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 { 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;
}

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

@ -2,7 +2,7 @@
<div>
<q-item v-for="(destination, index) in destinations">
<q-item-main>
<div class="dest-row">
<div class="dest-row" :class="{ terminated: destination.terminated}">
<span v-if="index == 0">
{{ $t('pages.callForward.firstRing') }}
</span>
@ -23,6 +23,9 @@
{{ $t('pages.callForward.secs') }}
</span>
</span>
<q-tooltip v-if="destination.terminated">
{{ $t('pages.callForward.terminatedTooltip') }}
</q-tooltip>
</div>
</q-item-main>
<q-item-side class="dest-btns" right>
@ -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

@ -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}",

@ -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);
});
});

Loading…
Cancel
Save