diff --git a/src/api/call-forward.js b/src/api/call-forward.js index 68aad04d..1fbe93d1 100644 --- a/src/api/call-forward.js +++ b/src/api/call-forward.js @@ -84,7 +84,7 @@ export function getDestinationsets(id) { }); } -export function loadAlwaysDestinations(options) { +export function loadEverybodyDestinations(options) { return new Promise((resolve, reject)=>{ let cfuTimeset = null; let cfnaTimeset = null; diff --git a/src/components/pages/CallForward/AfterHours.vue b/src/components/pages/CallForward/AfterHours.vue index 5b335c2c..b7705738 100644 --- a/src/components/pages/CallForward/AfterHours.vue +++ b/src/components/pages/CallForward/AfterHours.vue @@ -1,16 +1,29 @@ diff --git a/src/components/pages/CallForward/Always.vue b/src/components/pages/CallForward/Always.vue index 2325a689..e2f446ad 100644 --- a/src/components/pages/CallForward/Always.vue +++ b/src/components/pages/CallForward/Always.vue @@ -1,106 +1,32 @@ - diff --git a/src/components/pages/CallForward/CompanyHours.vue b/src/components/pages/CallForward/CompanyHours.vue index ff6e50b2..85d8bdea 100644 --- a/src/components/pages/CallForward/CompanyHours.vue +++ b/src/components/pages/CallForward/CompanyHours.vue @@ -1,106 +1,32 @@ - diff --git a/src/components/pages/CallForward/CscCallForward.vue b/src/components/pages/CallForward/CscCallForward.vue new file mode 100644 index 00000000..7009bca4 --- /dev/null +++ b/src/components/pages/CallForward/CscCallForward.vue @@ -0,0 +1,114 @@ + + + + + diff --git a/src/store/call-forward.js b/src/store/call-forward.js index 1c9bd289..79951dbf 100644 --- a/src/store/call-forward.js +++ b/src/store/call-forward.js @@ -3,7 +3,7 @@ import _ from 'lodash'; import { getSourcesets, getDestinationsets, getTimesets, getMappings, - loadAlwaysDestinations, + loadEverybodyDestinations, deleteDestinationFromDestinationset, addDestinationToDestinationset, addDestinationToEmptyGroup, @@ -36,6 +36,11 @@ export default { busy: [], offline: [] }, + afterHoursEverybodyDestinations: { + online: [], + busy: [], + offline: [] + }, removeDestinationState: DestinationState.button, removeDestinationError: null, lastRemovedDestination: null, @@ -84,6 +89,16 @@ export default { }; }; return timeset ? timeset.timesetId : null; + }, + getAfterHoursId(state) { + let timeset; + for (let group in state.afterHoursEverybodyDestinations) { if (!timeset) { + timeset = _.find(state.afterHoursEverybodyDestinations[group], (o) => { + return o.timesetId > 0; + }); + }; + }; + return timeset ? timeset.timesetId : null; } }, mutations: { @@ -105,6 +120,9 @@ export default { loadCompanyHoursEverybodyDestinations(state, result) { state.companyHoursEverybodyDestinations = result; }, + loadAfterHoursEverybodyDestinations(state, result) { + state.afterHoursEverybodyDestinations = result; + }, setActiveForm(state, value) { state.activeForm = value; }, @@ -123,6 +141,9 @@ export default { setLastAddedDestination(state, value) { state.lastAddedDestination = value; }, + setLastRemovedDestination(state, value) { + state.lastRemovedDestination = value; + }, resetFormState(state) { state.form = { announcement_id: null, @@ -175,9 +196,6 @@ export default { removeDestinationFailed(state, error) { state.removeDestinationState = DestinationState.failed; state.removeDestinationError = error; - }, - setLastRemovedDestination(state, value) { - state.lastRemovedDestination = value; } }, actions: { @@ -223,7 +241,7 @@ export default { }, loadAlwaysEverybodyDestinations(context) { return new Promise((resolve, reject)=>{ - loadAlwaysDestinations({ + loadEverybodyDestinations({ subscriberId: localStorage.getItem('subscriberId'), timeset: null }).then((result)=>{ @@ -233,7 +251,7 @@ export default { }, loadCompanyHoursEverybodyDestinations(context) { return new Promise((resolve, reject)=>{ - loadAlwaysDestinations({ + loadEverybodyDestinations({ subscriberId: localStorage.getItem('subscriberId'), timeset: 'Company Hours' }).then((result)=>{ @@ -241,6 +259,16 @@ export default { }) }); }, + loadAfterHoursEverybodyDestinations(context) { + return new Promise((resolve, reject)=>{ + loadEverybodyDestinations({ + subscriberId: localStorage.getItem('subscriberId'), + timeset: 'After Hours' + }).then((result)=>{ + context.commit('loadAfterHoursEverybodyDestinations', result); + }) + }); + }, deleteDestinationFromDestinationset(context, options) { let removedDestination = options.removeDestination; context.commit('removeDestinationRequesting'); diff --git a/t/store/call-forward.js b/t/store/call-forward.js index 1a4d1e8d..c8f1e6c3 100644 --- a/t/store/call-forward.js +++ b/t/store/call-forward.js @@ -51,9 +51,9 @@ describe('CallForward', function(){ CallForwardModule.mutations.resetFormState(state); assert.deepEqual(state.form, data); - it('should load always company hours destinations', function(){ + it('should load company hours everybody destinations', function(){ let state = { - alwaysCompanyHoursDestinations: [ + companyHoursEverybodyDestinations: [ ] }; let data = { @@ -78,8 +78,39 @@ describe('CallForward', function(){ }], online: [] }; - CallForwardModule.mutations.loadAlwaysCompanyHoursDestinations(state, data); - assert.deepEqual(state.alwaysCompanyHoursDestinations, data); + CallForwardModule.mutations.loadCompanyHoursEverybodyDestinations(state, data); + assert.deepEqual(state.companyHoursEverybodyDestinations, data); + }); + + it('should load after hours everybody destinations', function(){ + let state = { + afterHoursEverybodyDestinations: [ + ] + }; + 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.loadAfterHoursEverybodyDestinations(state, data); + assert.deepEqual(state.afterHoursEverybodyDestinations, data); }); });