diff --git a/submodules/devices/devices.js b/submodules/devices/devices.js index 00a4b0b7..d2652455 100644 --- a/submodules/devices/devices.js +++ b/submodules/devices/devices.js @@ -335,6 +335,21 @@ define(function(require) { */ devicesRenderDevice: function(args) { var self = this, + isCallerIdConfigurable = function() { + if (!monster.util.isNumberFeatureEnabled('e911')) { + return false; + } + var isEditableWhenSetOnAccount = monster.util.isFeatureAvailable( + 'smartpbx.devices.settings.callerId.editWhenSetOnAccount' + ), + isNotSetOnAccount = _ + .chain(monster.apps.auth.currentAccount) + .get('caller_id.external.number') + .isUndefined() + .value(); + + return isEditableWhenSetOnAccount || isNotSetOnAccount; + }, data = _.get(args, 'data'), isAssignAllowed = !!_.get(args, 'allowAssign', true), callbackSave = _.get(args, 'callbackSave'), @@ -353,7 +368,7 @@ define(function(require) { name: 'devices-' + type, data: $.extend(true, {}, data, { isProvisionerConfigured: monster.config.api.hasOwnProperty('provisioner'), - showEmergencyCallerId: monster.util.isNumberFeatureEnabled('e911') + showEmergencyCallerId: isCallerIdConfigurable() }), submodule: 'devices' })), diff --git a/submodules/users/users.js b/submodules/users/users.js index e11e43cc..e915b41f 100644 --- a/submodules/users/users.js +++ b/submodules/users/users.js @@ -204,6 +204,17 @@ define(function(require) { ); return i18n[key]; }, + isFeatureAvailable = function(data, id) { + var isFeatureAvailable = monster.util.isFeatureAvailable( + ['smartpbx', 'users', 'features', _.camelCase(id), 'edit'] + ), + availabilityChecker = _.get(data, 'availabilityChecker', _.stubTrue); + + return _.every([ + isFeatureAvailable, + availabilityChecker() + ]); + }, dataUser = data.user, _mainDirectory = data.mainDirectory, _mainCallflow = data.userMainCallflow, @@ -226,6 +237,18 @@ define(function(require) { differentEmail: dataUser.email !== dataUser.username, mapFeatures: _.pickBy({ caller_id: { + availabilityChecker: function() { + var isEditableWhenSetOnAccount = monster.util.isFeatureAvailable( + 'smartpbx.users.features.callerId.editWhenSetOnAccount' + ), + isNotSetOnAccount = _ + .chain(monster.apps.auth.currentAccount) + .get('caller_id.external.number') + .isUndefined() + .value(); + + return isEditableWhenSetOnAccount || isNotSetOnAccount; + }, icon: 'fa fa-user', iconColor: 'monster-blue', title: self.i18n.active().users.caller_id.title @@ -281,11 +304,7 @@ define(function(require) { iconColor: 'monster-red', title: self.i18n.active().users.do_not_disturb.title } - }, function(object, feature) { - return monster.util.isFeatureAvailable( - ['smartpbx', 'users', 'features', _.camelCase(feature), 'edit'] - ); - }), + }, isFeatureAvailable), outboundPrivacy: _.map(self.appFlags.common.outboundPrivacy, function(item) { return { key: item, @@ -2331,7 +2350,7 @@ define(function(require) { featureForm = featureTemplate.find('#vmbox_form'), switchTranscription = featureForm.find('#transcribe').parent(), switchVmToEmail = featureForm.find('#vm_to_email_enabled'); - + if (!monster.util.isFeatureAvailable('smartpbx.users.features.vmbox.transcription')) { switchTranscription.addClass('disabled'); }