From c0c77e629287f57d7db23564ec5e9741a3094a82 Mon Sep 17 00:00:00 2001 From: Carlo Venusino Date: Tue, 16 Jun 2020 10:11:45 +0200 Subject: [PATCH] TT#82506 CF: As a Customer, I want to add condition "... and date is" to forwarding groups MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit √ Can choose "date is" from condition menu in each forwarding group (online, offline, busy) √ Can click "date is ..." to set the date initially √ Can see a date widget according to the screens √ Can choose a date √ Can set the date √ Can see the changed title "... and date is Thu, Apr 13 2017" √ Can click the changed title to set a new date again √ Can remove the condition Change-Id: Ia2aec66d7c8d89f2be8b471348a98db96219d204 --- .../NewCallForward/CscCallForwardGroup.vue | 198 +++++++++++++++--- .../NewCallForward/CscNewCallForward.vue | 1 + .../CscNewCallForwardConditionTypeSelect.vue | 99 ++++++++- .../CscNewCallForwardEditSources.vue | 4 - src/locales/en.json | 4 + src/store/new-call-forward.js | 73 ++++++- 6 files changed, 334 insertions(+), 45 deletions(-) diff --git a/src/components/pages/NewCallForward/CscCallForwardGroup.vue b/src/components/pages/NewCallForward/CscCallForwardGroup.vue index 8432be0b..8c124408 100644 --- a/src/components/pages/NewCallForward/CscCallForwardGroup.vue +++ b/src/components/pages/NewCallForward/CscCallForwardGroup.vue @@ -26,16 +26,67 @@ > + + {{ $t('pages.newCallForward.conditionBtnLabelPrefix') }} + + {{ $t('pages.newCallForward.fromLabelShort') +'"'+ groupSourceset +'"'}} + + + + + + + + {{ $t('pages.newCallForward.conditionBtnLabelPrefix') }} + + {{ $t('pages.newCallForward.dateIsShort') + groupTimeset }} + + + + + + {{ $t('pages.newCallForward.conditionBtnLabelPrefix') }} @@ -48,6 +99,8 @@ > - - {{ $t('pages.newCallForward.conditionBtnLabelPrefix') }} - - {{ $t('pages.newCallForward.fromLabelShort') +'"'+ groupSourceset +'"'}} - - - - - -
0){ + time = this.timeSet.times[0]; + dateN = new Date(parseInt(time.year), parseInt(time.month) - 1 , parseInt(time.mday), 0, 0, 0, 0); + retVal = date.formatDate( dateN, 'ddd, MMM D YYYY') + } + return retVal; + }, isTempGroup(){ return this.group.id.toString().includes('temp-'); }, @@ -334,12 +382,30 @@ }, isTimeoutOrUnconditional(){ return this.group.name.includes( 'unconditional') || this.group.name.includes('timeout'); + }, + dayModel: { + get() { + let time = this.timeSet.times[0]; + let dateN = new Date(parseInt(time.year), parseInt(time.month) - 1 , parseInt(time.mday), 0, 0, 0, 0); + return dateN; + }, + set(value) { + if(value !== ""){ + this.addTimeset(value); + } + else{ + this.showConfirmDeleteTimesetDialog() + } + } } }, watch: { getSourcesets: function () { this.updateSourcesetNames(); }, + getTimesets: function () { + this.updateTimeSetNames(); + }, getGroupsLoaders: function(){ const groupLoaders = this.getGroupsLoaders; this.groupIsLoading = groupLoaders.includes(this.group.id); @@ -347,7 +413,7 @@ getFirstDestinationInCreation: function(){ if(this.getFirstDestinationInCreation === this.group.id.toString()){ this.toggleConditionFromForm = false; - this.$refs.onlineSourceset.open(); + this.$refs.conditions.open(); } } }, @@ -385,9 +451,17 @@ firstDestinationCmp.$refs.destTypeForm.open(); }, - async showConditionForm(){ - this.toggleConditionFromForm = false; - this.$refs.onlineSourceset.open(); + showConditionForm(){ + const action = this.$refs.addCondition.action; + switch(action){ + case "addFromCondition": + this.toggleConditionFromForm = false; + this.$refs.onlineSourceset.open(); + break; + case "addDateIsCondition": + break; + } + }, showDestTypeForm(){ @@ -449,6 +523,25 @@ } } }, + async updateTimeSetNames(){ + const mappings = this.getMappings; + const groupMappingId = await this.$store.dispatch('newCallForward/getMappingIdByGroupName', this.group.name); + let groupMapping, timeSet; + if(mappings[groupMappingId]){ + groupMapping = mappings[groupMappingId].filter(($mapping)=>{ + return $mapping.destinationset_id == this.group.id; + }); + timeSet = groupMapping[0] && groupMapping[0].timeset_id ? await this.$store.dispatch('newCallForward/getTimesetById', groupMapping[0].timeset_id) : null; + if(timeSet){ + this.timeSet = timeSet; + this.times = this.timeSet.times; + } + else{ + this.timeSet = null; + this.times = []; + } + } + }, showConfirmDialog(){ this.$refs.confirmDialog.open(); }, @@ -463,6 +556,44 @@ console.log(e) } + }, + showQDate(){ + this.$refs.dayWidget.open() + }, + showConfirmDeleteTimesetDialog(){ + this.$refs.confirmDeleteTimesetDialog.open(); + }, + async deleteTimeset(){ + try{ + await this.$store.dispatch('newCallForward/addGroupLoader', this.group.id); + await this.$store.dispatch('newCallForward/deleteTimesFromTimeset', this.timeSet.id); + await this.$store.dispatch('newCallForward/loadTimesets'); + await this.$store.dispatch('newCallForward/loadMappings'); + await this.$store.dispatch('newCallForward/removeGroupLoader', this.group.id); + } + catch(e){ + console.log(e) + } + }, + async addTimeset(time){ + try{ + await this.$store.dispatch('newCallForward/addGroupLoader', this.group.id); + this.day = { + "year": date.formatDate(time, 'YYYY'), + "month": date.formatDate(time, 'M'), + "mday": date.formatDate(time, 'D') + } + await this.$store.dispatch('newCallForward/addTimeToTimeset', { + id: this.timeSet.id, + time: this.day + }); + await this.$store.dispatch('newCallForward/loadTimesets'); + await this.$store.dispatch('newCallForward/loadMappings'); + await this.$store.dispatch('newCallForward/removeGroupLoader', this.group.id); + } + catch(e){ + console.log(e) + } } } } @@ -509,4 +640,13 @@ color $cf-disabled-link .q-icon color $cf-disabled-link !important + .row.q-datetime-controls.modal-buttons-top + button:first-child + color red !important + &:before + font-family: "Material Icons" + content: "\e872" + font-size 24px + margin-right 10px + diff --git a/src/components/pages/NewCallForward/CscNewCallForward.vue b/src/components/pages/NewCallForward/CscNewCallForward.vue index d092c5a1..755a5d17 100644 --- a/src/components/pages/NewCallForward/CscNewCallForward.vue +++ b/src/components/pages/NewCallForward/CscNewCallForward.vue @@ -147,6 +147,7 @@ try{ await this.$store.dispatch('newCallForward/loadMappings'); await this.$store.dispatch('newCallForward/loadSourcesets'); + await this.$store.dispatch('newCallForward/loadTimesets'); await this.$store.dispatch('newCallForward/loadForwardGroups'); let unconditionalGroups = await this.$store.dispatch('newCallForward/getForwardGroupByName', 'unconditional'); this.toggleDefaultNumber = !unconditionalGroups; diff --git a/src/components/pages/NewCallForward/CscNewCallForwardConditionTypeSelect.vue b/src/components/pages/NewCallForward/CscNewCallForwardConditionTypeSelect.vue index f9f5838b..fe82dbcd 100644 --- a/src/components/pages/NewCallForward/CscNewCallForwardConditionTypeSelect.vue +++ b/src/components/pages/NewCallForward/CscNewCallForwardConditionTypeSelect.vue @@ -4,10 +4,31 @@ >
{{ $t('pages.newCallForward.fromLabel') }}
+
+ {{ $t('pages.newCallForward.dateIsLabel') }} + + + +
@@ -16,30 +37,82 @@ mapGetters, } from 'vuex' import CscSpinner from '../../CscSpinner' - import { } from 'quasar-framework' + import { + QDatetime, + QPopover, + date + } from 'quasar-framework' export default { name: 'csc-new-call-forward-condition-type-select', + props: [ + 'groupId', + 'groupName', + 'disableSourcesetMenu', + 'disableTimesetMenu' + ], components: { - CscSpinner + CscSpinner, + QDatetime, + QPopover }, data () { return { enabled: true, - action: null + action: null, + timesetName: null, + day: null, + today: new Date() } }, + mounted(){ + this.timesetName = 'timeset-'+this.groupId; + }, computed: { - ...mapGetters('newCallForward', [ - ]) + ...mapGetters('newCallForward', []), + dayModel: { + get() { + return this.day; + }, + async set(value) { + try{ + await this.$store.dispatch('newCallForward/addGroupLoader', this.groupId); + const timeSetId = await this.$store.dispatch('newCallForward/createTimeSet', this.timesetName); + await this.$store.dispatch('newCallForward/addTimesetToGroup', { + name: this.groupName, + groupId: this.groupId, + timeSetId: timeSetId + }); + this.day = { + "year": date.formatDate(value, 'YYYY'), + "month": date.formatDate(value, 'M'), + "mday": date.formatDate(value, 'D') + } + await this.$store.dispatch('newCallForward/addTimeToTimeset', { + id: timeSetId, + time: this.day + }); + await this.$store.dispatch('newCallForward/loadMappings'); + await this.$store.dispatch('newCallForward/loadTimesets'); + await this.$store.dispatch('newCallForward/removeGroupLoader', this.groupId); + + } + catch(err){ + console.log(err) + } + + } + } }, methods: { - - async addFromCondition(){ + addFromCondition(){ this.action = "addFromCondition"; this.$parent.close() }, - + addDateIsCondition(){ + this.action = "addDateIsCondition"; + this.$parent.close() + }, cancel() { this.action = null; this.enabled = false; @@ -51,6 +124,9 @@ this.action = null; this.enabled = false; }, + showQDate(){ + this.$refs.dayWidget.open() + } } } @@ -63,4 +139,11 @@ cursor pointer .csc-cf-dest-type:hover background $main-menu-item-hover-background + .csc-cf-calendar-day + margin-top -100px !important + .q-datetime-weekdays + color $tertiary + .q-datetime-days div:not(.q-datetime-day-active), + .q-datetime-dark + color $white diff --git a/src/components/pages/NewCallForward/CscNewCallForwardEditSources.vue b/src/components/pages/NewCallForward/CscNewCallForwardEditSources.vue index 7cb88a1b..efa526bc 100644 --- a/src/components/pages/NewCallForward/CscNewCallForwardEditSources.vue +++ b/src/components/pages/NewCallForward/CscNewCallForwardEditSources.vue @@ -5,7 +5,6 @@ v-bind:class="{ 'csc-cf-popover-hide': toggleFormVisibility}" >
-
@@ -26,9 +25,6 @@
- - -
(sourceSetId) => { const sourceSet = state.sourceSets.filter($sourceset => $sourceset.id == sourceSetId); return sourceSet && sourceSet[0] ? sourceSet[0].sources : null; + }, + getTimesets(state){ + return state.timeSets; } }, mutations: { @@ -161,7 +169,6 @@ export default { state.mappings = mappings; }, loadForwardGroups(state, forwardGroups){ - for (let i = 0; i < forwardGroups.length; i++) { const group = forwardGroups[i]; if (group.name.includes('unconditional') || group.name.includes('timeout')){ @@ -177,6 +184,9 @@ export default { setSourceSets(state, sourceSets){ state.sourceSets = sourceSets; }, + setTimeSets(state, timeSets){ + state.timeSets = timeSets; + }, addGroupLoader(state, groupId){ state.groupsLoaders.push(groupId) }, @@ -223,11 +233,12 @@ export default { const groupMappingId = ForwardGroup[data.name] ? ForwardGroup[data.name].mapping : await context.dispatch('getMappingIdByGroupName', data.name); const allMappings = context.getters.getMappings; let groupMappings = allMappings[groupMappingId]; - if(data.replaceMapping){ for(let mapping of groupMappings){ if(mapping.destinationset_id === data.groupId){ + mapping.sourceset_id = data.sourceSetId || null; + mapping.timeset_id = data.timeSetId || null; break; } } @@ -236,7 +247,7 @@ export default { groupMappings.push({ "destinationset_id": data.groupId, "sourceset_id": data.sourceSetId || null, - "timeset_id":null + "timeset_id": data.timeSetId || null }); } await addNewMapping({ @@ -594,6 +605,11 @@ export default { const sourceSets = await getSourcesets(subscriberId); context.commit('setSourceSets', sourceSets); }, + async loadTimesets(context){ + const subscriberId = localStorage.getItem('subscriberId'); + const timeSets = await getTimesets(subscriberId); + context.commit('setTimeSets', timeSets); + }, async createSourceSet(context, data){ const sourceSetId = await createSourcesetWithSource({ sourcesetName: data.name, @@ -620,6 +636,10 @@ export default { const sourceSet = context.state.sourceSets.filter($sourceset => $sourceset.id == id); return sourceSet ? sourceSet[0] : []; }, + async getTimesetById(context, id){ + const timeSet = context.state.timeSets.filter($timeset => $timeset.id == id); + return timeSet ? timeSet[0] : []; + }, async addSourceToSourceset(context, data){ await addSourceToSourceset(data) }, @@ -631,6 +651,51 @@ export default { }, setFirstDestinationInCreation(context, groupId){ context.commit('setFirstDestinationInCreation', groupId); + }, + async createTimeSet(context, timesetName){ + try{ + // const subscriberId = localStorage.getItem('subscriberId'); + const timesetId = await addNewTimeset(timesetName); + return timesetId; + } + catch(err){ + console.log(err) + } + }, + async addTimesetToGroup(context, data){ + try{ + await context.dispatch('editMapping', { + name: data.name, + groupId: data.groupId, + timeSetId: data.timeSetId, + replaceMapping: true + }); + } + catch(err){ + console.log(err) + } + }, + async addTimeToTimeset(context, data){ + try{ + await addTimeToTimeset({ + id: data.id, + times: [data.time] + }); + } + catch(err){ + console.log(err) + } + }, + async deleteTimesFromTimeset(context, timesetId){ + try{ + await deleteTimeFromTimeset({ + timesetId: timesetId, + times: [] + }); + } + catch(err){ + console.log(err) + } } } };