MT#60187 bugfixes on call forwarding

When testing the bugfix mentioned in the ticket I found the below
bugs and proceeded with the fixes:
- cscCfGroupConditionDate: added try/catch to handle better errors.
  Before the fix the component was gettign stuck on loading when
  the backend was returning an error
- refactored post() in common.js to reflect sipwise js policy
- actions.js: fixed bug to pass correct timeSetId in the cfmapping
  PATCH requests. Before the fix we were passing an object with all
  the data of the new timeset rather than the id only and the backend
  was complaining.

Change-Id: I7bfabaf7a1a2aea8c6034de0d8f76e2f90633cdb
mr13.0
Debora Crescenzo 1 year ago committed by Nouhaila Idrissi-Zouggari
parent 668e23dfab
commit c78df757e1

@ -272,17 +272,17 @@ export function patchRemoveFull (options) {
}
export async function post (options) {
options = options || {}
options = _.merge({
let requestOptions = options || {}
requestOptions = _.merge({
headers: POST_HEADERS
}, options)
let path = options.path
if (options.resource !== undefined) {
path = 'api/' + options.resource + '/'
let path = requestOptions.path
if (requestOptions.resource !== undefined) {
path = 'api/' + requestOptions.resource + '/'
}
try {
const res = await httpApi.post(path, options.body, {
headers: options.headers
const res = await httpApi.post(path, requestOptions.body, {
headers: requestOptions.headers
})
const hasBody = res.data !== undefined && res.data !== null && res.data !== ''
if (hasBody) {

@ -41,6 +41,7 @@
import CscCfGroupCondition from 'components/call-forwarding/CscCfGroupCondition'
import { mapActions, mapGetters } from 'vuex'
import { timeSetDateExact } from 'src/filters/time-set'
import { showGlobalError } from 'src/helpers/ui'
export default {
name: 'CscCfGroupConditionDate',
components: {
@ -101,27 +102,31 @@ export default {
]),
async createTimeSetEvent () {
const dateParts = this.selectedDate.split('/')
if (this.timeSet) {
await this.updateTimeSetDate({
mapping: this.mapping,
id: this.timeSet.id,
subscriberId: this.subscriberId,
date: {
date: dateParts[2],
month: dateParts[1],
year: dateParts[0]
}
})
} else {
await this.createTimeSetDate({
mapping: this.mapping,
subscriberId: this.subscriberId,
date: {
date: dateParts[2],
month: dateParts[1],
year: dateParts[0]
}
})
try {
if (this.timeSet) {
await this.updateTimeSetDate({
mapping: this.mapping,
id: this.timeSet.id,
subscriberId: this.subscriberId,
date: {
date: dateParts[2],
month: dateParts[1],
year: dateParts[0]
}
})
} else {
await this.createTimeSetDate({
mapping: this.mapping,
subscriberId: this.subscriberId,
date: {
date: dateParts[2],
month: dateParts[1],
year: dateParts[0]
}
})
}
} catch (err) {
showGlobalError(err?.message || this.$t('Unknown error'))
}
this.$emit('close')
},

@ -16,18 +16,14 @@ import {
cfUpdateTimeSetDateRange,
cfUpdateTimeSetWeekdays
} from 'src/api/call-forwarding'
import {
v4
} from 'uuid'
import { v4 } from 'uuid'
import {
patchReplace,
patchReplaceFull,
post, put, get, getList
} from 'src/api/common'
import _ from 'lodash'
import {
showGlobalError
} from 'src/helpers/ui'
import { showGlobalError } from 'src/helpers/ui'
const DEFAULT_RING_TIMEOUT = 60
const DEFAULT_PRIORITY = 0
@ -341,7 +337,7 @@ export async function createTimeSetDate ({ dispatch, commit, rootGetters, state
dispatch('wait/start', 'csc-cf-time-set-create', { root: true })
const timeSetId = await cfCreateTimeSetDate(rootGetters['user/getSubscriberId'], payload.date)
const updatedMapping = _.cloneDeep(state.mappings[payload.mapping.type])
updatedMapping[payload.mapping.index].timeset_id = timeSetId
updatedMapping[payload.mapping.index].timeset_id = timeSetId.id
const updatedMappings = await patchReplaceFull({
resource: 'cfmappings',
resourceId: (payload.subscriberId) ? payload.subscriberId : rootGetters['user/getSubscriberId'],
@ -432,7 +428,7 @@ export async function createTimeSetDateRange ({ dispatch, commit, rootGetters, s
dispatch('wait/start', 'csc-cf-time-set-create', { root: true })
const timeSetId = await cfCreateTimeSetDateRange(rootGetters['user/getSubscriberId'], payload.date)
const updatedMapping = _.cloneDeep(state.mappings[payload.mapping.type])
updatedMapping[payload.mapping.index].timeset_id = timeSetId
updatedMapping[payload.mapping.index].timeset_id = timeSetId.id
const updatedMappings = await patchReplaceFull({
resource: 'cfmappings',
resourceId: (payload.subscriberId) ? payload.subscriberId : rootGetters['user/getSubscriberId'],
@ -461,7 +457,7 @@ export async function createTimeSetWeekdays ({ dispatch, commit, rootGetters, st
dispatch('wait/start', 'csc-cf-time-set-create', { root: true })
const timeSetId = await cfCreateTimeSetWeekdays(rootGetters['user/getSubscriberId'], payload.weekdays)
const updatedMapping = _.cloneDeep(state.mappings[payload.mapping.type])
updatedMapping[payload.mapping.index].timeset_id = timeSetId
updatedMapping[payload.mapping.index].timeset_id = timeSetId.id
const updatedMappings = await patchReplaceFull({
resource: 'cfmappings',
resourceId: (payload.subscriberId) ? payload.subscriberId : rootGetters['user/getSubscriberId'],
@ -490,7 +486,7 @@ export async function createOfficeHours ({ dispatch, commit, rootGetters, state
dispatch('wait/start', 'csc-cf-time-set-create', { root: true })
const timeSetId = await cfCreateOfficeHours(rootGetters['user/getSubscriberId'], payload.times)
const updatedMapping = _.cloneDeep(state.mappings[payload.mapping.type])
updatedMapping[payload.mapping.index].timeset_id = timeSetId
updatedMapping[payload.mapping.index].timeset_id = timeSetId.id
const updatedMappings = await patchReplaceFull({
resource: 'cfmappings',
resourceId: (payload.subscriberId) ? payload.subscriberId : rootGetters['user/getSubscriberId'],

Loading…
Cancel
Save