TT#100761 As a Customer, I want to see the number destination in call forwarding automatically rewritten

Change-Id: Ia1d16ff86a7f835db4a37717ae7b6a2c406dd696
pull/4/head
Carlo Venusino 5 years ago
parent 6df2d69eb8
commit 1c4f5ddc19

@ -156,7 +156,6 @@
buttons
@before-show="$store.commit('callForwarding/popupShow', null)"
@save="updateDestinationEvent({
destination: changedDestination,
destinationIndex: destinationIndex,
destinationSetId: destinationSet.id
})"
@ -208,6 +207,9 @@ import CscMoreMenu from 'components/CscMoreMenu'
import CscPopupMenuItemDelete from 'components/CscPopupMenuItemDelete'
import CscInput from 'components/form/CscInput'
import CscSpinner from 'components/CscSpinner'
import {
showGlobalError
} from 'src/helpers/ui'
export default {
name: 'CscCfGroupItem',
components: { CscSpinner, CscInput, CscPopupMenuItemDelete, CscMoreMenu },
@ -259,6 +261,11 @@ export default {
return 'csc-cf-group-item-' + this.destinationSet.id + '-' + this.destinationIndex
}
},
watch: {
destination () {
this.changedDestination = this.destination.simple_destination
}
},
mounted () {
if (this.mapping.type === 'cft' && this.destinationIndex === 0) {
this.changedDestinationTimeout = this.ringTimeout
@ -271,12 +278,19 @@ export default {
'updateDestination',
'removeDestination',
'updateDestinationTimeout',
'updateRingTimeout'
'updateRingTimeout',
'rewriteDestination'
]),
async updateDestinationEvent (payload) {
this.$wait.start(this.waitIdentifier)
await this.updateDestination(payload)
this.$wait.end(this.waitIdentifier)
try {
const validatedDest = await this.rewriteDestination(this.changedDestination)
await this.updateDestination({ ...payload, destination: validatedDest })
} catch (err) {
showGlobalError(err.message)
} finally {
this.$wait.end(this.waitIdentifier)
}
},
async removeDestinationEvent (payload) {
this.$q.dialog({

@ -162,6 +162,22 @@ export async function addDestination ({ dispatch, commit, state, rootGetters },
dispatch('wait/end', WAIT_IDENTIFIER, { root: true })
}
export async function rewriteDestination ({ dispatch, commit, state, rootGetters }, destination) {
try {
const req = await post({
resource: 'applyrewrites',
body: {
direction: 'callee_in',
subscriber_id: rootGetters['user/getSubscriberId'],
numbers: [destination]
}
})
return req.result
} catch (err) {
return destination
}
}
export async function removeDestination ({ dispatch, commit, state, rootGetters }, payload) {
dispatch('wait/start', WAIT_IDENTIFIER, { root: true })
const destinations = _.cloneDeep(state.destinationSetMap[payload.destinationSetId].destinations)

Loading…
Cancel
Save