TT#31803 Remove time from timeset

What has been done:
- TT#32221, CallForwarding: Implement UI icons and flow
- TT#32222, CallForwarding: Implement store and state management
- TT#31808, CallForwarding: Implement api requests

Change-Id: I0fd13e129ee006b7b08333df7a386de12710266a
changes/52/18852/12
raxelsen 7 years ago committed by Robert Axelsen
parent f345683357
commit 3a2f7bd30f

@ -380,8 +380,8 @@ export function moveDestinationDown(options) {
}
export function getDaysFromRange(options) {
let fromDay = options.from;
let toDay = options.to;
let fromDay = options.fromDay;
let toDay = options.toDay + 1;
let wdayMap = {
1: i18n.t('pages.callForward.times.sunday'),
2: i18n.t('pages.callForward.times.monday'),
@ -393,29 +393,31 @@ export function getDaysFromRange(options) {
};
let days = [];
while (fromDay < toDay) {
days.push({ name: wdayMap[fromDay], number: fromDay });
days.push({ name: wdayMap[fromDay], number: fromDay.toString() });
fromDay++;
};
return days;
}
export function getHoursFromRange(options) {
let toHour = options.toHour + 1;
let fromMinute = options.hasMinute ? options.fromMinute : '00';
let toMinute = options.hasMinute ? options.toMinute + 1 : '00';
toMinute = !toMinute ? fromMinute + 1 : toMinute;
let hours = [];
if (options.hasMinute) {
while (options.fromHour < options.toHour) {
while (options.fromHour < toHour) {
hours.push({
from: `${options.fromHour}:${fromMinute}`,
to: `${options.fromHour}:${toMinute}`
to: `${options.fromHour}:${toMinute}`,
hour: options.fromHour.toString()
});
options.fromHour++;
};
} else {
hours.push({
from: `${options.fromHour}:${fromMinute}`,
to: `${options.toHour}:${toMinute}`
to: `${toHour}:${toMinute}`
});
}
return hours;
@ -424,48 +426,54 @@ export function getHoursFromRange(options) {
export function convertTimesetToWeekdays(options) {
let times = [];
let counter = 0;
let timesetIsCompatible = false;
let timesetIsCompatible = true;
let timesetHasDuplicate = false;
let timesetExists = false;
let timesetHasReverse = false;
let timesetId = null;
options.timesets.forEach((timeset) => {
let timesetNameMatches = timeset.name === options.timesetName;
if (counter === 0 && timesetNameMatches) {
timeset.times.forEach((time) => {
let days = [];
let hours = [];
let fromDay = parseInt(time.wday.split('-')[0]);
let toDay = time.wday.split('-')[1] ? parseInt(time.wday.split('-')[1]) + 1 : fromDay + 1;
let fromHour = parseInt(time.hour.split('-')[0]);
let toHour = time.hour.split('-')[1] ? parseInt(time.hour.split('-')[1]) + 1 : fromHour + 1;
let fromMinute = time.minute ? parseInt(time.minute.split('-')[0]) : undefined;
let toMinute = (time.minute && time.minute.split('-')[1]) ? parseInt(time.minute.split('-')[1]) : undefined;
let isCompatible = time.mday || time.month || time.year || !time.wday || !time.hour;
let isReverse = fromDay > toDay || fromHour > toHour || fromMinute > toMinute;
if (isCompatible) {
let isIncompatible = time.mday || time.month || time.year || !time.wday || !time.hour;
if (isIncompatible) {
timesetIsCompatible = false;
return;
} else if (isReverse) {
timesetHasReverse = true;
return;
} else {
hours = getHoursFromRange({ hasMinute: !!time.minute,
fromHour: fromHour, toHour: toHour,
fromMinute: fromMinute, toMinute: toMinute });
days = getDaysFromRange({ from: fromDay, to: toDay });
days.forEach(day => {
hours.forEach(hour => {
times.push({
weekday: day.name,
from: hour.from,
to: hour.to,
wday: time.wday,
hour: time.hour,
minute: time.minute
} else {
let days = [];
let hours = [];
let fromDay = parseInt(time.wday.split('-')[0]);
let toDay = time.wday.split('-')[1] ? parseInt(time.wday.split('-')[1]) : fromDay;
let fromHour = parseInt(time.hour.split('-')[0]);
let toHour = time.hour.split('-')[1] ? parseInt(time.hour.split('-')[1]) : fromHour;
let fromMinute = time.minute ? parseInt(time.minute.split('-')[0]) : undefined;
let toMinute = (time.minute && time.minute.split('-')[1]) ? parseInt(time.minute.split('-')[1]) : undefined;
let isReverse = fromDay > toDay || fromHour > toHour || fromMinute > toMinute;
let timesHour;
if (isReverse) {
timesetHasReverse = true;
return;
} else {
hours = getHoursFromRange({ hasMinute: !!time.minute,
fromHour: fromHour, toHour: toHour,
fromMinute: fromMinute, toMinute: toMinute });
days = getDaysFromRange({ fromDay: fromDay, toDay: toDay });
days.forEach(day => {
hours.forEach(hour => {
timesHour = time.minute ? hour.hour : time.hour;
times.push({
weekday: day.name,
from: hour.from,
to: hour.to,
wday: day.number,
hour: timesHour,
minute: time.minute
});
});
});
});
timesetIsCompatible = true;
timesetId = timeset.id;
timesetIsCompatible = true;
}
}
});
timesetExists = true;
@ -480,7 +488,8 @@ export function convertTimesetToWeekdays(options) {
timesetIsCompatible: timesetIsCompatible,
timesetExists: timesetExists,
timesetHasReverse: timesetHasReverse,
timesetHasDuplicate: timesetHasDuplicate
timesetHasDuplicate: timesetHasDuplicate,
timesetId: timesetId
};
}
@ -498,3 +507,30 @@ export function loadTimesetTimes(options) {
});
});
}
export function deleteTimeFromTimeset(options) {
let headers = {
'Content-Type': 'application/json-patch+json'
};
return new Promise((resolve, reject) => {
Vue.http.patch('/api/cftimesets/' + options.timesetId, [{
op: 'replace',
path: '/times',
value: options.times
}], { headers: headers }).then((result) => {
resolve(result);
}).catch(err => {
reject(err);
});
});
}
export function deleteTimesetById(id) {
return new Promise((resolve, reject) => {
Vue.http.delete('/api/cftimesets/' + id).then(() => {
resolve();
}).catch(err => {
reject(err);
});
});
}

@ -1,6 +1,6 @@
<template>
<csc-page :title="$t('pages.callForward.titles.always')">
<csc-call-forward-destinations timeset="null" :destinations="destinations">
<csc-call-forward-destinations :timeset="alwaysTimeset" :destinations="destinations">
</csc-call-forward-destinations>
</csc-page>
</template>
@ -23,7 +23,10 @@
computed: {
...mapState('callForward', [
'destinations'
])
]),
alwaysTimeset() {
return null;
}
}
}
</script>

@ -5,31 +5,31 @@
<csc-call-forward-destinations timeset="Company Hours" :destinations="destinations">
</csc-call-forward-destinations>
</div>
<div v-else-if="timesetHasReverse && timesetExists">
<div v-else-if="timesetHasDuplicate && timesetExists">
<q-alert color="red"
icon="date_range"
enter="bounceInLeft"
leave="bounceOutRight"
appear>
{{ $t('pages.callForward.times.companyHoursReverse') }}
{{ $t('pages.callForward.times.companyHoursDuplicate') }}
</q-alert>
</div>
<div v-else-if="timesetHasDuplicate && timesetExists">
<div v-else-if="!timesetIsCompatible && timesetExists">
<q-alert color="red"
icon="date_range"
enter="bounceInLeft"
leave="bounceOutRight"
appear>
{{ $t('pages.callForward.times.companyHoursDuplicate') }}
{{ $t('pages.callForward.times.companyHoursIncompatible') }}
</q-alert>
</div>
<div v-else-if="!timesetIsCompatible && timesetExists">
<div v-else-if="timesetHasReverse && timesetExists">
<q-alert color="red"
icon="date_range"
enter="bounceInLeft"
leave="bounceOutRight"
appear>
{{ $t('pages.callForward.times.companyHoursIncompatible') }}
{{ $t('pages.callForward.times.companyHoursReverse') }}
</q-alert>
</div>
<div v-else>

@ -23,7 +23,7 @@
<script>
import numberFormat from '../../../filters/number-format'
import { mapState } from 'vuex'
import { mapState, mapGetters } from 'vuex'
import { startLoading, stopLoading,
showGlobalError, showToast } from '../../../helpers/ui'
import CscDestinations from './CscDestinations'
@ -52,18 +52,32 @@
addDestinationError(state) {
return state.addDestinationError ||
this.$t('pages.callForward.addErrorMessage');
},
removeTimeState: 'removeTimeState',
lastRemovedDay: 'lastRemovedDay',
removeTimeError(state) {
return state.removeTimeError ||
this.$t('pages.callForward.times.removeErrorMessage');
}
}),
...mapGetters('callForward', {
timesLength: 'getTimesetTimesLength'
})
},
methods: {
reload(timeset) {
if (!timeset) {
reloadDestinations(timeset) {
if (timeset === null) {
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');
};
},
reloadTimes(timeset) {
this.$store.dispatch('callForward/loadTimesetTimes', {
timeset: this.timeset
});
}
},
watch: {
@ -78,7 +92,7 @@
showToast(this.$t('pages.callForward.removeSuccessMessage', {
destination: this.lastRemovedDestination
}));
this.reload(this.timeset);
this.reloadDestinations(this.timeset);
}
},
addDestinationState(state) {
@ -92,7 +106,7 @@
showToast(this.$t('pages.callForward.addDestinationSuccessMessage', {
destination: this.lastAddedDestination
}));
this.reload(this.timeset);
this.reloadDestinations(this.timeset);
}
},
changeDestinationState(state) {
@ -103,7 +117,25 @@
showGlobalError(this.changeDestinationError);
} else if (state === 'succeeded') {
stopLoading();
this.reload(this.timeset);
this.reloadDestinations(this.timeset);
}
},
removeTimeState(state) {
if (state === 'requesting') {
startLoading();
} else if (state === 'failed') {
stopLoading();
showGlobalError(this.removeTimeError);
} else if (state === 'succeeded') {
stopLoading();
if (this.timesLength <= 1) {
showToast(this.$t('pages.callForward.times.removeTimesetSuccessMessage'));
} else {
showToast(this.$t('pages.callForward.times.removeSuccessMessage', {
day: this.lastRemovedDay
}));
}
this.reloadTimes(this.timeset);
}
}
}

@ -1,7 +1,7 @@
<template>
<q-field class="time-field">
<div class="row no-wrap">
<q-input class="col-8"
<q-input class="col-7"
v-model="weekday"
readonly />
<q-datetime
@ -20,16 +20,27 @@
type="time"
format24h
readonly />
<q-btn flat
class="col-1"
color="negative"
icon="delete"
@click="deleteTime(index)">
</q-btn>
</div>
</q-field>
</template>
<script>
import { QField, QInput, QDatetime, date } from 'quasar-framework'
import { QField, QInput, QDatetime, Dialog,
QBtn, Alert, date } from 'quasar-framework'
import { mapGetters } from 'vuex'
import 'quasar-extras/animate/bounceInRight.css'
import 'quasar-extras/animate/bounceOutRight.css'
export default {
name: 'csc-call-forward-time',
props: [
'time'
'time',
'index'
],
data () {
return {
@ -38,9 +49,14 @@
components: {
QField,
QInput,
QDatetime
QDatetime,
Dialog,
QBtn
},
computed: {
...mapGetters('callForward', {
timesLength: 'getTimesetTimesLength'
}),
weekday() {
return this.time.weekday;
},
@ -56,6 +72,52 @@
minutes: this.time.to.split(':')[1]
});
}
},
methods: {
deleteTime(index) {
let self = this;
let store = this.$store;
if (this.timesLength <= 1) {
Alert.create({
enter: 'bounceInRight',
leave: 'bounceOutRight',
position: 'top-center',
html: self.$t('pages.callForward.times.removeLastDialogText'),
icon: 'warning',
actions: [
{
label: self.$t('buttons.remove'),
handler () {
store.dispatch('callForward/deleteTimesetById')
}
},
{
label: self.$t('buttons.cancel')
}
]
});
} else {
Dialog.create({
title: self.$t('pages.callForward.times.removeDialogTitle'),
message: self.$t('pages.callForward.times.removeDialogText', {
day: self.weekday
}),
buttons: [
self.$t('buttons.cancel'),
{
label: self.$t('buttons.remove'),
color: 'negative',
handler () {
store.dispatch('callForward/deleteTimeFromTimeset', {
index: index,
removedDay: self.weekday
})
}
}
]
});
}
}
}
}
</script>

@ -4,12 +4,7 @@
Times
</q-card-title>
<q-card-main>
<div class="row no-wrap">
<p class="col-8 ">{{ $t('pages.callForward.times.weekday') }}</p>
<p class="col-2 hour-label">{{ $t('pages.callForward.times.from') }}</p>
<p class="col-2 hour-label">{{ $t('pages.callForward.times.to') }}</p</p>
</div>
<csc-call-forward-time v-if="times.length > 0" v-for="(time, index) in times" :time="time">
<csc-call-forward-time v-if="times.length > 0" v-for="(time, index) in times" :time="time" :index="index">
</csc-call-forward-time>
</q-card-main>
<q-card-actions>
@ -26,13 +21,13 @@
<script>
import numberFormat from '../../../filters/number-format'
import CscCallForwardTime from './CscCallForwardTime'
import { mapState } from 'vuex'
import { QCard, QCardTitle, QCardMain, QCardActions,
QField, QBtn } from 'quasar-framework'
export default {
name: 'csc-call-forward-times',
props: [
'times'
'times',
'timeset'
],
data () {
return {
@ -63,7 +58,7 @@
padding-left 5px
padding-bottom 8px
.times-card
padding 0 15px
padding 0 15px
.q-field
margin 5px 0
.q-card-actions
@ -79,5 +74,5 @@
color $secondary
margin-bottom 0
.hour-label
text-align right
text-align center
</style>

@ -56,8 +56,8 @@
import numberFormat from '../../../filters/number-format'
import _ from 'lodash'
import { startLoading, stopLoading,
showGlobalError, showToast } from '../../../helpers/ui'
import { QItem, QItemMain, QItemSide, Toast,
showGlobalError } from '../../../helpers/ui'
import { QItem, QItemMain, QItemSide,
Dialog, QBtn } from 'quasar-framework'
export default {
name: 'csc-destination',
@ -72,7 +72,6 @@
QItemMain,
QItemSide,
Dialog,
Toast,
QBtn
},
computed: {

@ -151,6 +151,13 @@
"timeout": "Timeout",
"destination": "Destination",
"times": {
"removeDialogTitle": "Remove call forward time",
"removeDialogText": "You are about to remove the time entry for {day}",
"removeLastDialogTitle": "Remove last call forward time",
"removeLastDialogText": "WARNING: Removing the last time entry will also delete this timeset and all corresponding destinations. Are you sure you want to do this?",
"removeSuccessMessage": "Removed time entry for {day}",
"removeErrorMessage": "An error occured while trying to delete the time entry. Please try again.",
"removeTimesetSuccessMessage": "Removed timeset",
"noTimeSet": "no time set",
"addTimeButton": "Add Time",
"companyHoursIncompatible": "The Company Hours timeset contains incompatible values.",

@ -14,7 +14,9 @@ import { getSourcesets,
changePositionOfDestination,
moveDestinationUp,
moveDestinationDown,
loadTimesetTimes } from '../api/call-forward';
loadTimesetTimes,
deleteTimeFromTimeset,
deleteTimesetById } from '../api/call-forward';
const DestinationState = {
button: 'button',
@ -43,6 +45,9 @@ export default {
lastAddedDestination: null,
changeDestinationState: DestinationState.button,
changeDestinationError: null,
removeTimeState: DestinationState.button,
removeTimeError: null,
lastRemovedDay: null,
activeForm: '',
formType: '',
destinationsetId: '',
@ -54,10 +59,11 @@ export default {
timeout: ''
},
timesetTimes: [],
timesetIsCompatible: false,
timesetIsCompatible: true,
timesetExists: true,
timesetHasReverse: false,
timesetHasDuplicate: false
timesetHasDuplicate: false,
timesetId: null
},
getters: {
hasFaxCapability(state, getters, rootState, rootGetters) {
@ -79,15 +85,13 @@ export default {
return state.destinationsetId;
},
getTimesetId(state) {
let timeset;
for (let group in state.destinations) {
if (!timeset) {
timeset = _.find(state.destinations[group], (o) => {
return o.timesetId > 0;
});
};
};
return timeset ? timeset.timesetId : null;
return state.timesetId;
},
getTimesetTimes(state) {
return state.timesetTimes;
},
getTimesetTimesLength(state) {
return state.timesetTimes.length;
}
},
mutations: {
@ -177,20 +181,28 @@ export default {
state.removeDestinationState = DestinationState.failed;
state.removeDestinationError = error;
},
loadTimesetTimes(state, result) {
state.timesetTimes = result;
removeTimeRequesting(state) {
state.removeTimeState = DestinationState.requesting;
state.removeTimeError = null;
},
setTimesetIsCompatible(state, value) {
state.timesetIsCompatible = value;
removeTimeSucceeded(state) {
state.removeTimeState = DestinationState.succeeded;
state.removeTimeError = null;
},
setTimesetExists(state, value) {
state.timesetExists = value;
removeTimeFailed(state, error) {
state.removeTimeState = DestinationState.failed;
state.removeTimeError = error;
},
setTimesetHasReverse(state, value) {
state.timesetHasReverse = value;
setLastRemovedDay(state, value) {
state.lastRemovedDay = value;
},
setTimesetHasDuplicate(state, value) {
state.timesetHasDuplicate = value;
loadTimesSucceeded(state, result) {
state.timesetTimes = result.times;
state.timesetIsCompatible = result.timesetIsCompatible;
state.timesetExists = result.timesetExists;
state.timesetHasReverse = result.timesetHasReverse;
state.timesetHasDuplicate = result.timesetHasDuplicate;
state.timesetId = result.timesetId;
}
},
actions: {
@ -412,11 +424,40 @@ export default {
timeset: options.timeset,
subscriberId: context.getters.getSubscriberId
}).then((result) => {
context.commit('loadTimesetTimes', result.times);
context.commit('setTimesetIsCompatible', result.timesetIsCompatible);
context.commit('setTimesetExists', result.timesetExists);
context.commit('setTimesetHasReverse', result.timesetHasReverse);
context.commit('setTimesetHasDuplicate', result.timesetHasDuplicate);
context.commit('loadTimesSucceeded', result);
});
},
deleteTimeFromTimeset(context, options) {
context.commit('removeTimeRequesting');
let clonedTimes = _.cloneDeep(context.getters.getTimesetTimes);
let indexInt = parseInt(options.index);
clonedTimes.splice(indexInt, 1);
clonedTimes.forEach((time) => {
delete time.weekday;
delete time.from;
delete time.to;
});
return new Promise((resolve, reject) => {
deleteTimeFromTimeset({
subscriberId: context.getters.getSubscriberId,
timesetId: context.getters.getTimesetId,
times: clonedTimes
}).then(() => {
context.commit('setLastRemovedDay', options.removedDay);
context.commit('removeTimeSucceeded');
}).catch((err) => {
context.commit('removeTimeFailed', err.message);
});
});
},
deleteTimesetById(context, options) {
context.commit('removeTimeRequesting');
return new Promise((resolve, reject) => {
deleteTimesetById(context.getters.getTimesetId).then(() => {
context.commit('removeTimeSucceeded');
}).catch((err) => {
context.commit('removeTimeFailed', err.message);
});
});
}
}

@ -9,16 +9,17 @@ import { getMappings, getSourcesets, getTimesets,
addDestinationToDestinationset,
convertTimesetToWeekdays,
getHoursFromRange,
getDaysFromRange } from '../../src/api/call-forward';
getDaysFromRange,
deleteTimeFromTimeset } from '../../src/api/call-forward';
import { assert } from 'chai';
Vue.use(VueResource);
describe('CallForward', function(){
describe('CallForward', function() {
const subscriberId = 123;
it('should get all call forward mappings', function(done){
it('should get all call forward mappings', function(done) {
let data = {
"cfb": [{
@ -52,20 +53,20 @@ describe('CallForward', function(){
};
Vue.http.interceptors = [];
Vue.http.interceptors.unshift((request, next)=>{
Vue.http.interceptors.unshift((request, next) => {
next(request.respondWith(JSON.stringify(data), {
status: 200
}));
});
getMappings(subscriberId).then((result)=>{
getMappings(subscriberId).then((result) => {
assert.deepEqual(result, data);
done();
}).catch((err)=>{
}).catch((err) => {
done(err);
});
});
it('should get all call forward sourcesets', function(done){
it('should get all call forward sourcesets', function(done) {
let innerData = [{
"_links": {
@ -103,20 +104,20 @@ describe('CallForward', function(){
};
Vue.http.interceptors = [];
Vue.http.interceptors.unshift((request, next)=>{
Vue.http.interceptors.unshift((request, next) => {
next(request.respondWith(JSON.stringify(data), {
status: 200
}));
});
getSourcesets(subscriberId).then((result)=>{
getSourcesets(subscriberId).then((result) => {
assert.deepEqual(result, innerData);
done();
}).catch((err)=>{
}).catch((err) => {
done(err);
});
});
it('should get all call forward timesets', function(done){
it('should get all call forward timesets', function(done) {
let innerData = [{
"_links": {
@ -164,20 +165,20 @@ describe('CallForward', function(){
};
Vue.http.interceptors = [];
Vue.http.interceptors.unshift((request, next)=>{
Vue.http.interceptors.unshift((request, next) => {
next(request.respondWith(JSON.stringify(data), {
status: 200
}));
});
getTimesets(subscriberId).then((result)=>{
getTimesets(subscriberId).then((result) => {
assert.deepEqual(result, innerData);
done();
}).catch((err)=>{
}).catch((err) => {
done(err);
});
});
it('should get all call forward destinationsets', function(done){
it('should get all call forward destinationsets', function(done) {
let innerData = [{
"_links": {
@ -221,20 +222,20 @@ describe('CallForward', function(){
};
Vue.http.interceptors = [];
Vue.http.interceptors.unshift((request, next)=>{
Vue.http.interceptors.unshift((request, next) => {
next(request.respondWith(JSON.stringify(data), {
status: 200
}));
});
getDestinationsets(subscriberId).then((result)=>{
getDestinationsets(subscriberId).then((result) => {
assert.deepEqual(result, innerData);
done();
}).catch((err)=>{
}).catch((err) => {
done(err);
});
});
it('should get all call forward destinationset by id', function(done){
it('should get all call forward destinationset by id', function(done) {
let data = {
"_links": {
@ -322,20 +323,20 @@ describe('CallForward', function(){
};
Vue.http.interceptors = [];
Vue.http.interceptors.unshift((request, next)=>{
Vue.http.interceptors.unshift((request, next) => {
next(request.respondWith(JSON.stringify(data), {
status: 200
}));
});
getDestinationsetById('3').then((result)=>{
getDestinationsetById('3').then((result) => {
assert.deepEqual(result, responseData);
done();
}).catch((err)=>{
}).catch((err) => {
done(err);
});
});
it('should delete destination from call forward destinationset', function(done){
it('should delete destination from call forward destinationset', function(done) {
let options = {
id: 3,
@ -355,15 +356,15 @@ describe('CallForward', function(){
status: 204
}));
});
deleteDestinationFromDestinationset(options).then((result)=>{
deleteDestinationFromDestinationset(options).then((result) => {
assert.isOk(result);
done();
}).catch((err)=>{
}).catch((err) => {
done(err);
});
});
it('should add destination to call forward destinationset', function(done){
it('should add destination to call forward destinationset', function(done) {
let options = {
id: 3,
@ -375,16 +376,43 @@ describe('CallForward', function(){
}
};
Vue.http.interceptors = [];
Vue.http.interceptors.unshift((request, next) => {
next(request.respondWith(JSON.stringify({}), {
status: 204
}));
});
addDestinationToDestinationset(options).then((result) => {
assert.isOk(result);
done();
}).catch((err) => {
done(err);
});
});
it('should delete time entry from call forward timeset', function(done) {
let options = {
timesetId: 3,
times: {
"weekday": "1",
"wday": "Monday",
"hour": "8-16",
"from": "8",
"to": "16"
}
};
Vue.http.interceptors = [];
Vue.http.interceptors.unshift((request, next)=>{
next(request.respondWith(JSON.stringify({}), {
status: 204
}));
});
addDestinationToDestinationset(options).then((result)=>{
deleteTimeFromTimeset(options).then((result) => {
assert.isOk(result);
done();
}).catch((err)=>{
}).catch((err) => {
done(err);
});
});
@ -414,7 +442,7 @@ describe('CallForward', function(){
hour: "6-8",
minute: null,
to: "9:00",
wday: "1-2",
wday: "1",
weekday: "Sunday"
},
{
@ -422,14 +450,15 @@ describe('CallForward', function(){
hour: "6-8",
minute: null,
to: "9:00",
wday: "1-2",
wday: "2",
weekday: "Monday"
}
],
timesetIsCompatible: true,
timesetExists: true,
timesetHasDuplicate: false,
timesetHasReverse: false,
timesetIsCompatible: true
timesetHasDuplicate: false,
timesetId: 1
};
assert.deepEqual(convertTimesetToWeekdays(options), convertedData);
@ -458,57 +487,58 @@ describe('CallForward', function(){
times: [
{
from: "6:0",
hour: "6-8",
hour: "6",
minute: "0-30",
to: "6:31",
wday: "1-2",
wday: "1",
weekday: "Sunday"
},
{
from: "7:0",
hour: "6-8",
hour: "7",
minute: "0-30",
to: "7:31",
wday: "1-2",
wday: "1",
weekday: "Sunday"
},
{
from: "8:0",
hour: "6-8",
hour: "8",
minute: "0-30",
to: "8:31",
wday: "1-2",
wday: "1",
weekday: "Sunday"
},
{
from: "6:0",
hour: "6-8",
hour: "6",
minute: "0-30",
to: "6:31",
wday: "1-2",
wday: "2",
weekday: "Monday"
},
{
from: "7:0",
hour: "6-8",
hour: "7",
minute: "0-30",
to: "7:31",
wday: "1-2",
wday: "2",
weekday: "Monday"
},
{
from: "8:0",
hour: "6-8",
hour: "8",
minute: "0-30",
to: "8:31",
wday: "1-2",
wday: "2",
weekday: "Monday"
}
],
timesetIsCompatible: true,
timesetExists: true,
timesetHasDuplicate: false,
timesetHasReverse: false,
timesetIsCompatible: true
timesetHasDuplicate: false,
timesetId: 1
};
assert.deepEqual(convertTimesetToWeekdays(options), convertedData);
@ -547,7 +577,8 @@ describe('CallForward', function(){
timesetExists: true,
timesetHasDuplicate: false,
timesetHasReverse: false,
timesetIsCompatible: true
timesetIsCompatible: true,
timesetId: 1
};
assert.deepEqual(convertTimesetToWeekdays(options), convertedData);

@ -44,13 +44,20 @@ describe('CallForward', function(){
let state = {
timesetTimes: []
};
let data = [
{ weekday: "Monday", from: "8", to: "16" },
{ weekday: "Tuesday", from: "8", to: "16" },
{ weekday: "Wednesday", from: "8", to: "16" }
]
CallForwardModule.mutations.loadTimesetTimes(state, data);
assert.equal(state.timesetTimes, data);
let result = {
times: [
{ weekday: "Monday", from: "8", to: "16" },
{ weekday: "Tuesday", from: "8", to: "16" },
{ weekday: "Wednesday", from: "8", to: "16" }
],
timesetIsCompatible: null,
timesetExists: null,
timesetHasReverse: null,
timesetHasDuplicate: null,
timesetId: null
}
CallForwardModule.mutations.loadTimesSucceeded(state, result);
assert.equal(state.timesetTimes, result.times);
});
});

Loading…
Cancel
Save