@ -11,7 +11,7 @@ import {
cfLoadDestinationSets ,
cfLoadMappingsFull ,
cfLoadSourceSets ,
cfLoadTimeSets , cfUpdate OfficeHours,
cfLoadTimeSets , cfUpdate FullMapping, cfUpdate OfficeHours,
cfUpdateSourceSet ,
cfUpdateTimeSetDate ,
cfUpdateTimeSetDateRange ,
@ -309,14 +309,26 @@ export async function updateSourceSet ({ dispatch, commit, rootGetters }, payloa
export async function deleteSourceSet ( { dispatch , commit , rootGetters , state } , payload ) {
try {
dispatch ( 'wait/start' , 'csc-cf-source-set-create' , { root : true } )
const updatedMapping = _ . cloneDeep ( state . mappings [ payload . mapping . type ] )
updatedMapping [ payload . mapping . index ] . sourceset _id = null
updatedMapping [ payload . mapping . index ] . sourceset = null
const updatedMappings = await patchReplaceFull ( {
resource : 'cfmappings' ,
resourceId : ( payload . subscriberId ) ? payload . subscriberId : rootGetters [ 'user/getSubscriberId' ] ,
fieldPath : payload . mapping . type ,
value : updatedMapping
const subscriberId = payload . subscriberId || rootGetters [ 'user/getSubscriberId' ]
const currentMappings = { ... state . mappings }
const mappingTypes = Object . keys ( currentMappings ) . filter ( ( key ) => key !== 'cft_ringtimeout' && key !== 'id' )
mappingTypes . forEach ( ( type ) => {
currentMappings [ type ] = currentMappings [ type ] . map ( ( mapping ) => {
if ( mapping . sourceset _id === payload . id ) {
return {
... mapping ,
sourceset _id : null ,
sourceset : null
}
}
return mapping
} )
} )
const updatedMappings = await cfUpdateFullMapping ( {
subscriberId ,
body : currentMappings
} )
try {
await cfDeleteSourceSet ( payload . id )
@ -418,15 +430,28 @@ export async function updateTimeSetDate ({ dispatch, commit }, payload) {
export async function deleteTimeSet ( { dispatch , commit , rootGetters , state } , payload ) {
dispatch ( 'wait/start' , 'csc-cf-time-set-create' , { root : true } )
const updatedMapping = _ . cloneDeep ( state . mappings [ payload . mapping . type ] )
updatedMapping [ payload . mapping . index ] . timeset _id = null
updatedMapping [ payload . mapping . index ] . timeset = null
const updatedMappings = await patchReplaceFull ( {
resource : 'cfmappings' ,
resourceId : ( payload . subscriberId ) ? payload . subscriberId : rootGetters [ 'user/getSubscriberId' ] ,
fieldPath : payload . mapping . type ,
value : updatedMapping
const subscriberId = payload . subscriberId || rootGetters [ 'user/getSubscriberId' ]
const currentMappings = { ... state . mappings }
const mappingTypes = Object . keys ( currentMappings ) . filter ( ( key ) => key !== 'cft_ringtimeout' && key !== 'id' )
mappingTypes . forEach ( ( type ) => {
currentMappings [ type ] = currentMappings [ type ] . map ( ( mapping ) => {
if ( mapping . timeset _id === payload . id ) {
return {
... mapping ,
timeset _id : null ,
timeset : null
}
}
return mapping
} )
} )
const updatedMappings = await cfUpdateFullMapping ( {
subscriberId ,
body : currentMappings
} )
try {
await cfDeleteTimeSet ( payload . id )
} catch ( e ) {
@ -655,3 +680,11 @@ export async function updateAnnouncement ({ dispatch, commit, state }, payload)
destinationSets : destinationSets . items
} )
}
export function resetCallForwardingState ( { commit } ) {
commit ( 'resetState' )
}
export function setPopupShow ( { commit } , popupId ) {
commit ( 'popupShow' , popupId )
}