Browse Source

MSPB-3: Show CallerID dialog to set E911/CallerID (#153)

4.3
Guillermo Gutiérrez 6 years ago
committed by Joris Tirado
parent
commit
cac4d8ff10
4 changed files with 54 additions and 128 deletions
  1. +50
    -11
      submodules/myOffice/myOffice.js
  2. +1
    -1
      submodules/myOffice/myOffice.scss
  3. +2
    -2
      submodules/myOffice/views/layout.html
  4. +1
    -114
      submodules/strategy/strategy.js

+ 50
- 11
submodules/myOffice/myOffice.js View File

@ -655,25 +655,37 @@ define(function(require) {
});
if (data.mainNumbers && data.mainNumbers.length > 0) {
var hasValidCallerId = monster.util.isNumberFeatureEnabled('cnam') === false || data.account.hasOwnProperty('caller_id') && data.account.caller_id.hasOwnProperty('emergency') && data.account.caller_id.emergency.hasOwnProperty('number') && data.numbers.hasOwnProperty(data.account.caller_id.emergency.number),
hasValidE911 = monster.util.isNumberFeatureEnabled('e911') === false || data.account.hasOwnProperty('caller_id') && data.account.caller_id.hasOwnProperty('emergency') && data.account.caller_id.emergency.hasOwnProperty('number') && data.numbers.hasOwnProperty(data.account.caller_id.emergency.number) && data.numbers[data.account.caller_id.emergency.number].features.indexOf('e911') >= 0;
var bypassCnam = !monster.util.isNumberFeatureEnabled('cnam'),
isExternalNumberSet = _.has(data.numbers, _.get(data.account, 'caller_id.external.number')),
hasValidCallerId = bypassCnam || isExternalNumberSet,
bypassE911 = !monster.util.isNumberFeatureEnabled('e911'),
isEmergencyNumberSet = _
.chain(data.numbers)
.get([ _.get(data.account, 'caller_id.emergency.number'), 'features' ])
.includes('e911')
.value(),
hasValidE911 = bypassE911 || isEmergencyNumberSet;
if (!hasValidCallerId && !hasValidE911) {
data.topMessage = {
cssClass: 'btn-danger',
message: self.i18n.active().myOffice.missingCnamE911Message,
action: 'checkMissingE911'
category: 'myOffice',
subcategory: 'callerIdDialog'
};
} else if (!hasValidCallerId) {
data.topMessage = {
cssClass: 'btn-danger',
message: self.i18n.active().myOffice.missingCnamMessage
message: self.i18n.active().myOffice.missingCnamMessage,
category: 'myOffice',
subcategory: 'callerIdDialog'
};
} else if (!hasValidE911) {
data.topMessage = {
cssClass: 'btn-danger',
message: self.i18n.active().myOffice.missingE911Message,
action: 'checkMissingE911'
category: 'myOffice',
subcategory: 'callerIdDialog'
};
}
}
@ -702,8 +714,7 @@ define(function(require) {
template.find('.link-box').on('click', function(e) {
var $this = $(this),
category = $this.data('category'),
subcategory = $this.data('subcategory'),
actionType = $this.data('action');
subcategory = $this.data('subcategory');
$('.category').removeClass('active');
switch (category) {
@ -723,10 +734,14 @@ define(function(require) {
$('.category#strategy').addClass('active');
monster.pub('voip.strategy.render', {
parent: parent,
openElement: subcategory,
action: {
type: actionType
}
openElement: subcategory
});
break;
case 'myOffice':
self.myOfficeOpenElement({
data: myOfficeData,
element: subcategory,
parent: parent
});
break;
}
@ -756,6 +771,30 @@ define(function(require) {
monster.ui.tooltips(template);
},
/**
* Opens an element within this submodule
* @param {Object} args
* @param {Object} args.data Data to be provided to the element to be displayed
* @param {('callerIdDialog')} args.element Name of the element to open
* @param {jQuery} args.parent Parent container
*/
myOfficeOpenElement: function(args) {
var self = this,
data = args.data,
element = args.element,
$parent = args.parent;
// Currently only the Caller ID dialog is handled
if (element !== 'callerIdDialog') {
return;
}
self.myOfficeRenderCallerIdPopup({
parent: $parent,
myOfficeData: data
});
},
myOfficeRenderMusicOnHoldPopup: function(args) {
var self = this,
account = args.account,


+ 1
- 1
submodules/myOffice/myOffice.scss View File

@ -70,7 +70,7 @@
opacity: 0.8;
}
.dashboard-top-message{
&.link-box[data-action] {
&.link-box[data-category] {
cursor: pointer;
&:hover {
background-color: #ff3b29;


+ 2
- 2
submodules/myOffice/views/layout.html View File

@ -23,8 +23,8 @@
<div class="dashboard-content">
{{#if topMessage}}
<div class="dashboard-top-message {{topMessage.cssClass}} link-box" data-category="strategy" data-subcategory="main-number"{{#if topMessage.action}} data-action="{{topMessage.action}}"{{/if}}>
<i class="fa fa-exclamation-triangle"></i>{{topMessage.message}}<!-- {{i18n.myOffice.missingE911Message}} -->
<div class="dashboard-top-message {{topMessage.cssClass}} link-box" data-category="{{topMessage.category}}" data-subcategory="{{topMessage.subcategory}}">
<i class="fa fa-exclamation-triangle"></i>{{topMessage.message}}
</div>
{{/if}}
<div class="dashboard-content-div dashboard-left-content">


+ 1
- 114
submodules/strategy/strategy.js View File

@ -172,10 +172,6 @@ define(function(require) {
* @param {Object} args
* @param {jQuery} args.parent Parent template
* @param {String} [args.openElement] Name of the element to display on render
* @param {Object} [args.action] Action to execute on render
* @param {String} [args.action.type] Type of action to execute
* @param {Object} [args.action.callbacks] Action callbacks
* @param {Function} [args.action.callbacks.success] Action success callback
* @param {Function} [args.callback] Callback to execute after render
*/
strategyRender: function(args) {
@ -183,7 +179,6 @@ define(function(require) {
args = args || {},
parent = args.parent || $('.right-content'),
openElement = args.openElement,
action = args.action,
callback = args.callback;
monster.parallel({
@ -256,7 +251,6 @@ define(function(require) {
self.strategyRefreshTemplate({
container: element,
strategyData: results,
action: action,
callback: function() {
element.addClass('open');
element.find('.element-content').show();
@ -635,10 +629,6 @@ define(function(require) {
* @param {Object} args
* @param {jQuery} args.container Container template
* @param {Object} args.strategyData Strategy data
* @param {Object} [args.action] Action to execute
* @param {String} [args.action.type] Type of action to execute
* @param {Object} [args.action.callbacks] Action callbacks
* @param {Function} [args.action.callbacks.success] Action success callback
* @param {Function} [args.callback] Optional callback to execute after refresh
*/
strategyRefreshTemplate: function(args) {
@ -992,10 +982,6 @@ define(function(require) {
* @param {jQuery} args.container Container template
* @param {Object} args.strategyData Strategy data
* @param {Object} args.templateName Template name
* @param {Object} [args.action] Action to execute
* @param {String} [args.action.type] Type of action to execute
* @param {Object} [args.action.callbacks] Action callbacks
* @param {Function} [args.action.callbacks.success] Action success callback
* @param {Function} [args.callback] Optional callback to execute after refresh
*/
strategyRefreshTemplateNumbers: function(args) {
@ -1003,8 +989,6 @@ define(function(require) {
$container = args.container,
strategyData = args.strategyData,
templateName = args.templateName,
action = args.action,
actionType = _.get(action, 'type'),
callback = args.callback;
self.strategyListAccountNumbers(function(accountNumbers) {
@ -1046,98 +1030,6 @@ define(function(require) {
number: numberId,
callbacks: callbacks
});
},
actions = {
checkMissingE911: function(numbers) {
if (!monster.util.isNumberFeatureEnabled('e911')) {
// E911 feature is not enabled for the account, so there is
// nothing to do here
return;
}
// Cases:
// * If there is one or more main numbers with E911 set:
// - If there is one number, set that number as the emergency
// caller ID for the account.
// - If there are 2 or more, display dialog to choose number,
// then set it as the account emergency caller ID.
// * If there are one or more numbers with E911 available (but not
// set), then:
// - If there is one number, select that number for E911.
// - If there are 2 or more, display dialog to choose number.
// Then display pop-up to set and save the info, and set the
// selected number as the account emergency caller ID.
// * If there are no numbers with E911 feature available, display
// toast to notify the user about it.
monster.waterfall([
function(callback) {
var isE911Active = _.some(numbers, function(numberData) {
return _.includes(numberData.number.features, 'e911');
});
if (isE911Active) {
callback('OK', { });
} else {
callback(null);
}
},
function(callback) {
var e911AvailableNumbers = _.filter(numbers, function(numberData) {
var availableFeatures = monster.util.getNumberFeatures(numberData.number);
return _.includes(availableFeatures, 'e911');
});
if (_.isEmpty(e911AvailableNumbers)) {
callback('no_e911_numbers');
} else {
callback(null, e911AvailableNumbers);
}
},
function(e911AvailableNumbers, callback) {
if (e911AvailableNumbers.length === 1) {
callback(null, _.head(e911AvailableNumbers).number.id);
return;
}
self.strategyShowNumberChoices({
callerIdType: 'emergency',
newNumbers: _.map(e911AvailableNumbers, 'number.id'),
save: function(number) {
callback(null, number);
}
});
},
function(numberId, callback) {
monster.pub('common.e911.renderPopup', {
phoneNumber: numberId,
callbacks: {
success: function(data) {
callback(null, {
numberId: numberId,
features: data.data.features
});
},
error: function() {
callback(true);
}
}
});
}
], function(err, results) {
if (err && err !== 'OK') {
if (err === 'no_e911_numbers') {
monster.ui.toast({
type: 'warning',
message: self.i18n.active().strategy.toastrMessages.noE911NumberAvailable
});
} else {
_.has(action, 'callbacks.error') && action.callbacks.error(err);
}
} else {
afterFeatureUpdate(results.numberId, results.features, action.callbacks);
}
});
}
};
_.each(templateData.numbers, function(data) {
@ -1162,11 +1054,6 @@ define(function(require) {
.empty()
.append(template);
// Execute any additional action that has been requested
if (_.has(actions, actionType)) {
actions[actionType](templateData.numbers);
}
callback && callback();
});
},
@ -1360,7 +1247,7 @@ define(function(require) {
message: self.i18n.active().strategy.toastrMessages.removeNumberSuccess
});
strategyData.callflows.MainCallflow = updatedCallflow;
refreshNumbersTemplate(updateCallflow);
refreshNumbersTemplate();
self.strategyGetAccount({
success: function(accountData) {


Loading…
Cancel
Save