TT#28056 List all company hours destinations

What has been done:
- TT#31193, CallForwarding: Create store mutation unit test
- TT#31191, CallForwarding: Implement API requests
- TT#31192, CallForwarding: Implement store
- TT#31175, CallForwarding: Implement vue component

Change-Id: I971e06cea0b930f57ede43b7a56c6766a790e651
changes/40/18640/9
raxelsen 7 years ago
parent 3463789805
commit cefb66b549

@ -84,31 +84,37 @@ export function getDestinationsets(id) {
}); });
} }
export function loadAlwaysEverybodyDestinations(subscriberId) { export function loadAlwaysDestinations(options) {
return new Promise((resolve, reject)=>{ return new Promise((resolve, reject)=>{
let cfuTimeset = null;
let cfnaTimeset = null;
let cfbTimeset = null;
Promise.resolve().then(()=>{ Promise.resolve().then(()=>{
return getMappings(subscriberId); return getMappings(options.subscriberId);
}).then((mappings) => { }).then((mappings)=>{
let cfuPromises = []; let cfuPromises = [];
let cfnaPromises = []; let cfnaPromises = [];
let cfbPromises = []; let cfbPromises = [];
if(_.has(mappings, 'cfu') && _.isArray(mappings.cfu) && mappings.cfu.length > 0) { if(_.has(mappings, 'cfu') && _.isArray(mappings.cfu) && mappings.cfu.length > 0) {
mappings.cfu.forEach((cfuMapping)=>{ mappings.cfu.forEach((cfuMapping)=>{
if (cfuMapping.timeset_id === null && cfuMapping.sourceset_id === null) { if (cfuMapping.timeset === options.timeset && cfuMapping.sourceset_id === null) {
cfuTimeset = cfuMapping.timeset_id;
cfuPromises.push(getDestinationsetById(cfuMapping.destinationset_id)); cfuPromises.push(getDestinationsetById(cfuMapping.destinationset_id));
} }
}); });
} }
if(_.has(mappings, 'cfna') && _.isArray(mappings.cfna) && mappings.cfna.length > 0) { if(_.has(mappings, 'cfna') && _.isArray(mappings.cfna) && mappings.cfna.length > 0) {
mappings.cfna.forEach((cfnaMapping)=>{ mappings.cfna.forEach((cfnaMapping)=>{
if (cfnaMapping.timeset_id === null && cfnaMapping.sourceset_id === null) { if (cfnaMapping.timeset === options.timeset && cfnaMapping.sourceset_id === null) {
cfnaTimeset = cfnaMapping.timeset_id;
cfnaPromises.push(getDestinationsetById(cfnaMapping.destinationset_id)); cfnaPromises.push(getDestinationsetById(cfnaMapping.destinationset_id));
} }
}); });
} }
if(_.has(mappings, 'cfb') && _.isArray(mappings.cfb) && mappings.cfb.length > 0) { if(_.has(mappings, 'cfb') && _.isArray(mappings.cfb) && mappings.cfb.length > 0) {
mappings.cfb.forEach((cfbMapping)=>{ mappings.cfb.forEach((cfbMapping)=>{
if (cfbMapping.timeset_id === null && cfbMapping.sourceset_id === null) { if (cfbMapping.timeset === options.timeset && cfbMapping.sourceset_id === null) {
cfbTimeset = cfbMapping.timeset_id;
cfbPromises.push(getDestinationsetById(cfbMapping.destinationset_id)); cfbPromises.push(getDestinationsetById(cfbMapping.destinationset_id));
} }
}); });
@ -119,9 +125,9 @@ export function loadAlwaysEverybodyDestinations(subscriberId) {
Promise.all(cfbPromises) Promise.all(cfbPromises)
]); ]);
}).then((res)=>{ }).then((res)=>{
addGroupNames(res[0], 'cfu'); addGroupNamesAndTimeset({ group: res[0], groupName: 'cfu', timesetId: cfuTimeset });
addGroupNames(res[1], 'cfna'); addGroupNamesAndTimeset({ group: res[1], groupName: 'cfna', timesetId: cfnaTimeset });
addGroupNames(res[2], 'cfb'); addGroupNamesAndTimeset({ group: res[2], groupName: 'cfb', timesetId: cfbTimeset });
resolve({ resolve({
online: res[0], online: res[0],
offline: res[1], offline: res[1],
@ -133,11 +139,12 @@ export function loadAlwaysEverybodyDestinations(subscriberId) {
}); });
} }
export function addGroupNames(group, groupName) { export function addGroupNamesAndTimeset(options) {
group.forEach(destinationset => { options.group.forEach(destinationset => {
destinationset.groupName = groupName; destinationset.groupName = options.groupName;
destinationset.timesetId = options.timesetId;
}); });
return group; return options.group;
} }
export function getDestinationsetById(id) { export function getDestinationsetById(id) {
@ -247,18 +254,17 @@ export function addDestinationToEmptyGroup(options) {
return addDestinationToDestinationset({ return addDestinationToDestinationset({
id: id, data: [options.data] id: id, data: [options.data]
}); });
//}).then(() => {
// return getMappings(subscriberId);
//}).then((mappings) => {
// return addNewMapping({
// destinationsetId: destinationsetId,
// group: options.groupName,
// subscriberId: options.subscriberId,
// mappings: mappings
// });
}).then(() => { }).then(() => {
return getMappings(options.subscriberId);
}).then((mappings) => {
let updatedMappings = mappings[options.groupName];
updatedMappings.push({
destinationset_id: destinationsetId,
sourceset_id: null,
timeset_id: options.timesetId
});
return addNewMapping({ return addNewMapping({
destinationsetId: destinationsetId, mappings: updatedMappings,
group: options.groupName, group: options.groupName,
subscriberId: options.subscriberId subscriberId: options.subscriberId
}); });
@ -271,19 +277,12 @@ export function addDestinationToEmptyGroup(options) {
} }
export function addNewMapping(options) { export function addNewMapping(options) {
let headers = { let headers = { 'Content-Type': 'application/json-patch+json' };
'Content-Type': 'application/json-patch+json'
};
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
let mappingsToSend = [{
destinationset_id: options.destinationsetId,
sourceset_id: null,
timeset_id: null
}];
Vue.http.patch('/api/cfmappings/' + options.subscriberId, [{ Vue.http.patch('/api/cfmappings/' + options.subscriberId, [{
op: 'replace', op: 'replace',
path: '/' + options.group, path: '/' + options.group,
value: mappingsToSend value: options.mappings
}], { headers: headers }).then(result => { }], { headers: headers }).then(result => {
resolve(result); resolve(result);
}).catch(err => { }).catch(err => {

@ -4,16 +4,19 @@
<csc-destinations :title="$t('pages.callForward.whenOnline')" <csc-destinations :title="$t('pages.callForward.whenOnline')"
:group="destinations.online" :group="destinations.online"
group-name="cfu" group-name="cfu"
timeset="null"
icon="signal_wifi_4_bar"> icon="signal_wifi_4_bar">
</csc-destinations> </csc-destinations>
<csc-destinations :title="$t('pages.callForward.whenBusy')" <csc-destinations :title="$t('pages.callForward.whenBusy')"
:group="destinations.busy" :group="destinations.busy"
group-name="cfb" group-name="cfb"
timeset="null"
icon="record_voice_over"> icon="record_voice_over">
</csc-destinations> </csc-destinations>
<csc-destinations :title="$t('pages.callForward.whenOffline')" <csc-destinations :title="$t('pages.callForward.whenOffline')"
:group="destinations.offline" :group="destinations.offline"
group-name="cfna" group-name="cfna"
timeset="null"
icon="signal_wifi_off"> icon="signal_wifi_off">
</csc-destinations> </csc-destinations>
</q-card> </q-card>
@ -21,11 +24,15 @@
</template> </template>
<script> <script>
import numberFormat from '../../../filters/number-format'
import { mapState } from 'vuex'
import { startLoading, stopLoading,
showGlobalError, showToast } from '../../../helpers/ui'
import CscPage from '../../CscPage' import CscPage from '../../CscPage'
import CscDestinations from './CscDestinations' import CscDestinations from './CscDestinations'
import { QCard } from 'quasar-framework' import { QCard } from 'quasar-framework'
export default { export default {
mounted() { created() {
this.$store.dispatch('callForward/loadAlwaysEverybodyDestinations'); this.$store.dispatch('callForward/loadAlwaysEverybodyDestinations');
}, },
data () { data () {
@ -38,8 +45,58 @@
CscDestinations CscDestinations
}, },
computed: { computed: {
destinations() { ...mapState('callForward', {
return this.$store.state.callForward.alwaysEverybodyDestinations; removeDestinationState: 'removeDestinationState',
addDestinationState: 'addDestinationState',
changeDestinationState: 'changeDestinationState',
destinations: 'alwaysEverybodyDestinations',
lastRemovedDestination: 'lastRemovedDestination',
lastAddedDestination: 'lastAddedDestination',
addDestinationError(state) {
return state.addDestinationError ||
this.$t('pages.callForward.addErrorMessage');
}
})
},
watch: {
removeDestinationState(state) {
if (state === 'requesting') {
startLoading();
} else if (state === 'failed') {
stopLoading();
showGlobalError(this.removeDestinationError);
} else if (state === 'succeeded') {
stopLoading();
showToast(this.$t('pages.callForward.removeSuccessMessage', {
destination: this.lastRemovedDestination
}));
this.$store.dispatch('callForward/loadAlwaysEverybodyDestinations');
}
},
addDestinationState(state) {
if (state === 'requesting') {
startLoading();
} else if (state === 'failed') {
stopLoading();
showGlobalError(this.addDestinationError);
} else if (state === 'succeeded') {
stopLoading();
showToast(this.$t('pages.callForward.addDestinationSuccessMessage', {
destination: this.lastAddedDestination
}));
this.$store.dispatch('callForward/loadAlwaysEverybodyDestinations');
}
},
changeDestinationState(state) {
if (state === 'requesting') {
startLoading();
} else if (state === 'failed') {
stopLoading();
showGlobalError(this.changeDestinationError);
} else if (state === 'succeeded') {
stopLoading();
this.$store.dispatch('callForward/loadAlwaysEverybodyDestinations');
}
} }
} }
} }

@ -1,19 +1,106 @@
<template> <template>
<csc-page :title="$t('pages.callForward.titles.companyHours')"> <csc-page :title="$t('pages.callForward.titles.companyHours')">
<q-card class="dest-card">
<csc-destinations :title="$t('pages.callForward.whenOnline')"
:group="destinations.online"
group-name="cfu"
timeset="Company Hours"
icon="signal_wifi_4_bar">
</csc-destinations>
<csc-destinations :title="$t('pages.callForward.whenBusy')"
:group="destinations.busy"
group-name="cfb"
timeset="Company Hours"
icon="record_voice_over">
</csc-destinations>
<csc-destinations :title="$t('pages.callForward.whenOffline')"
:group="destinations.offline"
group-name="cfna"
timeset="Company Hours"
icon="signal_wifi_off">
</csc-destinations>
</q-card>
</csc-page> </csc-page>
</template> </template>
<script> <script>
import numberFormat from '../../../filters/number-format'
import { mapState } from 'vuex'
import { startLoading, stopLoading,
showGlobalError, showToast } from '../../../helpers/ui'
import CscPage from '../../CscPage' import CscPage from '../../CscPage'
import CscDestinations from './CscDestinations'
import { QCard } from 'quasar-framework'
export default { export default {
created() {
this.$store.dispatch('callForward/loadCompanyHoursEverybodyDestinations');
},
data () { data () {
return {} return {
}
}, },
components: { components: {
CscPage QCard,
CscPage,
CscDestinations
},
computed: {
...mapState('callForward', {
removeDestinationState: 'removeDestinationState',
addDestinationState: 'addDestinationState',
changeDestinationState: 'changeDestinationState',
destinations: 'companyHoursEverybodyDestinations',
lastRemovedDestination: 'lastRemovedDestination',
lastAddedDestination: 'lastAddedDestination',
addDestinationError(state) {
return state.addDestinationError ||
this.$t('pages.callForward.addErrorMessage');
}
})
},
watch: {
removeDestinationState(state) {
if (state === 'requesting') {
startLoading();
} else if (state === 'failed') {
stopLoading();
showGlobalError(this.removeDestinationError);
} else if (state === 'succeeded') {
stopLoading();
showToast(this.$t('pages.callForward.removeSuccessMessage', {
destination: this.lastRemovedDestination
}));
this.$store.dispatch('callForward/loadCompanyHoursEverybodyDestinations');
}
},
addDestinationState(state) {
if (state === 'requesting') {
startLoading();
} else if (state === 'failed') {
stopLoading();
showGlobalError(this.addDestinationError);
} else if (state === 'succeeded') {
stopLoading();
showToast(this.$t('pages.callForward.addDestinationSuccessMessage', {
destination: this.lastAddedDestination
}));
this.$store.dispatch('callForward/loadCompanyHoursEverybodyDestinations');
}
},
changeDestinationState(state) {
if (state === 'requesting') {
startLoading();
} else if (state === 'failed') {
stopLoading();
showGlobalError(this.changeDestinationError);
} else if (state === 'succeeded') {
stopLoading();
this.$store.dispatch('callForward/loadCompanyHoursEverybodyDestinations');
}
}
} }
} }
</script> </script>
<style> <style lang="stylus">
</style> </style>

@ -54,7 +54,9 @@
'destinations', 'destinations',
'id', 'id',
'groupName', 'groupName',
'priority' 'priority',
'timeset',
'timesetId'
], ],
data () { data () {
return { return {
@ -81,9 +83,7 @@
...mapState('callForward', [ ...mapState('callForward', [
'activeForm', 'activeForm',
'formType', 'formType',
'addDestinationState', 'addDestinationState'
'addDestinationError',
'lastAddedDestination'
]), ]),
...mapGetters('callForward', [ ...mapGetters('callForward', [
'hasFaxCapability' 'hasFaxCapability'
@ -97,9 +97,6 @@
addDestinationIsRequesting() { addDestinationIsRequesting() {
return this.addDestinationState === 'requesting'; return this.addDestinationState === 'requesting';
}, },
addDestinationError() {
return this.$store.state.callForward.addDestinationError || this.$t('pages.callForward.addErrorMessage');
},
beforeIconTimeout() { beforeIconTimeout() {
return [{ return [{
icon: 'schedule' icon: 'schedule'
@ -113,17 +110,8 @@
}, },
watch: { watch: {
addDestinationState(state) { addDestinationState(state) {
if (state === 'failed') { if (state === 'succeeded') {
stopLoading();
showGlobalError(this.addDestinationError);
} else if (state === 'succeeded') {
stopLoading();
showToast(this.$t('pages.callForward.addDestinationSuccessMessage', {
destination: this.lastAddedDestination
}));
this.disableForm(); this.disableForm();
} else if (state === 'button') {
stopLoading();
} }
} }
}, },
@ -155,7 +143,9 @@
startLoading(); startLoading();
this.$store.dispatch('callForward/addDestination', { this.$store.dispatch('callForward/addDestination', {
form: this.destinationForm, form: this.destinationForm,
destinations: this.destinations destinations: this.destinations,
timeset: this.timeset,
timesetId: this.timesetId
}); });
} }
} }

@ -119,9 +119,10 @@
}, },
deleteDestination(index) { deleteDestination(index) {
let clonedDestinations = _.cloneDeep(this.destinations); let clonedDestinations = _.cloneDeep(this.destinations);
let clonedDestination = clonedDestinations[index].destination;
let indexInt = parseInt(index); let indexInt = parseInt(index);
let store = this.$store; let store = this.$store;
let removeDestination = numberFormat(this.destinations[index].destination); let removeDestination = numberFormat(clonedDestination);
let self = this; let self = this;
let isLastDestination = this.destinations.length === 1; let isLastDestination = this.destinations.length === 1;
clonedDestinations.splice(indexInt, 1); clonedDestinations.splice(indexInt, 1);
@ -139,14 +140,9 @@
store.dispatch('callForward/deleteDestinationFromDestinationset', { store.dispatch('callForward/deleteDestinationFromDestinationset', {
id: self.id, id: self.id,
data: clonedDestinations, data: clonedDestinations,
deleteDestinationset: isLastDestination }).then((result) => { deleteDestinationset: isLastDestination,
store.dispatch('callForward/loadAlwaysEverybodyDestinations'); removeDestination: removeDestination
showToast(self.$t('pages.callForward.removeSuccessMessage', { })
destination: removeDestination
}));
}).catch((err) => {
showToast(self.$t('pages.callForward.removeErrorMessage'));
});
} }
} }
] ]

@ -39,7 +39,8 @@
'title', 'title',
'icon', 'icon',
'group', 'group',
'groupName' 'groupName',
'timeset'
], ],
components: { components: {
QCardTitle, QCardTitle,
@ -54,6 +55,8 @@
lastDestinationset() { lastDestinationset() {
let destinationset = _.findLast(this.group) || {}; let destinationset = _.findLast(this.group) || {};
destinationset.groupName = this.groupName; destinationset.groupName = this.groupName;
destinationset.priority = destinationset.lowestPriority || 1;
destinationset.timeset = this.timeset;
return destinationset; return destinationset;
} }
}, },

@ -3,7 +3,7 @@
import _ from 'lodash'; import { getSourcesets, getDestinationsets, import _ from 'lodash'; import { getSourcesets, getDestinationsets,
getTimesets, getTimesets,
getMappings, getMappings,
loadAlwaysEverybodyDestinations, loadAlwaysDestinations,
deleteDestinationFromDestinationset, deleteDestinationFromDestinationset,
addDestinationToDestinationset, addDestinationToDestinationset,
addDestinationToEmptyGroup, addDestinationToEmptyGroup,
@ -12,14 +12,7 @@ import _ from 'lodash'; import { getSourcesets, getDestinationsets,
moveDestinationUp, moveDestinationUp,
moveDestinationDown } from '../api/call-forward'; moveDestinationDown } from '../api/call-forward';
const AddDestinationState = { const DestinationState = {
button: 'button',
requesting: 'requesting',
succeeded: 'succeeded',
failed: 'failed'
};
const ChangeDestinationState = {
button: 'button', button: 'button',
requesting: 'requesting', requesting: 'requesting',
succeeded: 'succeeded', succeeded: 'succeeded',
@ -34,13 +27,22 @@ export default {
timesets: null, timesets: null,
destinationsets: null, destinationsets: null,
alwaysEverybodyDestinations: { alwaysEverybodyDestinations: {
online: [{}], online: [],
busy: [{}], busy: [],
offline: [{}] offline: []
}, },
addDestinationState: AddDestinationState.button, companyHoursEverybodyDestinations: {
online: [],
busy: [],
offline: []
},
removeDestinationState: DestinationState.button,
removeDestinationError: null,
lastRemovedDestination: null,
addDestinationState: DestinationState.button,
addDestinationError: null, addDestinationError: null,
changeDestinationState: ChangeDestinationState.button, lastAddedDestination: null,
changeDestinationState: DestinationState.button,
changeDestinationError: null, changeDestinationError: null,
activeForm: '', activeForm: '',
formType: '', formType: '',
@ -51,8 +53,7 @@ export default {
destination: '', destination: '',
priority: 1, priority: 1,
timeout: '' timeout: ''
}, }
lastAddedDestination: null
}, },
getters: { getters: {
hasFaxCapability(state, getters, rootState, rootGetters) { hasFaxCapability(state, getters, rootState, rootGetters) {
@ -72,6 +73,17 @@ export default {
}, },
getDestinationsetId(state) { getDestinationsetId(state) {
return state.destinationsetId; return state.destinationsetId;
},
getCompanyHoursId(state) {
let timeset;
for (let group in state.companyHoursEverybodyDestinations) {
if (!timeset) {
timeset = _.find(state.companyHoursEverybodyDestinations[group], (o) => {
return o.timesetId > 0;
});
};
};
return timeset ? timeset.timesetId : null;
} }
}, },
mutations: { mutations: {
@ -90,6 +102,9 @@ export default {
loadAlwaysEverybodyDestinations(state, result) { loadAlwaysEverybodyDestinations(state, result) {
state.alwaysEverybodyDestinations = result; state.alwaysEverybodyDestinations = result;
}, },
loadCompanyHoursEverybodyDestinations(state, result) {
state.companyHoursEverybodyDestinations = result;
},
setActiveForm(state, value) { setActiveForm(state, value) {
state.activeForm = value; state.activeForm = value;
}, },
@ -121,31 +136,48 @@ export default {
state.formType = ''; state.formType = '';
state.destinationsetId = ''; state.destinationsetId = '';
state.groupName = ''; state.groupName = '';
state.addDestinationState = AddDestinationState.button; state.addDestinationState = DestinationState.button;
state.changeDestinationState = DestinationState.button;
state.removeDestinationState = DestinationState.button;
}, },
addDestinationRequesting(state) { addDestinationRequesting(state) {
state.addDestinationState = AddDestinationState.requesting; state.addDestinationState = DestinationState.requesting;
state.addDestinationError = null; state.addDestinationError = null;
}, },
addDestinationSucceeded(state) { addDestinationSucceeded(state) {
state.addDestinationState = AddDestinationState.succeeded; state.addDestinationState = DestinationState.succeeded;
state.addDestinationError = null; state.addDestinationError = null;
}, },
addDestinationFailed(state, error) { addDestinationFailed(state, error) {
state.addDestinationState = AddDestinationState.failed; state.addDestinationState = DestinationState.failed;
state.addDestinationError = error; state.addDestinationError = error;
}, },
changeDestinationRequesting(state) { changeDestinationRequesting(state) {
state.changeDestinationState = ChangeDestinationState.requesting; state.changeDestinationState = DestinationState.requesting;
state.changeDestinationError = null; state.changeDestinationError = null;
}, },
changeDestinationSucceeded(state) { changeDestinationSucceeded(state) {
state.changeDestinationState = ChangeDestinationState.succeeded; state.changeDestinationState = DestinationState.succeeded;
state.changeDestinationError = null; state.changeDestinationError = null;
}, },
changeDestinationFailed(state, error) { changeDestinationFailed(state, error) {
state.changeDestinationState = ChangeDestinationState.failed; state.changeDestinationState = DestinationState.failed;
state.changeDestinationError = error; state.changeDestinationError = error;
},
removeDestinationRequesting(state) {
state.removeDestinationState = DestinationState.requesting;
state.removeDestinationError = null;
},
removeDestinationSucceeded(state) {
state.removeDestinationState = DestinationState.succeeded;
state.removeDestinationError = null;
},
removeDestinationFailed(state, error) {
state.removeDestinationState = DestinationState.failed;
state.removeDestinationError = error;
},
setLastRemovedDestination(state, value) {
state.lastRemovedDestination = value;
} }
}, },
actions: { actions: {
@ -191,18 +223,34 @@ export default {
}, },
loadAlwaysEverybodyDestinations(context) { loadAlwaysEverybodyDestinations(context) {
return new Promise((resolve, reject)=>{ return new Promise((resolve, reject)=>{
loadAlwaysEverybodyDestinations(localStorage.getItem('subscriberId')).then((result)=>{ loadAlwaysDestinations({
subscriberId: localStorage.getItem('subscriberId'),
timeset: null
}).then((result)=>{
context.commit('loadAlwaysEverybodyDestinations', result); context.commit('loadAlwaysEverybodyDestinations', result);
}) })
}); });
}, },
loadCompanyHoursEverybodyDestinations(context) {
return new Promise((resolve, reject)=>{
loadAlwaysDestinations({
subscriberId: localStorage.getItem('subscriberId'),
timeset: 'Company Hours'
}).then((result)=>{
context.commit('loadCompanyHoursEverybodyDestinations', result);
})
});
},
deleteDestinationFromDestinationset(context, options) { deleteDestinationFromDestinationset(context, options) {
let removedDestination = options.removeDestination;
context.commit('removeDestinationRequesting');
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
deleteDestinationFromDestinationset(options) deleteDestinationFromDestinationset(options)
.then((result) => { .then(() => {
resolve(result); context.commit('setLastRemovedDestination', removedDestination);
context.commit('removeDestinationSucceeded');
}).catch((err) => { }).catch((err) => {
reject(err); context.commit('removeDestinationFailed', err.message);
}); });
}); });
}, },
@ -220,6 +268,12 @@ export default {
let form = _.clone(context.getters.getForm); let form = _.clone(context.getters.getForm);
let updatedOptions; let updatedOptions;
let type = context.getters.getFormType; let type = context.getters.getFormType;
let timeset = null;
if (options.timeset === 'Company Hours') {
timeset = context.getters.getCompanyHoursId;
} else if (options.timeset === 'After Hours') {
timeset = context.getters.getAfterHoursId;
};
context.commit('addDestinationRequesting'); context.commit('addDestinationRequesting');
if (type !== 'number') { if (type !== 'number') {
delete form.timeout; delete form.timeout;
@ -232,14 +286,14 @@ export default {
subscriberId: context.getters.getSubscriberId, subscriberId: context.getters.getSubscriberId,
data: form, data: form,
groupName: context.getters.getGroupName, groupName: context.getters.getGroupName,
id: context.getters.getDestinationsetId id: context.getters.getDestinationsetId,
timesetId: timeset
}; };
if (options.destinations) { if (options.destinations) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
addDestinationToExistingGroup(updatedOptions).then(() => { addDestinationToExistingGroup(updatedOptions).then(() => {
context.commit('setLastAddedDestination', options.form.destination); context.commit('setLastAddedDestination', options.form.destination);
context.commit('addDestinationSucceeded'); context.commit('addDestinationSucceeded');
context.dispatch('loadAlwaysEverybodyDestinations');
}).catch((err) => { }).catch((err) => {
context.commit('addDestinationFailed', err.message); context.commit('addDestinationFailed', err.message);
}); });
@ -247,8 +301,8 @@ export default {
} else { } else {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
addDestinationToEmptyGroup(updatedOptions).then((result) => { addDestinationToEmptyGroup(updatedOptions).then((result) => {
context.commit('setLastAddedDestination', options.form.destination);
context.commit('addDestinationSucceeded'); context.commit('addDestinationSucceeded');
context.dispatch('loadAlwaysEverybodyDestinations');
}).catch((err) => { }).catch((err) => {
context.commit('addDestinationFailed', err.message); context.commit('addDestinationFailed', err.message);
}); });
@ -269,7 +323,6 @@ export default {
destination: clonedDestination destination: clonedDestination
}).then(() => { }).then(() => {
context.commit('changeDestinationSucceeded'); context.commit('changeDestinationSucceeded');
context.dispatch('loadAlwaysEverybodyDestinations');
}).catch((err) => { }).catch((err) => {
context.commit('changeDestinationFailed', err.message); context.commit('changeDestinationFailed', err.message);
}); });
@ -282,7 +335,6 @@ export default {
destination: clonedDestination destination: clonedDestination
}).then(() => { }).then(() => {
context.commit('changeDestinationSucceeded'); context.commit('changeDestinationSucceeded');
context.dispatch('loadAlwaysEverybodyDestinations');
}).catch((err) => { }).catch((err) => {
context.commit('changeDestinationFailed', err.message); context.commit('changeDestinationFailed', err.message);
}); });
@ -306,7 +358,6 @@ export default {
subscriberId: context.getters.getSubscriberId subscriberId: context.getters.getSubscriberId
}).then(() => { }).then(() => {
context.commit('changeDestinationSucceeded'); context.commit('changeDestinationSucceeded');
context.dispatch('loadAlwaysEverybodyDestinations');
}).catch((err) => { }).catch((err) => {
context.commit('changeDestinationFailed', err.message); context.commit('changeDestinationFailed', err.message);
}); });

@ -50,6 +50,36 @@ describe('CallForward', function(){
}; };
CallForwardModule.mutations.resetFormState(state); CallForwardModule.mutations.resetFormState(state);
assert.deepEqual(state.form, data); assert.deepEqual(state.form, data);
it('should load always company hours destinations', function(){
let state = {
alwaysCompanyHoursDestinations: [
]
};
let data = {
busy: [],
offline: [{
destinations: [{
"announcement_id": null,
"destination": "sip:3333@192.168.178.23",
"priority": 1,
"simple_destination": "3333",
"timeout": 60
},
{
"announcement_id": null,
"destination": "sip:2222@192.168.178.23",
"priority": 1,
"simple_destination": "2222",
"timeout": 300
}],
id: 3,
name: "csc_destinationset_1"
}],
online: []
};
CallForwardModule.mutations.loadAlwaysCompanyHoursDestinations(state, data);
assert.deepEqual(state.alwaysCompanyHoursDestinations, data);
}); });
}); });

Loading…
Cancel
Save