TT#28057 List all after hours destinations

What has been done:
- TT#31190, CallForwarding: Create store mutation unit test
- TT#31188, CallForwarding: Implement API requests
- TT#31189, CallForwarding: Implement store
- TT#31174, CallForwarding: Implement vue component

Change-Id: I79557be8c8cea4b8014e25afab213b8ab4d4acb8
changes/20/18720/3
raxelsen 7 years ago
parent cefb66b549
commit fcbd7f64ef

@ -84,7 +84,7 @@ export function getDestinationsets(id) {
});
}
export function loadAlwaysDestinations(options) {
export function loadEverybodyDestinations(options) {
return new Promise((resolve, reject)=>{
let cfuTimeset = null;
let cfnaTimeset = null;

@ -1,16 +1,29 @@
<template>
<csc-page :title="$t('pages.callForward.titles.afterHours')">
<csc-call-forward timeset="After Hours" :destinations="destinations">
</csc-call-forward>
</csc-page>
</template>
<script>
import { mapState } from 'vuex'
import CscPage from '../../CscPage'
import CscCallForward from './CscCallForward'
export default {
data () {
return {}
},
components: {
CscPage
CscPage,
CscCallForward
},
created() {
this.$store.dispatch('callForward/loadAfterHoursEverybodyDestinations');
},
computed: {
...mapState('callForward', {
destinations: 'afterHoursEverybodyDestinations'
})
}
}
</script>

@ -1,106 +1,32 @@
<template>
<csc-page :title="$t('pages.callForward.titles.always')">
<q-card class="dest-card">
<csc-destinations :title="$t('pages.callForward.whenOnline')"
:group="destinations.online"
group-name="cfu"
timeset="null"
icon="signal_wifi_4_bar">
</csc-destinations>
<csc-destinations :title="$t('pages.callForward.whenBusy')"
:group="destinations.busy"
group-name="cfb"
timeset="null"
icon="record_voice_over">
</csc-destinations>
<csc-destinations :title="$t('pages.callForward.whenOffline')"
:group="destinations.offline"
group-name="cfna"
timeset="null"
icon="signal_wifi_off">
</csc-destinations>
</q-card>
<csc-call-forward timeset="null" :destinations="destinations">
</csc-call-forward>
</csc-page>
</template>
<script>
import numberFormat from '../../../filters/number-format'
import { mapState } from 'vuex'
import { startLoading, stopLoading,
showGlobalError, showToast } from '../../../helpers/ui'
import CscPage from '../../CscPage'
import CscDestinations from './CscDestinations'
import { QCard } from 'quasar-framework'
import CscCallForward from './CscCallForward'
export default {
created() {
this.$store.dispatch('callForward/loadAlwaysEverybodyDestinations');
},
data () {
return {
}
return {}
},
components: {
QCard,
CscPage,
CscDestinations
CscCallForward
},
created() {
this.$store.dispatch('callForward/loadAlwaysEverybodyDestinations');
},
computed: {
...mapState('callForward', {
removeDestinationState: 'removeDestinationState',
addDestinationState: 'addDestinationState',
changeDestinationState: 'changeDestinationState',
destinations: 'alwaysEverybodyDestinations',
lastRemovedDestination: 'lastRemovedDestination',
lastAddedDestination: 'lastAddedDestination',
addDestinationError(state) {
return state.addDestinationError ||
this.$t('pages.callForward.addErrorMessage');
}
destinations: 'alwaysEverybodyDestinations'
})
},
watch: {
removeDestinationState(state) {
if (state === 'requesting') {
startLoading();
} else if (state === 'failed') {
stopLoading();
showGlobalError(this.removeDestinationError);
} else if (state === 'succeeded') {
stopLoading();
showToast(this.$t('pages.callForward.removeSuccessMessage', {
destination: this.lastRemovedDestination
}));
this.$store.dispatch('callForward/loadAlwaysEverybodyDestinations');
}
},
addDestinationState(state) {
if (state === 'requesting') {
startLoading();
} else if (state === 'failed') {
stopLoading();
showGlobalError(this.addDestinationError);
} else if (state === 'succeeded') {
stopLoading();
showToast(this.$t('pages.callForward.addDestinationSuccessMessage', {
destination: this.lastAddedDestination
}));
this.$store.dispatch('callForward/loadAlwaysEverybodyDestinations');
}
},
changeDestinationState(state) {
if (state === 'requesting') {
startLoading();
} else if (state === 'failed') {
stopLoading();
showGlobalError(this.changeDestinationError);
} else if (state === 'succeeded') {
stopLoading();
this.$store.dispatch('callForward/loadAlwaysEverybodyDestinations');
}
}
}
}
</script>
<style lang="stylus">
<style>
</style>

@ -1,106 +1,32 @@
<template>
<csc-page :title="$t('pages.callForward.titles.companyHours')">
<q-card class="dest-card">
<csc-destinations :title="$t('pages.callForward.whenOnline')"
:group="destinations.online"
group-name="cfu"
timeset="Company Hours"
icon="signal_wifi_4_bar">
</csc-destinations>
<csc-destinations :title="$t('pages.callForward.whenBusy')"
:group="destinations.busy"
group-name="cfb"
timeset="Company Hours"
icon="record_voice_over">
</csc-destinations>
<csc-destinations :title="$t('pages.callForward.whenOffline')"
:group="destinations.offline"
group-name="cfna"
timeset="Company Hours"
icon="signal_wifi_off">
</csc-destinations>
</q-card>
<csc-call-forward timeset="Company Hours" :destinations="destinations">
</csc-call-forward>
</csc-page>
</template>
<script>
import numberFormat from '../../../filters/number-format'
import { mapState } from 'vuex'
import { startLoading, stopLoading,
showGlobalError, showToast } from '../../../helpers/ui'
import CscPage from '../../CscPage'
import CscDestinations from './CscDestinations'
import { QCard } from 'quasar-framework'
import CscCallForward from './CscCallForward'
export default {
created() {
this.$store.dispatch('callForward/loadCompanyHoursEverybodyDestinations');
},
data () {
return {
}
return {}
},
components: {
QCard,
CscPage,
CscDestinations
CscCallForward
},
created() {
this.$store.dispatch('callForward/loadCompanyHoursEverybodyDestinations');
},
computed: {
...mapState('callForward', {
removeDestinationState: 'removeDestinationState',
addDestinationState: 'addDestinationState',
changeDestinationState: 'changeDestinationState',
destinations: 'companyHoursEverybodyDestinations',
lastRemovedDestination: 'lastRemovedDestination',
lastAddedDestination: 'lastAddedDestination',
addDestinationError(state) {
return state.addDestinationError ||
this.$t('pages.callForward.addErrorMessage');
}
destinations: 'companyHoursEverybodyDestinations'
})
},
watch: {
removeDestinationState(state) {
if (state === 'requesting') {
startLoading();
} else if (state === 'failed') {
stopLoading();
showGlobalError(this.removeDestinationError);
} else if (state === 'succeeded') {
stopLoading();
showToast(this.$t('pages.callForward.removeSuccessMessage', {
destination: this.lastRemovedDestination
}));
this.$store.dispatch('callForward/loadCompanyHoursEverybodyDestinations');
}
},
addDestinationState(state) {
if (state === 'requesting') {
startLoading();
} else if (state === 'failed') {
stopLoading();
showGlobalError(this.addDestinationError);
} else if (state === 'succeeded') {
stopLoading();
showToast(this.$t('pages.callForward.addDestinationSuccessMessage', {
destination: this.lastAddedDestination
}));
this.$store.dispatch('callForward/loadCompanyHoursEverybodyDestinations');
}
},
changeDestinationState(state) {
if (state === 'requesting') {
startLoading();
} else if (state === 'failed') {
stopLoading();
showGlobalError(this.changeDestinationError);
} else if (state === 'succeeded') {
stopLoading();
this.$store.dispatch('callForward/loadCompanyHoursEverybodyDestinations');
}
}
}
}
</script>
<style lang="stylus">
<style>
</style>

@ -0,0 +1,114 @@
<template>
<q-card class="dest-card">
<csc-destinations :title="$t('pages.callForward.whenOnline')"
:group="destinations.online"
group-name="cfu"
:timeset="timeset"
icon="signal_wifi_4_bar">
</csc-destinations>
<csc-destinations :title="$t('pages.callForward.whenBusy')"
:group="destinations.busy"
group-name="cfb"
:timeset="timeset"
icon="record_voice_over">
</csc-destinations>
<csc-destinations :title="$t('pages.callForward.whenOffline')"
:group="destinations.offline"
group-name="cfna"
:timeset="timeset"
icon="signal_wifi_off">
</csc-destinations>
</q-card>
</template>
<script>
import numberFormat from '../../../filters/number-format'
import { mapState } from 'vuex'
import { startLoading, stopLoading,
showGlobalError, showToast } from '../../../helpers/ui'
import CscDestinations from './CscDestinations'
import { QCard } from 'quasar-framework'
export default {
name: 'csc-call-forward',
props: [
'timeset',
'destinations'
],
data () {
return {
}
},
components: {
QCard,
CscDestinations
},
computed: {
...mapState('callForward', {
removeDestinationState: 'removeDestinationState',
addDestinationState: 'addDestinationState',
changeDestinationState: 'changeDestinationState',
lastRemovedDestination: 'lastRemovedDestination',
lastAddedDestination: 'lastAddedDestination',
addDestinationError(state) {
return state.addDestinationError ||
this.$t('pages.callForward.addErrorMessage');
}
})
},
methods: {
reload(timeset) {
if (!timeset) {
this.$store.dispatch('callForward/loadAlwaysEverybodyDestinations');
} else if (timeset === 'Company Hours') {
this.$store.dispatch('callForward/loadCompanyHoursEverybodyDestinations');
} else if (timeset === 'After Hours') {
this.$store.dispatch('callForward/loadAfterHoursEverybodyDestinations');
};
}
},
watch: {
removeDestinationState(state) {
if (state === 'requesting') {
startLoading();
} else if (state === 'failed') {
stopLoading();
showGlobalError(this.removeDestinationError);
} else if (state === 'succeeded') {
stopLoading();
showToast(this.$t('pages.callForward.removeSuccessMessage', {
destination: this.lastRemovedDestination
}));
this.reload(this.timeset);
}
},
addDestinationState(state) {
if (state === 'requesting') {
startLoading();
} else if (state === 'failed') {
stopLoading();
showGlobalError(this.addDestinationError);
} else if (state === 'succeeded') {
stopLoading();
showToast(this.$t('pages.callForward.addDestinationSuccessMessage', {
destination: this.lastAddedDestination
}));
this.reload(this.timeset);
}
},
changeDestinationState(state) {
if (state === 'requesting') {
startLoading();
} else if (state === 'failed') {
stopLoading();
showGlobalError(this.changeDestinationError);
} else if (state === 'succeeded') {
stopLoading();
this.reload(this.timeset);
}
}
}
}
</script>
<style lang="stylus">
</style>

@ -3,7 +3,7 @@
import _ from 'lodash'; import { getSourcesets, getDestinationsets,
getTimesets,
getMappings,
loadAlwaysDestinations,
loadEverybodyDestinations,
deleteDestinationFromDestinationset,
addDestinationToDestinationset,
addDestinationToEmptyGroup,
@ -36,6 +36,11 @@ export default {
busy: [],
offline: []
},
afterHoursEverybodyDestinations: {
online: [],
busy: [],
offline: []
},
removeDestinationState: DestinationState.button,
removeDestinationError: null,
lastRemovedDestination: null,
@ -84,6 +89,16 @@ export default {
};
};
return timeset ? timeset.timesetId : null;
},
getAfterHoursId(state) {
let timeset;
for (let group in state.afterHoursEverybodyDestinations) { if (!timeset) {
timeset = _.find(state.afterHoursEverybodyDestinations[group], (o) => {
return o.timesetId > 0;
});
};
};
return timeset ? timeset.timesetId : null;
}
},
mutations: {
@ -105,6 +120,9 @@ export default {
loadCompanyHoursEverybodyDestinations(state, result) {
state.companyHoursEverybodyDestinations = result;
},
loadAfterHoursEverybodyDestinations(state, result) {
state.afterHoursEverybodyDestinations = result;
},
setActiveForm(state, value) {
state.activeForm = value;
},
@ -123,6 +141,9 @@ export default {
setLastAddedDestination(state, value) {
state.lastAddedDestination = value;
},
setLastRemovedDestination(state, value) {
state.lastRemovedDestination = value;
},
resetFormState(state) {
state.form = {
announcement_id: null,
@ -175,9 +196,6 @@ export default {
removeDestinationFailed(state, error) {
state.removeDestinationState = DestinationState.failed;
state.removeDestinationError = error;
},
setLastRemovedDestination(state, value) {
state.lastRemovedDestination = value;
}
},
actions: {
@ -223,7 +241,7 @@ export default {
},
loadAlwaysEverybodyDestinations(context) {
return new Promise((resolve, reject)=>{
loadAlwaysDestinations({
loadEverybodyDestinations({
subscriberId: localStorage.getItem('subscriberId'),
timeset: null
}).then((result)=>{
@ -233,7 +251,7 @@ export default {
},
loadCompanyHoursEverybodyDestinations(context) {
return new Promise((resolve, reject)=>{
loadAlwaysDestinations({
loadEverybodyDestinations({
subscriberId: localStorage.getItem('subscriberId'),
timeset: 'Company Hours'
}).then((result)=>{
@ -241,6 +259,16 @@ export default {
})
});
},
loadAfterHoursEverybodyDestinations(context) {
return new Promise((resolve, reject)=>{
loadEverybodyDestinations({
subscriberId: localStorage.getItem('subscriberId'),
timeset: 'After Hours'
}).then((result)=>{
context.commit('loadAfterHoursEverybodyDestinations', result);
})
});
},
deleteDestinationFromDestinationset(context, options) {
let removedDestination = options.removeDestination;
context.commit('removeDestinationRequesting');

@ -51,9 +51,9 @@ describe('CallForward', function(){
CallForwardModule.mutations.resetFormState(state);
assert.deepEqual(state.form, data);
it('should load always company hours destinations', function(){
it('should load company hours everybody destinations', function(){
let state = {
alwaysCompanyHoursDestinations: [
companyHoursEverybodyDestinations: [
]
};
let data = {
@ -78,8 +78,39 @@ describe('CallForward', function(){
}],
online: []
};
CallForwardModule.mutations.loadAlwaysCompanyHoursDestinations(state, data);
assert.deepEqual(state.alwaysCompanyHoursDestinations, data);
CallForwardModule.mutations.loadCompanyHoursEverybodyDestinations(state, data);
assert.deepEqual(state.companyHoursEverybodyDestinations, data);
});
it('should load after hours everybody destinations', function(){
let state = {
afterHoursEverybodyDestinations: [
]
};
let data = {
busy: [],
offline: [{
destinations: [{
"announcement_id": null,
"destination": "sip:3333@192.168.178.23",
"priority": 1,
"simple_destination": "3333",
"timeout": 60
},
{
"announcement_id": null,
"destination": "sip:2222@192.168.178.23",
"priority": 1,
"simple_destination": "2222",
"timeout": 300
}],
id: 3,
name: "csc_destinationset_1"
}],
online: []
};
CallForwardModule.mutations.loadAfterHoursEverybodyDestinations(state, data);
assert.deepEqual(state.afterHoursEverybodyDestinations, data);
});
});

Loading…
Cancel
Save