|
|
@ -172,10 +172,6 @@ define(function(require) { |
|
|
* @param {Object} args |
|
|
* @param {Object} args |
|
|
* @param {jQuery} args.parent Parent template |
|
|
* @param {jQuery} args.parent Parent template |
|
|
* @param {String} [args.openElement] Name of the element to display on render |
|
|
* @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 |
|
|
* @param {Function} [args.callback] Callback to execute after render |
|
|
*/ |
|
|
*/ |
|
|
strategyRender: function(args) { |
|
|
strategyRender: function(args) { |
|
|
@ -183,7 +179,6 @@ define(function(require) { |
|
|
args = args || {}, |
|
|
args = args || {}, |
|
|
parent = args.parent || $('.right-content'), |
|
|
parent = args.parent || $('.right-content'), |
|
|
openElement = args.openElement, |
|
|
openElement = args.openElement, |
|
|
action = args.action, |
|
|
|
|
|
callback = args.callback; |
|
|
callback = args.callback; |
|
|
|
|
|
|
|
|
monster.parallel({ |
|
|
monster.parallel({ |
|
|
@ -256,7 +251,6 @@ define(function(require) { |
|
|
self.strategyRefreshTemplate({ |
|
|
self.strategyRefreshTemplate({ |
|
|
container: element, |
|
|
container: element, |
|
|
strategyData: results, |
|
|
strategyData: results, |
|
|
action: action, |
|
|
|
|
|
callback: function() { |
|
|
callback: function() { |
|
|
element.addClass('open'); |
|
|
element.addClass('open'); |
|
|
element.find('.element-content').show(); |
|
|
element.find('.element-content').show(); |
|
|
@ -635,10 +629,6 @@ define(function(require) { |
|
|
* @param {Object} args |
|
|
* @param {Object} args |
|
|
* @param {jQuery} args.container Container template |
|
|
* @param {jQuery} args.container Container template |
|
|
* @param {Object} args.strategyData Strategy data |
|
|
* @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 |
|
|
* @param {Function} [args.callback] Optional callback to execute after refresh |
|
|
*/ |
|
|
*/ |
|
|
strategyRefreshTemplate: function(args) { |
|
|
strategyRefreshTemplate: function(args) { |
|
|
@ -992,10 +982,6 @@ define(function(require) { |
|
|
* @param {jQuery} args.container Container template |
|
|
* @param {jQuery} args.container Container template |
|
|
* @param {Object} args.strategyData Strategy data |
|
|
* @param {Object} args.strategyData Strategy data |
|
|
* @param {Object} args.templateName Template name |
|
|
* @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 |
|
|
* @param {Function} [args.callback] Optional callback to execute after refresh |
|
|
*/ |
|
|
*/ |
|
|
strategyRefreshTemplateNumbers: function(args) { |
|
|
strategyRefreshTemplateNumbers: function(args) { |
|
|
@ -1003,8 +989,6 @@ define(function(require) { |
|
|
$container = args.container, |
|
|
$container = args.container, |
|
|
strategyData = args.strategyData, |
|
|
strategyData = args.strategyData, |
|
|
templateName = args.templateName, |
|
|
templateName = args.templateName, |
|
|
action = args.action, |
|
|
|
|
|
actionType = _.get(action, 'type'), |
|
|
|
|
|
callback = args.callback; |
|
|
callback = args.callback; |
|
|
|
|
|
|
|
|
self.strategyListAccountNumbers(function(accountNumbers) { |
|
|
self.strategyListAccountNumbers(function(accountNumbers) { |
|
|
@ -1046,98 +1030,6 @@ define(function(require) { |
|
|
number: numberId, |
|
|
number: numberId, |
|
|
callbacks: callbacks |
|
|
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) { |
|
|
_.each(templateData.numbers, function(data) { |
|
|
@ -1162,11 +1054,6 @@ define(function(require) { |
|
|
.empty() |
|
|
.empty() |
|
|
.append(template); |
|
|
.append(template); |
|
|
|
|
|
|
|
|
// Execute any additional action that has been requested
|
|
|
|
|
|
if (_.has(actions, actionType)) { |
|
|
|
|
|
actions[actionType](templateData.numbers); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
callback && callback(); |
|
|
callback && callback(); |
|
|
}); |
|
|
}); |
|
|
}, |
|
|
}, |
|
|
@ -1360,7 +1247,7 @@ define(function(require) { |
|
|
message: self.i18n.active().strategy.toastrMessages.removeNumberSuccess |
|
|
message: self.i18n.active().strategy.toastrMessages.removeNumberSuccess |
|
|
}); |
|
|
}); |
|
|
strategyData.callflows.MainCallflow = updatedCallflow; |
|
|
strategyData.callflows.MainCallflow = updatedCallflow; |
|
|
refreshNumbersTemplate(updateCallflow); |
|
|
|
|
|
|
|
|
refreshNumbersTemplate(); |
|
|
|
|
|
|
|
|
self.strategyGetAccount({ |
|
|
self.strategyGetAccount({ |
|
|
success: function(accountData) { |
|
|
success: function(accountData) { |
|
|
|