@ -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. i d,
url : '/api/cfdestinationsets/' + destinationsetI d,
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
} ]
} ) ;
}
} ) ;
} ,