Browse Source

UI-2848: changed the way we initialize maincallflow, to stop routing to 0 automatically, even when they wouldn't configure a main number

4.3
Jean-Roch Maitre 8 years ago
parent
commit
4cffee3567
2 changed files with 21 additions and 11 deletions
  1. +1
    -1
      submodules/myOffice/myOffice.js
  2. +20
    -10
      submodules/strategy/strategy.js

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

@ -542,7 +542,7 @@ define(function(require) {
if (numberArrayName.length > 0) {
if (!(numberArrayName in data)) { data[numberArrayName] = []; }
_.each(val.numbers, function(num) {
if (num !== '0' && num !== 'undefined' && num !== 'undefinedconf' && num !== 'undefinedfaxing') {
if (['0', 'undefined', 'undefinedconf', 'undefinedfaxing', 'undefinedMainNumber'].indexOf(num) < 0) {
var number = {
number: num
};


+ 20
- 10
submodules/strategy/strategy.js View File

@ -193,6 +193,7 @@ define(function(require) {
});
}
}, function(err, results) {
// has to be > 1 because we automatically add "undefinedMainNumber" as a placeholder for the "0" that will be automatically added if they add a Main number
var hasMainNumber = (results.callflows.MainCallflow.numbers.length > 1),
hasConfNumber = (results.callflows.MainConference.numbers.length > 0 && results.callflows.MainConference.numbers[0] !== 'undefinedconf'),
hasFaxingNumber = (results.callflows.MainFaxing.numbers.length > 0 && results.callflows.MainFaxing.numbers[0] !== 'undefinedfaxing'),
@ -462,7 +463,7 @@ define(function(require) {
numbers = callflow.numbers,
templateData = {
numbers: $.map(numbers, function(val, key) {
if (val !== '0') {
if (val !== '0' && val !== 'undefinedMainNumber') {
var ret = {
number: {
id: val
@ -823,8 +824,15 @@ define(function(require) {
var self = this,
addNumbersToMainCallflow = function(numbers) {
if (numbers.length) {
var mainCallflow = strategyData.callflows.MainCallflow;
var mainCallflow = strategyData.callflows.MainCallflow,
indexPlaceholder = mainCallflow.numbers.indexOf('undefinedMainNumber');
if (indexPlaceholder >= 0) {
mainCallflow.numbers[indexPlaceholder] = '0';
}
mainCallflow.numbers = mainCallflow.numbers.concat(numbers);
self.strategyUpdateCallflow(mainCallflow, function(updatedCallflow) {
var parentContainer = container.parents('.element-container');
strategyData.callflows.MainCallflow = updatedCallflow;
@ -914,6 +922,12 @@ define(function(require) {
updateCallflow = function() {
strategyData.callflows.MainCallflow.numbers.splice(indexToRemove, 1);
// We don't want the '0' to stay in the routing system if they're no longer using SmartPBX.
// If they remove their last main number, we consider they don't use SmartPBX, so we reset the "0" to be the "undefinedMainNumber"
if (strategyData.callflows.MainCallflow.numbers.length === 1 && strategyData.callflows.MainCallflow.numbers[0] === '0') {
strategyData.callflows.MainCallflow.numbers[0] = 'undefinedMainNumber';
}
self.strategyUpdateCallflow(strategyData.callflows.MainCallflow, function(updatedCallflow) {
var parentContainer = container.parents('.element-container');
toastr.success(self.i18n.active().strategy.toastrMessages.removeNumberSuccess);
@ -2979,7 +2993,7 @@ define(function(require) {
contact_list: {
exclude: false
},
numbers: ['0'],
numbers: ['undefinedMainNumber'],
name: 'MainCallflow',
type: 'main',
flow: {
@ -3003,13 +3017,9 @@ define(function(require) {
}
});
} else {
delete results.MainCallflow.flow.data.timezone;
if (results.MainCallflow.numbers[0] !== '0') {
if (results.MainCallflow.numbers[0] === 'undefined') {
results.MainCallflow.numbers[0] = '0';
} else {
results.MainCallflow.numbers.splice(0, 0, '0');
}
// For users who had undesired callflow with only "0" in it, we migrate it to our new empty main callflow "undefinedMainNumber"
if (results.MainCallflow.numbers && results.MainCallflow.numbers.length === 1 && results.MainCallflow.numbers[0] === '0') {
results.MainCallflow.numbers[0] = 'undefinedMainNumber';
self.strategyUpdateCallflow(results.MainCallflow, function(updatedCallflow) {
results.MainCallflow = updatedCallflow;


Loading…
Cancel
Save