TT#34011 Indication of active destinations

Change-Id: I6f01ad02bd46b6aff299b0da58fcf62303e7845c
changes/59/20059/3
raxelsen 8 years ago
parent f0a2fa1ed9
commit 2fa207031a

@ -3,6 +3,7 @@ import _ from 'lodash';
import Vue from 'vue'; import Vue from 'vue';
import { i18n } from '../i18n'; import { i18n } from '../i18n';
import { getJsonBody } from './utils'; import { getJsonBody } from './utils';
import { normalizeDestination } from '../filters/number-format'
let rowCountAssumption = 1000; let rowCountAssumption = 1000;
@ -131,9 +132,9 @@ export function loadEverybodyDestinations(options) {
Promise.all(cfbPromises) Promise.all(cfbPromises)
]); ]);
}).then((res)=>{ }).then((res)=>{
addGroupNamesAndTimeset({ group: res[0], groupName: 'cfu', timesetId: cfuTimeset }); addNameIdAndTerminating({ group: res[0], groupName: 'cfu', timesetId: cfuTimeset });
addGroupNamesAndTimeset({ group: res[1], groupName: 'cfna', timesetId: cfnaTimeset }); addNameIdAndTerminating({ group: res[1], groupName: 'cfna', timesetId: cfnaTimeset });
addGroupNamesAndTimeset({ group: res[2], groupName: 'cfb', timesetId: cfbTimeset }); addNameIdAndTerminating({ group: res[2], groupName: 'cfb', timesetId: cfbTimeset });
resolve({ resolve({
online: res[0], online: res[0],
offline: res[1], 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 => { options.group.forEach(destinationset => {
destinationset.groupName = options.groupName; destinationset.groupName = options.groupName;
destinationset.timesetId = options.timesetId; 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; return options.group;
} }

@ -4,34 +4,29 @@
{{ $t('pages.callForward.addDestinationButton') }} {{ $t('pages.callForward.addDestinationButton') }}
<q-popover ref="popover"> <q-popover ref="popover">
<q-list separator link> <q-list separator link>
<q-item @click="enableForm('number'), <q-item @click="enableForm('number'), $refs.popover.close()">
$refs.popover.close()"> {{ $t('pages.callForward.buttons.addNumber') }}
{{ $t('pages.callForward.buttons.addNumber') }}
</q-item> </q-item>
<q-item @click="enableForm('voicebox'), <q-item @click="enableForm('voicebox'), $refs.popover.close()">
$refs.popover.close()"> {{ $t('pages.callForward.buttons.addVoicemail') }}
{{ $t('pages.callForward.buttons.addVoicemail') }}
</q-item> </q-item>
<q-item @click="enableForm('fax2mail'), <q-item @click="enableForm('fax2mail'), $refs.popover.close()" v-if="hasFaxCapability">
$refs.popover.close()" {{ $t('pages.callForward.buttons.addFax2Mail') }}
v-if="hasFaxCapability">
{{ $t('pages.callForward.buttons.addFax2Mail') }}
</q-item> </q-item>
</q-list> </q-list>
</q-popover> </q-popover>
</q-btn> </q-btn>
<div v-if="isFormEnabled"> <div v-if="isFormEnabled">
<q-field :error="addFormError" :error-label="$t('pages.callForward.addInputError')"> <q-field :error="addFormError" :error-label="$t('pages.callForward.addInputError')">
<q-input :before="beforeIconDestination" :float-label="$t('pages.callForward.destination')" type="text" <q-input :before="beforeIconDestination" :float-label="$t('pages.callForward.destination')" type="text"
v-model="destinationForm.destination" @keyup.enter="addDestination()" v-model="destinationForm.destination" @keyup.enter="addDestination()"
:clearable="isFormTypeNumber" :autofocus="isFormTypeNumber" :clearable="isFormTypeNumber" :autofocus="isFormTypeNumber"
:disable="!isFormTypeNumber || addDestinationIsRequesting" /> :disable="!isFormTypeNumber || addDestinationIsRequesting" />
</q-field> </q-field>
<q-field :error="addFormError" <q-field :error="addFormError" :error-label="$t('pages.callForward.addInputError')">
:error-label="$t('pages.callForward.addInputError')">
<q-input :before="beforeIconTimeout" :float-label="$t('pages.callForward.timeout')" <q-input :before="beforeIconTimeout" :float-label="$t('pages.callForward.timeout')"
type="number" v-if="isFormTypeNumber" v-model="destinationForm.timeout" type="number" v-if="isFormTypeNumber" v-model="destinationForm.timeout"
:min="0" :max="600" suffix="seconds" /> :min="0" :max="600" suffix="seconds" />
</q-field> </q-field>
<q-btn flat dark @click="disableForm()">{{ $t('buttons.cancel') }}</q-btn> <q-btn flat dark @click="disableForm()">{{ $t('buttons.cancel') }}</q-btn>
<q-btn flat color="primary" icon-right="fa-save" @click="addDestination()">{{ $t('buttons.save') }}</q-btn> <q-btn flat color="primary" icon-right="fa-save" @click="addDestination()">{{ $t('buttons.save') }}</q-btn>

@ -2,7 +2,7 @@
<div> <div>
<q-item v-for="(destination, index) in destinations"> <q-item v-for="(destination, index) in destinations">
<q-item-main> <q-item-main>
<div class="dest-row"> <div class="dest-row" :class="{ terminated: destination.terminated}">
<span v-if="index == 0"> <span v-if="index == 0">
{{ $t('pages.callForward.firstRing') }} {{ $t('pages.callForward.firstRing') }}
</span> </span>
@ -23,6 +23,9 @@
{{ $t('pages.callForward.secs') }} {{ $t('pages.callForward.secs') }}
</span> </span>
</span> </span>
<q-tooltip v-if="destination.terminated">
{{ $t('pages.callForward.terminatedTooltip') }}
</q-tooltip>
</div> </div>
</q-item-main> </q-item-main>
<q-item-side class="dest-btns" right> <q-item-side class="dest-btns" right>
@ -58,7 +61,7 @@
import { startLoading, stopLoading, import { startLoading, stopLoading,
showGlobalError } from '../../../helpers/ui' showGlobalError } from '../../../helpers/ui'
import { QItem, QItemMain, QItemSide, import { QItem, QItemMain, QItemSide,
Dialog, QBtn } from 'quasar-framework' Dialog, QBtn, QTooltip } from 'quasar-framework'
export default { export default {
name: 'csc-destination', name: 'csc-destination',
props: [ props: [
@ -72,7 +75,8 @@
QItemMain, QItemMain,
QItemSide, QItemSide,
Dialog, Dialog,
QBtn QBtn,
QTooltip
}, },
computed: { computed: {
...mapState('callForward', [ ...mapState('callForward', [
@ -160,6 +164,9 @@
.dest-values .dest-values
font-weight 500 font-weight 500
.dest-row.terminated
color $grey
.dest-btns .dest-btns
display inline-block display inline-block

@ -150,6 +150,7 @@
"addInputError": "Input a valid number or subscriber name", "addInputError": "Input a valid number or subscriber name",
"timeout": "Timeout", "timeout": "Timeout",
"destination": "Destination", "destination": "Destination",
"terminatedTooltip": "This destination precedes a terminating destinations, and is therefore inactive.",
"times": { "times": {
"removeDialogTitle": "Remove call forward time", "removeDialogTitle": "Remove call forward time",
"removeDialogText": "You are about to remove the time entry for {day}", "removeDialogText": "You are about to remove the time entry for {day}",

@ -9,7 +9,8 @@ import { getMappings, getSourcesets, getTimesets,
addDestinationToDestinationset, addDestinationToDestinationset,
convertTimesetToWeekdays, convertTimesetToWeekdays,
deleteTimeFromTimeset, deleteTimeFromTimeset,
convertAddTime } from '../../src/api/call-forward'; convertAddTime,
addNameIdAndTerminating } from '../../src/api/call-forward';
import { assert } from 'chai'; import { assert } from 'chai';
Vue.use(VueResource); 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);
});
}); });

Loading…
Cancel
Save