TT#21450 Fix reference problem destinationsets

What has been done:
- #21450 CallForward: Fix reference problem with DestinationSets
  which are changed globally over all SourceSets
- Fix issue with last destination removal in grid not resulting in
  any writing to API (remains undeleted)

Change-Id: Ieb1fd6d05a050985b63dca18fabd92df2b9d1d87
changes/23/15223/4
Robert Axelsen 8 years ago
parent 592fa6c22c
commit e0e6f0b90d

@ -278,9 +278,10 @@ Ext.define('NgcpCsc.view.pages.callforward.CallForwardController', {
};
};
});
Ext.each(recordsToSend, function(obj) {
if (recordsToSend.length === 0) {
var destinationsetId = store.removed[0].data.destinationset_id;
Ext.Ajax.request({
url: '/api/cfdestinationsets/' + obj.id,
url: '/api/cfdestinationsets/' + destinationsetId,
method: 'PATCH',
headers: {
'Content-Type': 'application/json-patch+json'
@ -288,7 +289,7 @@ Ext.define('NgcpCsc.view.pages.callforward.CallForwardController', {
jsonData: [{
"op": "add",
"path": "/destinations",
"value": obj.records
"value": []
}],
success: function(response, opts) {
var currentRoute = window.location.hash;
@ -300,7 +301,31 @@ Ext.define('NgcpCsc.view.pages.callforward.CallForwardController', {
console.log('server-side failure with status code ' + response.status);
}
});
});
} else {
Ext.each(recordsToSend, function(obj) {
Ext.Ajax.request({
url: '/api/cfdestinationsets/' + obj.id,
method: 'PATCH',
headers: {
'Content-Type': 'application/json-patch+json'
},
jsonData: [{
"op": "add",
"path": "/destinations",
"value": obj.records
}],
success: function(response, opts) {
var currentRoute = window.location.hash;
var currentStoreName = me.getStoreNameFromRoute(currentRoute);
Ext.getStore(currentStoreName).load();
vm.set('last_store_synced', currentStoreName);
},
failure: function(response, opts) {
console.log('server-side failure with status code ' + response.status);
}
});
});
};
return false;
},
@ -553,6 +578,7 @@ Ext.define('NgcpCsc.view.pages.callforward.CallForwardController', {
}
});
},
populateDestinationStores: function(models) {
var me = this;
var store;
@ -580,6 +606,7 @@ Ext.define('NgcpCsc.view.pages.callforward.CallForwardController', {
});
}
},
createSourcesetTabs: function(sourcesets) {
var me = this;
var vm = this.getViewModel();
@ -1030,20 +1057,30 @@ Ext.define('NgcpCsc.view.pages.callforward.CallForwardController', {
createNewMapping: function(subscriberId, newType, newDestinationsetName, newSourceset, newTimeset) {
Ext.Ajax.request({
url: '/api/cfmappings/' + subscriberId,
method: 'PATCH',
headers: {
'Content-Type': 'application/json-patch+json'
},
jsonData: [{
"op": "add",
"path": "/" + newType,
"value": [{
url: '/api/cfmappings/' + localStorage.getItem('subscriber_id'),
method: 'GET',
jsonData: {},
success: function(response) {
var decodedResponse = Ext.decode(response.responseText);
var mappings = decodedResponse[newType];
mappings.push({
"destinationset": newDestinationsetName,
"sourceset": newSourceset,
"timeset": newTimeset
}]
}]
});
Ext.Ajax.request({
url: '/api/cfmappings/' + subscriberId,
method: 'PATCH',
headers: {
'Content-Type': 'application/json-patch+json'
},
jsonData: [{
"op": "add",
"path": "/" + newType,
"value": mappings
}]
});
}
});
},

Loading…
Cancel
Save