diff --git a/src/api/call-forward.js b/src/api/call-forward.js index 503029ef..18a0b202 100644 --- a/src/api/call-forward.js +++ b/src/api/call-forward.js @@ -107,7 +107,8 @@ export function loadDestinations(options) { sourcesets.map((sourceset) => { sourcesetsCollection.push({ id: sourceset.id, - name: sourceset.name + name: sourceset.name, + mode: sourceset.mode }) }); sourcesetsCollection.forEach((sourceset) => { @@ -116,7 +117,8 @@ export function loadDestinations(options) { timeset: options.timeset, sourceset_id: sourceset.id, sourceset_name: sourceset.name, - subscriberId: options.subscriberId + subscriberId: options.subscriberId, + sourceset_mode: sourceset.mode }) ) }); @@ -174,6 +176,7 @@ export function getDestinationsBySourcesetId(options) { resolve({ sourcesetId: options.sourceset_id, sourcesetName: options.sourceset_name, + sourcesetMode: options.sourceset_mode, destinationGroups: { online: result[0], offline: result[1], @@ -743,3 +746,20 @@ export function appendTimeToTimeset(options) { }); }); } + +export function createSourcesetWithSource(options) { + return new Promise((resolve, reject) => { + Vue.http.post('/api/cfsourcesets/', { + name: options.sourcesetName, + subscriber_id: options.subscriberId, + mode: options.mode, + sources: [{ + source: options.source + }] + }).then(() => { + resolve(); + }).catch(err => { + reject(err); + }); + }); +} diff --git a/src/components/pages/CallBlocking/CscCallBlocking.vue b/src/components/pages/CallBlocking/CscCallBlocking.vue index a1475543..c2c5ad8b 100644 --- a/src/components/pages/CallBlocking/CscCallBlocking.vue +++ b/src/components/pages/CallBlocking/CscCallBlocking.vue @@ -258,19 +258,19 @@ diff --git a/src/components/pages/CallForward/Always.vue b/src/components/pages/CallForward/Always.vue index 42456f6b..685cd6ea 100644 --- a/src/components/pages/CallForward/Always.vue +++ b/src/components/pages/CallForward/Always.vue @@ -1,7 +1,7 @@ @@ -10,6 +10,7 @@ import { startLoading, stopLoading, + showToast, showGlobalError } from '../../../helpers/ui' import CscPage from '../../CscPage' @@ -35,9 +36,12 @@ 'destinations', 'sourcesets', 'loadDestinationState', - 'loadDestinationError' + 'loadDestinationError', + 'addSourcesetState', + 'lastAddedSourceset' ]), ...mapGetters('callForward', [ + 'addSourcesetError', 'destinationsLoaded' ]), destinationsLoaded() { @@ -56,6 +60,26 @@ else if (state === 'succeeded') { stopLoading(); } + }, + addSourcesetState(state) { + if (state === 'requesting') { + startLoading(); + } + else if (state === 'failed') { + stopLoading(); + showGlobalError(this.addSourcesetError); + } + else if (state === 'succeeded') { + stopLoading(); + this.$refs.sourcesets.resetForm(); + showToast(this.$t('pages.callForward.sources.addSuccessMessage', { + sourceset: this.lastAddedSourceset + })); + this.$store.dispatch('callForward/loadDestinations', { + timeset: null + }); + this.$store.dispatch('callForward/loadSourcesets'); + } } } } diff --git a/src/components/pages/CallForward/CscAddTimeForm.vue b/src/components/pages/CallForward/CscAddTimeForm.vue index f70b0648..5f850c00 100644 --- a/src/components/pages/CallForward/CscAddTimeForm.vue +++ b/src/components/pages/CallForward/CscAddTimeForm.vue @@ -3,7 +3,7 @@ + :destinations="destinations" :timesetName="timesetName" ref="sourcesets" />
@@ -95,7 +95,8 @@ 'timesetExists', 'activeTimeForm', 'sourcesets', - 'loadDestinationState' + 'loadDestinationState', + 'addSourcesetState' ]), ...mapGetters('callForward', [ 'resetTimeError', @@ -103,7 +104,8 @@ 'showDefinedAlert', 'destinationsLoaded', 'showTimesAndDestinations', - 'loadDestinationError' + 'loadDestinationError', + 'addSourcesetError' ]), labelReset() { return this.$t('pages.callForward.times.resetTimeset', { @@ -208,6 +210,24 @@ else if (state === 'succeeded') { stopLoading(); } + }, + addSourcesetState(state) { + if (state === 'requesting') { + startLoading(); + } + else if (state === 'failed') { + stopLoading(); + showGlobalError(this.addSourcesetError); + } + else if (state === 'succeeded') { + stopLoading(); + this.$refs.sourcesets.resetForm(); + showToast(this.$t('pages.callForward.sources.addSuccessMessage', { + sourceset: this.lastAddedSourceset + })); + this.loadDestinations(); + this.loadSourcesets(); + } } } } diff --git a/src/components/pages/CallForward/CscSourcesets.vue b/src/components/pages/CallForward/CscSourcesets.vue index 4479b0c3..3f8ecdee 100644 --- a/src/components/pages/CallForward/CscSourcesets.vue +++ b/src/components/pages/CallForward/CscSourcesets.vue @@ -1,23 +1,25 @@