From 93dc277051f90380bd084f55d0cae3dc253193e5 Mon Sep 17 00:00:00 2001 From: Robert Axelsen Date: Tue, 12 Sep 2017 15:58:45 +0200 Subject: [PATCH] TT#20654 Prevent cft and cfu from both rendering Change-Id: I3c2493a1449f7d324ce5d9e3ad880f5a0189eb79 --- .../callforward/CallForwardController.js | 80 +++++++++++-------- 1 file changed, 46 insertions(+), 34 deletions(-) diff --git a/classic/src/view/pages/callforward/CallForwardController.js b/classic/src/view/pages/callforward/CallForwardController.js index eeacaf6f..19cc387c 100644 --- a/classic/src/view/pages/callforward/CallForwardController.js +++ b/classic/src/view/pages/callforward/CallForwardController.js @@ -162,10 +162,19 @@ Ext.define('NgcpCsc.view.pages.callforward.CallForwardController', { } }, + hasMappings: function (mapping) { + return mapping.length !== 0; + }, + + hasMultipleMappings: function (mapping) { + return mapping.length > 1; + }, + cfStoreLoaded: function(store, data) { - var me = this; + var $cf = this; var cfTypeArrayOfObjects = [data.get('cfu'), data.get('cft'), data.get('cfb'), data.get('cfna')]; var cftRingTimeout = data.get('cft_ringtimeout'); + var hasCftAndCfuMappings = $cf.hasMappings(data.get('cfu')) && $cf.hasMappings(data.get('cft')); var cfTypes = ['cfu', 'cft', 'cfb', 'cfna']; var timeset = store._type; var arrayOfModels = []; @@ -189,46 +198,48 @@ Ext.define('NgcpCsc.view.pages.callforward.CallForwardController', { cfmappings.timesetName = cfTypeObject.timeset; if (cfmappings.timesetName == routeTimeset) { Ext.each(cfdestinationsets, function(cfdestinationset) { - if (cfdestinationset.name == cfmappings.destinationsetName && !cfmappings._modelCreated) { - cfdestinationset.destinations = me.sortDestinationsetByPriority(cfdestinationset.destinations); - if (cfType === 'cft') { - if (cfTypeObjects.length > 0) { - me.addCftOwnPhone(cfdestinationset.destinations, cftRingTimeout); + if (cfType.match(/(cfb|cfna)/) || cfType === 'cfu' && cfTypeObjects[0].destinationset === cfTypeObject.destinationset || !hasCftAndCfuMappings && cfType === 'cft') { + if (cfdestinationset.name == cfmappings.destinationsetName && !cfmappings._modelCreated) { + cfdestinationset.destinations = $cf.sortDestinationsetByPriority(cfdestinationset.destinations); + if (cfType === 'cft') { + if (cfTypeObjects.length > 0) { + $cf.addCftOwnPhone(cfdestinationset.destinations, cftRingTimeout); + } + }; + for (item in cfdestinationset.destinations) { + var destinationToDisplayInGrid = $cf.getDestinationFromSipId(cfdestinationset.destinations[item].destination); + var destinationAnnouncementId = cfdestinationset.announcement_id; + var destination = cfdestinationset.destinations[item].destination; + var priority = cfdestinationset.destinations[item].priority; + var timeout = cfdestinationset.destinations[item].timeout; + var destinationId = cfdestinationset.id; + var destinationName = cfdestinationset.name; + // Removes timeout if destination is not a number + var ringFor = !Ext.isNumber(parseInt(destinationToDisplayInGrid)) ? '' : cfdestinationset.destinations[item].timeout; + var cbModel = Ext.create('NgcpCsc.model.CallForwardDestination', { + type: cfType, + destination_displayed: destinationToDisplayInGrid, + destination: destination, + destination_announcement_id: destinationAnnouncementId, + priority: priority, + timeout_displayed: ringFor, + timeout: timeout, + sourceset: cfmappings.sourcesetName, + timeset: cfmappings.timesetName, + destinationset_id: destinationId, + destinationset_name: destinationName + }); + arrayOfModels.push(cbModel); + cfmappings._modelCreated = true; } - }; - for (item in cfdestinationset.destinations) { - var destinationToDisplayInGrid = me.getDestinationFromSipId(cfdestinationset.destinations[item].destination); - var destinationAnnouncementId = cfdestinationset.announcement_id; - var destination = cfdestinationset.destinations[item].destination; - var priority = cfdestinationset.destinations[item].priority; - var timeout = cfdestinationset.destinations[item].timeout; - var destinationId = cfdestinationset.id; - var destinationName = cfdestinationset.name; - // Removes timeout if destination is not a number - var ringFor = !Ext.isNumber(parseInt(destinationToDisplayInGrid)) ? '' : cfdestinationset.destinations[item].timeout; - var cbModel = Ext.create('NgcpCsc.model.CallForwardDestination', { - type: cfType, - destination_displayed: destinationToDisplayInGrid, - destination: destination, - destination_announcement_id: destinationAnnouncementId, - priority: priority, - timeout_displayed: ringFor, - timeout: timeout, - sourceset: cfmappings.sourcesetName, - timeset: cfmappings.timesetName, - destinationset_id: destinationId, - destinationset_name: destinationName - }); - arrayOfModels.push(cbModel); - cfmappings._modelCreated = true; } - } + }; }); }; }); }); if (arrayOfModels.length > 0) { - me.populateDestinationStores(arrayOfModels); + $cf.populateDestinationStores(arrayOfModels); }; }; }, @@ -581,6 +592,7 @@ Ext.define('NgcpCsc.view.pages.callforward.CallForwardController', { store.getAt(index).set('after_termination', false); }); }; + // TODO Is this redundant now? If so, remove // "Greyes out" destination if appearing after a terminating destination if (store.findRecord('type', 'cfu') && store.findRecord('type', 'cft')) { Ext.each(store.getRange(), function(record) {