From 4f6f3f2f23d3aa85005d436d4b73cca1445ddb83 Mon Sep 17 00:00:00 2001 From: Carlo Venusino Date: Mon, 25 May 2020 17:50:29 +0200 Subject: [PATCH] TT#81164 CF: As a Customer, I want to add new forwarding groups "If call from ..." MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ACs: √ Can click a new type of forwarding group under "Add forwarding" √ Can create a new group "If online and call from ..." √ Can delete an existing group √ Can add destinations as in other groups √ Can delete destinations √ Can edit destinations √ Can define a list of sources by clicking the highlighted part in the title "call from ..." √ Can see a popup after clicking "call from ..." √ Can input a name to identify the source list, add a first number and save it √ Can see the title "If online and call from nameOfTheSourceList" after saving the new source list initially √ Can see the popup with the source list after clicking the title again √ Can add numbers to that source list by clicking an add button in the popup √ Can delete numbers from the source list by clicking a delete button extra: √ Adding a sourceset to an unpersisted destinationset is prevented: √ Changed condition menu label Change-Id: Ifaa7b9cf5e8e5785bbfe2efd9ab7acaa0497cef5 --- .../NewCallForward/CscCallForwardGroup.vue | 32 +++++----- .../NewCallForward/CscNewCallForward.vue | 3 +- .../CscNewCallForwardAddSourcesetForm.vue | 43 ++++++------- .../CscNewCallForwardEditSources.vue | 62 ++++++++++++++++--- .../NewCallForward/CscNewCallForwardInput.vue | 6 ++ .../CscNewCallForwardSource.vue | 58 ++++++++--------- src/locales/en.json | 5 +- src/store/new-call-forward.js | 6 -- 8 files changed, 123 insertions(+), 92 deletions(-) diff --git a/src/components/pages/NewCallForward/CscCallForwardGroup.vue b/src/components/pages/NewCallForward/CscCallForwardGroup.vue index 63223fdd..523a9c32 100644 --- a/src/components/pages/NewCallForward/CscCallForwardGroup.vue +++ b/src/components/pages/NewCallForward/CscCallForwardGroup.vue @@ -14,19 +14,14 @@ - - - {{ $t('pages.newCallForward.conditionBtnLabel') }} - + {{ $t('pages.newCallForward.conditionBtnLabelPrefix') }} + + {{ $t('pages.newCallForward.conditionBtnLabel') }} + @@ -55,10 +50,11 @@ - {{ $t('pages.newCallForward.fromLabelShort') +'"'+ groupSourceset +'"'}} - + {{ $t('pages.newCallForward.conditionBtnLabelPrefix') }} + + {{ $t('pages.newCallForward.fromLabelShort') +'"'+ groupSourceset +'"'}} + @@ -228,7 +224,7 @@ const isGroupEnabled = await this.$store.dispatch('newCallForward/isGroupEnabled', {groupName: this.group.name, id: this.group.id}); this.isEnabled = isGroupEnabled; } - this.updateSourcesetNames() + await this.updateSourcesetNames() } catch(err){ console.log(err) @@ -236,6 +232,7 @@ }, computed: { ...mapGetters('newCallForward', [ + 'getGroupsLoaders', 'getOwnPhoneTimeout', 'groupsCount', 'getMappings', @@ -273,6 +270,9 @@ }, groupSourceset(){ return this.sourceSet ? this.sourceSet.name : false; + }, + isTempGroup(){ + return this.group.id.toString().includes('temp-'); } }, watch: { @@ -389,8 +389,6 @@ .csc-cf-destination-value text-align center .csc-cf-destination-add-condition - color $primary - cursor pointer font-size 16px .csc-cf-destination-add-destination padding-left 25px diff --git a/src/components/pages/NewCallForward/CscNewCallForward.vue b/src/components/pages/NewCallForward/CscNewCallForward.vue index 2c3d5e75..cdfedf9e 100644 --- a/src/components/pages/NewCallForward/CscNewCallForward.vue +++ b/src/components/pages/NewCallForward/CscNewCallForward.vue @@ -154,9 +154,10 @@ this.groupsLoading = true; try{ await this.$store.dispatch('newCallForward/loadMappings'); + await this.$store.dispatch('newCallForward/loadSourcesets'); await this.$store.dispatch('newCallForward/loadForwardGroups'); let unconditionalGroups = await this.$store.dispatch('newCallForward/getForwardGroupByName', 'unconditional'); - this.toggleDefaultNumber = !unconditionalGroups; //|| unconditionalGroup.destinations.length < 1; + this.toggleDefaultNumber = !unconditionalGroups; } catch(err){ console.log(err) diff --git a/src/components/pages/NewCallForward/CscNewCallForwardAddSourcesetForm.vue b/src/components/pages/NewCallForward/CscNewCallForwardAddSourcesetForm.vue index 1566ea20..6bbe42dc 100644 --- a/src/components/pages/NewCallForward/CscNewCallForwardAddSourcesetForm.vue +++ b/src/components/pages/NewCallForward/CscNewCallForwardAddSourcesetForm.vue @@ -76,7 +76,6 @@ }, data () { return { - mode: 'create', loading: false, enabled: false, number: '', @@ -109,32 +108,28 @@ let sourceSetId; const forwardGroupId = this.groupId; const forwardGroupName = this.groupName; - + if (this.numberError || this.nameError || this.saveDisabled) { showGlobalError(this.$t('validationErrors.generic')); + return; } - switch(this.mode){ - case 'create': - try{ - sourceSetId = await this.$store.dispatch('newCallForward/createSourceSet', { - name: this.name, - source: this.number - }); - await this.$store.dispatch('newCallForward/addSourcesetToGroup', { - name: forwardGroupName, - id: forwardGroupId, - sourceSetId: sourceSetId - }); - await this.$store.dispatch('newCallForward/loadForwardGroups'); - } - catch(err){ - console.log(err) - } - - - break; - case 'edit': - break; + try{ + await this.$store.dispatch('newCallForward/addGroupLoader', forwardGroupId); + sourceSetId = await this.$store.dispatch('newCallForward/createSourceSet', { + name: this.name, + source: this.number + }); + await this.$store.dispatch('newCallForward/addSourcesetToGroup', { + name: forwardGroupName, + id: forwardGroupId, + sourceSetId: sourceSetId + }); + await this.$store.dispatch('newCallForward/removeGroupLoader', forwardGroupId); + await this.$store.dispatch('newCallForward/loadForwardGroups'); + await this.$store.dispatch('newCallForward/loadSourcesets'); + } + catch(err){ + console.log(err) } }, cancel() { diff --git a/src/components/pages/NewCallForward/CscNewCallForwardEditSources.vue b/src/components/pages/NewCallForward/CscNewCallForwardEditSources.vue index 9bb3a86d..252e7030 100644 --- a/src/components/pages/NewCallForward/CscNewCallForwardEditSources.vue +++ b/src/components/pages/NewCallForward/CscNewCallForwardEditSources.vue @@ -3,8 +3,17 @@ v-if="enabled" class="csc-form" > +
+ +
+ {{ sourceSetName }} + +
+ +
@@ -12,6 +21,7 @@ :groupId="groupId" :groupName="groupName" :source="source.source" + :sourceSetId="sourceSetId" :sourceSetName="sourceSetName" />
@@ -20,9 +30,10 @@ class="csc-cf-row row" > @@ -43,7 +54,7 @@ flat color="primary" icon="done" - @click="save(); close()" + @click="save()" :disable="saveDisabled" > {{ $t('buttons.save') }} @@ -94,14 +105,15 @@ enabled: false, number: '', numberError: false, - destinationIndex: null + destinationIndex: null, + sources: [] } }, props: [ 'groupName', 'groupId', 'sourceSetName', - 'sources' + 'sourceSetId' ], validations: { number: { @@ -111,6 +123,7 @@ }, computed: { ...mapGetters('newCallForward', [ + 'destinationInCreation', 'getSourcesets', 'getSourcesesBySourcesetId' ]), @@ -118,16 +131,45 @@ return this.number.length < 1 || this.numberError || this.disable || this.loading; } }, + async mounted(){ + try{ + this.sources = await this.getSourcesesBySourcesetId(this.sourceSetId); + } + catch(err){ + console.log(err) + } + }, + watch:{ + getSourcesets: function(){ + this.sources = this.getSourcesesBySourcesetId(this.sourceSetId); + } + }, methods: { async save() { - //const forwardGroupId = this.groupId; - // const forwardGroupName = this.groupName; - //const forwardGroup = await this.$store.dispatch('newCallForward/getForwardGroupById', forwardGroupId); + const sources = this.sources; if (this.numberError || this.saveDisabled) { showGlobalError(this.$t('validationErrors.generic')); } - // TODO save source + sources.push({ + source: this.number + }); + try{ + await this.$store.dispatch('newCallForward/addGroupLoader', this.groupId); + this.$refs.sourceInputField.reset(); + await this.$store.dispatch('newCallForward/addSourceToSourceset', { + id: this.sourceSetId, + sources: sources + }); + await this.$store.dispatch('newCallForward/loadSourcesets'); + + } + catch(err){ + console.log(err) + } + finally { + await this.$store.dispatch('newCallForward/removeGroupLoader', this.groupId); + } }, cancel() { this.number = ''; @@ -152,4 +194,6 @@ diff --git a/src/components/pages/NewCallForward/CscNewCallForwardInput.vue b/src/components/pages/NewCallForward/CscNewCallForwardInput.vue index 0b8f7c22..2df2e3e5 100644 --- a/src/components/pages/NewCallForward/CscNewCallForwardInput.vue +++ b/src/components/pages/NewCallForward/CscNewCallForwardInput.vue @@ -7,6 +7,7 @@ dark clearable type="text" + ref="inputField" :float-label="label" v-model="inputValue" @keyup.enter="submit" @@ -44,6 +45,7 @@ mounted(){ if(this.prefilled){ this.inputValue = this.prefilled === " " ? "" : this.prefilled; + this.$v.$reset(); } }, @@ -97,6 +99,10 @@ blur() { this.$v.inputValue.$touch(); this.error = this.$v.inputValue.$error; + }, + reset(){ + this.$refs.inputField.clear(); + this.$v.$reset(); } }, watch: { diff --git a/src/components/pages/NewCallForward/CscNewCallForwardSource.vue b/src/components/pages/NewCallForward/CscNewCallForwardSource.vue index 40a17824..300dbba0 100644 --- a/src/components/pages/NewCallForward/CscNewCallForwardSource.vue +++ b/src/components/pages/NewCallForward/CscNewCallForwardSource.vue @@ -3,16 +3,6 @@ class="row csc-cf-source-cont" v-bind:class="{ 'csc-cf-removed-source': removeInProgress }" > -
- -
- {{ sourceSetName }} - -
- -
-
@@ -74,31 +57,40 @@ 'groupId', 'groupName', 'source', - 'sourceSetName' + 'sourceSetName', + 'sourceSetId' ], - // mounted(){ - // this.updateValues(this.destination) - // }, data(){ return { removeInProgress: false, - toggleNumberForm: true + toggleNumberForm: true, + sources: [] } }, computed: { - ...mapGetters('newCallForward', []), + ...mapGetters('newCallForward', [ + 'getSourcesesBySourcesetId' + ]), }, methods: { - showConfirmDialog(){ - this.$refs.confirmDialog.open(); - }, - async confirmDeleteSource(){ + async deleteSource(){ this.removeInProgress = true; - await this.$store.dispatch('newCallForward/removeSourceFromSourceset', { - source: this.source, - forwardGroupId: this.groupId, - sourceSetId: this.sourceSetId - }); + let sources = this.getSourcesesBySourcesetId(this.sourceSetId); + sources = sources.filter($source=> $source.source !== this.source); + try{ + await this.$store.dispatch('newCallForward/addGroupLoader', this.groupId); + await this.$store.dispatch('newCallForward/removeSourceFromSourceset', { + id: this.sourceSetId, + sources: sources + }); + await this.$store.dispatch('newCallForward/loadSourcesets'); + } + catch(err){ + console.log(err) + } + finally{ + await this.$store.dispatch('newCallForward/removeGroupLoader', this.groupId); + } this.removeInProgress = false; } } diff --git a/src/locales/en.json b/src/locales/en.json index 44248391..1d775ce2 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -221,7 +221,8 @@ "primarNumberEnabled": "All calls go to the primary number", "primarNumberDisabled": "No call goes to primary number", "forwardBtnLabel": "Add forwarding", - "conditionBtnLabel": "add condition", + "conditionBtnLabelPrefix": " and", + "conditionBtnLabel": " condition", "numberLabel": "Number", "voiceMailLabel": "Voicemail", "destinationTimeoutLabel": "Then after ", @@ -236,7 +237,7 @@ "cancelGroupDialogText": "You are about to delete {groupName} call forwarding group", "unconditionalLabel": "If online", "fromLabel": "If call from ...", - "fromLabelShort": " and call from ", + "fromLabelShort": " call from ", "offlineLabel": "If offline", "busyLabel": "If busy", "sourcesetName": "List name" diff --git a/src/store/new-call-forward.js b/src/store/new-call-forward.js index 0df90990..5ddd50a6 100644 --- a/src/store/new-call-forward.js +++ b/src/store/new-call-forward.js @@ -166,9 +166,6 @@ export default { } state.forwardGroups = forwardGroups; }, - setDestinationInCreation(state, isInCreation){ - state.destinationInCreation = isInCreation; - }, setSelectedDestType(state, destType){ state.selectedDestType = destType; }, @@ -581,9 +578,6 @@ export default { console.log(err) } }, - setDestinationInCreation(context, isInCreation){ - context.commit('setDestinationInCreation', isInCreation); - }, setSelectedDestType(context, destType){ context.commit('setSelectedDestType', destType); },