From c69376fd94b735bbcf75477c091df9bcd47ac6de Mon Sep 17 00:00:00 2001 From: Robert Axelsen Date: Thu, 21 Sep 2017 11:07:23 +0200 Subject: [PATCH] TT#22076 Fix destination rendering issues Change-Id: Idf5ddd7709eccbc67d60a18c8aa2067b3d12f5fd --- .../callforward/CallForwardController.js | 41 +++++++++++++++++-- 1 file changed, 37 insertions(+), 4 deletions(-) diff --git a/classic/src/view/pages/callforward/CallForwardController.js b/classic/src/view/pages/callforward/CallForwardController.js index 882b4d6a..d94e8983 100644 --- a/classic/src/view/pages/callforward/CallForwardController.js +++ b/classic/src/view/pages/callforward/CallForwardController.js @@ -257,6 +257,20 @@ Ext.define('NgcpCsc.view.pages.callforward.CallForwardController', { return mapping.length !== 0; }, + removeExtraCfuDestinations: function () { + var stores = this.getStoresByStatus('online'); + Ext.each(stores.getRange(), function (store) { + if (store.first() && store.first().get('type') === 'cfu') { + var firstDestId = store.first().get('destinationset_id'); + store.each(function (record) { + if (record.get('destinationset_id') !== firstDestId) { + store.remove(record); + } + }); + }; + }); + }, + buildArrayOfModels: function(cfMappings, cfType, routeTimeset, cfdestinationsets, cftRingTimeout, arrayOfModels, hasCftAndCfuMappings) { var $cf = this; Ext.each(cfMappings, function(mapping, j) { @@ -266,12 +280,12 @@ Ext.define('NgcpCsc.view.pages.callforward.CallForwardController', { currentMapping.timesetName = mapping.timeset; if (currentMapping.timesetName == routeTimeset) { Ext.each(cfdestinationsets, function(cfdestinationset) { - if (cfType.match(/(cfb|cfna)/) || cfType === 'cfu' && cfMappings[0].destinationset === mapping.destinationset || !hasCftAndCfuMappings && cfType === 'cft') { + if (cfType !== 'cft' || !hasCftAndCfuMappings && cfType === 'cft') { // _modelCreated check in place to make sure we don't add the destinationset more // than one time if the cftype already has that destinationset added as model if (cfdestinationset.name == currentMapping.destinationsetName && !currentMapping._modelCreated) { cfdestinationset.destinations = $cf.sortDestinationsetByPriority(cfdestinationset.destinations); - if (cfType === 'cft' && cfMappings[0].destinationset === mapping.destinationset) { + if (cfType === 'cft') { $cf.addCftOwnPhone(cfdestinationset.destinations, cftRingTimeout); }; for (item in cfdestinationset.destinations) { @@ -326,13 +340,12 @@ Ext.define('NgcpCsc.view.pages.callforward.CallForwardController', { $cf.buildArrayOfModels(cfuMappings, 'cfu', routeTimeset, cfdestinationsets, cftRingTimeout, arrayOfModels); $cf.buildArrayOfModels(cftMappings, 'cft', routeTimeset, cfdestinationsets, cftRingTimeout, arrayOfModels, hasCftAndCfuMappings); $cf.buildArrayOfModels(cfnaMappings, 'cfna', routeTimeset, cfdestinationsets, cftRingTimeout, arrayOfModels); - $cf.addOwnPhoneToEmptyOnline(); if (arrayOfModels.length > 0) { $vm.set('arrayOfDestModels', arrayOfModels); $cf.populateDestinationStores(); }; - $cf.unmaskDestinationGrids(); }; + $cf.unmaskDestinationGrids(); }, failure: function(response, opts) { @@ -341,6 +354,7 @@ Ext.define('NgcpCsc.view.pages.callforward.CallForwardController', { }); }, + hasDestinationWithId: function(arr, id) { return arr.some(function(arrObj) { return id == arrObj.id; @@ -704,6 +718,22 @@ Ext.define('NgcpCsc.view.pages.callforward.CallForwardController', { }); }, + removeOwnPhoneDuplicates: function () { + console.log('removeOwnPhoneDuplicates'); + var $cf = this; + var $vm = $cf.getViewModel(); + var stores = $cf.getStoresByStatus('online'); + Ext.each(stores.getRange(), function(store) { + var index = 0; + store.each(function (record) { + if (index > 0 && record.get('destination') === 'own phone') { + store.remove(record); + } + index++ + }); + }); + }, + populateDestinationStores: function() { var $cf = this; var $vm = $cf.getViewModel(); @@ -733,8 +763,11 @@ Ext.define('NgcpCsc.view.pages.callforward.CallForwardController', { store._emptied = false; }); }; + $cf.removeExtraCfuDestinations(); + $cf.removeOwnPhoneDuplicates(); $vm.set('destStoresPopulated', true); }; + $cf.addOwnPhoneToEmptyOnline(); }, getStoresByStatus: function (status) {