Browse Source

Toggle user caller id strategy (#48)

* Allow toggle via config between two caller id selection methods

This only affects caller ID for users. If
monster.config.whitelabel.allowAnyOwnedNumberAsCallerID is falsy, the
old way of assigning caller ID will be activated i.e. users can only
have their caller ID set to numbers assigned to them, otherwise the main
number is used. If monster.config.whitelabel.allowAnyOwnedNumberAsCallerID
is truthy, the user can also have any number owned by the account used as
their caller ID.

* Add automatic eslint fixes

* Eslint fix: make mixed user of && and || tidier
4.3
mira-t 8 years ago
committed by JRMaitre
parent
commit
1ef1fb2cfe
3 changed files with 46 additions and 8 deletions
  1. +2
    -0
      i18n/en-US.json
  2. +31
    -5
      submodules/users/users.js
  3. +13
    -3
      views/users-feature-caller_id.html

+ 2
- 0
i18n/en-US.json View File

@ -671,6 +671,8 @@
"caller_id": {
"title": "Caller-ID Number",
"dropdownLabel": "Show my Caller-Id Number as",
"currentCallerIdLabel": "Current Caller-ID: ",
"none": "None",
"headline": "User Caller-ID Number Settings",
"help": "If you don't enable this feature, the Caller-ID displayed by default will be the one configured on the Main Number of this account."
},


+ 31
- 5
submodules/users/users.js View File

@ -1369,7 +1369,24 @@ define(function(require) {
});
template.on('click', '.feature[data-feature="caller_id"]', function() {
self.usersRenderCallerId(currentUser);
if (monster.config.whitelabel && monster.config.whitelabel.allowAnyOwnedNumberAsCallerID) {
self.usersListNumbers(function(accountNumbers) {
var numberChoices = accountNumbers.numbers,
phoneNumber;
for (phoneNumber in numberChoices) {
numberChoices[monster.util.formatPhoneNumber(phoneNumber)] = $.extend(true, {}, numberChoices[phoneNumber]);
if (phoneNumber !== monster.util.formatPhoneNumber(phoneNumber)) {
delete numberChoices[phoneNumber];
}
}
if (currentUser.caller_id && currentUser.caller_id.external && currentUser.caller_id.external.number) {
currentUser.caller_id.external.number = monster.util.formatPhoneNumber(currentUser.caller_id.external.number);
}
self.usersRenderCallerId(currentUser, numberChoices);
});
} else {
self.usersRenderCallerId(currentUser);
}
});
template.on('click', '.feature[data-feature="call_forward"]', function() {
@ -1999,10 +2016,19 @@ define(function(require) {
});
},
usersRenderCallerId: function(currentUser) {
usersRenderCallerId: function(currentUser, numberChoices) {
var self = this,
featureTemplate = $(monster.template(self, 'users-feature-caller_id', currentUser)),
switchFeature = featureTemplate.find('.switch-state');
allowAnyOwnedNumberAsCallerID = monster.config.whitelabel && monster.config.whitelabel.allowAnyOwnedNumberAsCallerID ? true : false,
templateUser = $.extend(true, {allowAnyOwnedNumberAsCallerID: allowAnyOwnedNumberAsCallerID}, currentUser),
featureTemplate,
switchFeature;
if (numberChoices && monster.config.whitelabel && monster.config.whitelabel.allowAnyOwnedNumberAsCallerID) {
templateUser.caller_id.numberChoices = numberChoices;
}
featureTemplate = $(monster.template(self, 'users-feature-caller_id', templateUser));
switchFeature = featureTemplate.find('.switch-state');
featureTemplate.find('.cancel-link').on('click', function() {
popup.dialog('close').remove();
@ -2041,7 +2067,7 @@ define(function(require) {
});
});
if (currentUser.extra.listCallerId.length > 0) {
if (currentUser.extra.listCallerId.length > 0 || (monster.config.whitelabel && monster.config.whitelabel.allowAnyOwnedNumberAsCallerID)) {
var popup = monster.ui.dialog(featureTemplate, {
title: currentUser.extra.mapFeatures.caller_id.title,
position: ['center', 20]


+ 13
- 3
views/users-feature-caller_id.html View File

@ -11,11 +11,21 @@
</div>
</div>
<div class="content{{#unless extra.mapFeatures.caller_id.active}} disabled{{/unless}}">
{{#if allowAnyOwnedNumberAsCallerID }}
{{ i18n.users.caller_id.currentCallerIdLabel }}
{{#if caller_id.external.number }}{{ caller_id.external.number }}{{else}}{{i18n.users.caller_id.none}}{{/if}}<br />
{{/if}}
{{ i18n.users.caller_id.dropdownLabel }}
<select class="caller-id-select">
{{#each extra.listCallerId}}
<option{{#compare ../this.caller_id.external.number "===" this}} selected{{/compare}} value="{{this}}">{{this}}</option>
{{/each}}
{{#if allowAnyOwnedNumberAsCallerID }}
{{#each caller_id.numberChoices}}
<option{{#compare ../caller_id.external.number "===" @key}} selected{{/compare}} value="{{@key}}">{{@key}}</option>
{{/each}}
{{else}}
{{#each extra.listCallerId}}
<option{{#compare ../this.caller_id.external.number "===" this}} selected{{/compare}} value="{{this}}">{{this}}</option>
{{/each}}
{{/if}}
</select>
{{#monsterText}}


Loading…
Cancel
Save