From 2fa207031ac98f252291f94fcb99c387be6b0e40 Mon Sep 17 00:00:00 2001 From: raxelsen Date: Thu, 29 Mar 2018 16:16:35 +0200 Subject: [PATCH] TT#34011 Indication of active destinations Change-Id: I6f01ad02bd46b6aff299b0da58fcf62303e7845c --- src/api/call-forward.js | 24 +++- .../CallForward/CscAddDestinationForm.vue | 31 ++--- .../pages/CallForward/CscDestination.vue | 13 +- src/locales/en.json | 1 + t/api/call-forward.js | 116 +++++++++++++++++- 5 files changed, 159 insertions(+), 26 deletions(-) diff --git a/src/api/call-forward.js b/src/api/call-forward.js index 0e6f579d..0529f6b1 100644 --- a/src/api/call-forward.js +++ b/src/api/call-forward.js @@ -3,6 +3,7 @@ import _ from 'lodash'; import Vue from 'vue'; import { i18n } from '../i18n'; import { getJsonBody } from './utils'; +import { normalizeDestination } from '../filters/number-format' let rowCountAssumption = 1000; @@ -131,9 +132,9 @@ export function loadEverybodyDestinations(options) { Promise.all(cfbPromises) ]); }).then((res)=>{ - addGroupNamesAndTimeset({ group: res[0], groupName: 'cfu', timesetId: cfuTimeset }); - addGroupNamesAndTimeset({ group: res[1], groupName: 'cfna', timesetId: cfnaTimeset }); - addGroupNamesAndTimeset({ group: res[2], groupName: 'cfb', timesetId: cfbTimeset }); + addNameIdAndTerminating({ group: res[0], groupName: 'cfu', timesetId: cfuTimeset }); + addNameIdAndTerminating({ group: res[1], groupName: 'cfna', timesetId: cfnaTimeset }); + addNameIdAndTerminating({ group: res[2], groupName: 'cfb', timesetId: cfbTimeset }); resolve({ online: res[0], offline: res[1], @@ -145,10 +146,25 @@ export function loadEverybodyDestinations(options) { }); } -export function addGroupNamesAndTimeset(options) { +export function addNameIdAndTerminating(options) { + let terminatingFlag = false; options.group.forEach(destinationset => { destinationset.groupName = options.groupName; destinationset.timesetId = options.timesetId; + destinationset.destinations.forEach(destination => { + let normalized = normalizeDestination(destination.destination); + if (!terminatingFlag && _.includes(['Voicemail', 'Fax2Mail', 'Manager Secretary', + 'Custom Announcement', 'Conference'], normalized)) { + terminatingFlag = true; + destination.terminated = false; + } + else if (terminatingFlag) { + destination.terminated = true; + } + else { + destination.terminated = false; + } + }); }); return options.group; } diff --git a/src/components/pages/CallForward/CscAddDestinationForm.vue b/src/components/pages/CallForward/CscAddDestinationForm.vue index defbe902..e24f14bb 100644 --- a/src/components/pages/CallForward/CscAddDestinationForm.vue +++ b/src/components/pages/CallForward/CscAddDestinationForm.vue @@ -4,34 +4,29 @@ {{ $t('pages.callForward.addDestinationButton') }} - - {{ $t('pages.callForward.buttons.addNumber') }} + + {{ $t('pages.callForward.buttons.addNumber') }} - - {{ $t('pages.callForward.buttons.addVoicemail') }} + + {{ $t('pages.callForward.buttons.addVoicemail') }} - - {{ $t('pages.callForward.buttons.addFax2Mail') }} + + {{ $t('pages.callForward.buttons.addFax2Mail') }}
- + - + + type="number" v-if="isFormTypeNumber" v-model="destinationForm.timeout" + :min="0" :max="600" suffix="seconds" /> {{ $t('buttons.cancel') }} {{ $t('buttons.save') }} diff --git a/src/components/pages/CallForward/CscDestination.vue b/src/components/pages/CallForward/CscDestination.vue index b7ab4e6a..57203936 100644 --- a/src/components/pages/CallForward/CscDestination.vue +++ b/src/components/pages/CallForward/CscDestination.vue @@ -2,7 +2,7 @@
-
+
{{ $t('pages.callForward.firstRing') }} @@ -23,6 +23,9 @@ {{ $t('pages.callForward.secs') }} + + {{ $t('pages.callForward.terminatedTooltip') }} +
@@ -58,7 +61,7 @@ import { startLoading, stopLoading, showGlobalError } from '../../../helpers/ui' import { QItem, QItemMain, QItemSide, - Dialog, QBtn } from 'quasar-framework' + Dialog, QBtn, QTooltip } from 'quasar-framework' export default { name: 'csc-destination', props: [ @@ -72,7 +75,8 @@ QItemMain, QItemSide, Dialog, - QBtn + QBtn, + QTooltip }, computed: { ...mapState('callForward', [ @@ -160,6 +164,9 @@ .dest-values font-weight 500 + .dest-row.terminated + color $grey + .dest-btns display inline-block diff --git a/src/locales/en.json b/src/locales/en.json index 79a1f2c8..9877d983 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -150,6 +150,7 @@ "addInputError": "Input a valid number or subscriber name", "timeout": "Timeout", "destination": "Destination", + "terminatedTooltip": "This destination precedes a terminating destinations, and is therefore inactive.", "times": { "removeDialogTitle": "Remove call forward time", "removeDialogText": "You are about to remove the time entry for {day}", diff --git a/t/api/call-forward.js b/t/api/call-forward.js index b6072326..1b327538 100644 --- a/t/api/call-forward.js +++ b/t/api/call-forward.js @@ -9,7 +9,8 @@ import { getMappings, getSourcesets, getTimesets, addDestinationToDestinationset, convertTimesetToWeekdays, deleteTimeFromTimeset, - convertAddTime } from '../../src/api/call-forward'; + convertAddTime, + addNameIdAndTerminating } from '../../src/api/call-forward'; import { assert } from 'chai'; Vue.use(VueResource); @@ -847,4 +848,117 @@ describe('CallForward', function() { }); + it('should attempt to add group name, timeset id and terminated state to destinations', function(){ + + let options = { + group: [ + { + destinations: [ + { + announcement_id: null, + destination: "sip:1111@10.15.17.240", + priority: 1, + simple_destination: "1111", + timeout: 300 + }, + { + announcement_id: null, + destination: "sip:vmued4b92f4-59f0-414d-ba70-31c40da69e3b@voicebox.local", + priority: 1, + timeout: 300 + }, + { + announcement_id: null, + destination: "sip:2222@10.15.17.240", + priority: 1, + simple_destination: "2222", + timeout: 300 + }, + ], + id: 3, + name: "t1", + priority: 1, + subscriber_id: 311, + timeset: null + }, + { + destinations: [ + { + announcement_id: null, + destination: "sip:3333@10.15.17.240", + priority: 1, + simple_destination: "3333", + timeout: 300 + }, + ], + id: 5, + name: "t2", + priority: 1, + subscriber_id: 311, + timeset: null + } + ], + groupName: "cfu", + timesetId: null + }; + let data = [ + { + destinations: [ + { + announcement_id: null, + destination: "sip:1111@10.15.17.240", + priority: 1, + simple_destination: "1111", + terminated: false, + timeout: 300 + }, + { + announcement_id: null, + destination: "sip:vmued4b92f4-59f0-414d-ba70-31c40da69e3b@voicebox.local", + priority: 1, + terminated: false, + timeout: 300 + }, + { + announcement_id: null, + destination: "sip:2222@10.15.17.240", + priority: 1, + simple_destination: "2222", + terminated: true, + timeout: 300 + }, + ], + groupName: "cfu", + id: 3, + name: "t1", + priority: 1, + subscriber_id: 311, + timeset: null, + timesetId: null + }, + { + destinations: [ + { + announcement_id: null, + destination: "sip:3333@10.15.17.240", + priority: 1, + simple_destination: "3333", + terminated: true, + timeout: 300 + } + ], + groupName: "cfu", + id: 5, + name: "t2", + priority: 1, + subscriber_id: 311, + timeset: null, + timesetId: null + } + ]; + + assert.deepEqual(addNameIdAndTerminating(options), data); + + }); + });