TT#82507 CF: As a Customer, I want to add condition "... and weekdays are" to forwarding groups

AC:
√ Can choose "weekdays are ..." from condition menu in each forwarding group (online, offline, busy)
√ Can click "weekdays are ..." to choose the weekdays initially
√ Can see a date weekday widget according to the screens
√ Can choose weekdays
√ Can save the chosen weekdays
√ Can cancel the process
√ Can see the changed title "... and weekdays are Monday, Friday" after saving
√ Can click the changed title to change weekdays again
√ Can remove the condition

Extra:
√ Fix conditions menu UX bugs
√ Fix conditions popover position

Change-Id: I8a5a465765b5ce204fd47c1880164f91c03b4622
mr9.0.1
Carlo Venusino 5 years ago
parent 04b4660396
commit 8a0527d54a

@ -305,7 +305,6 @@ export function updateDestinationsetName(options) {
} }
export function addDestinationToDestinationset(options) { export function addDestinationToDestinationset(options) {
return patchReplaceFull({ return patchReplaceFull({
path: 'api/cfdestinationsets/' + options.id, path: 'api/cfdestinationsets/' + options.id,
fieldPath: 'destinations', fieldPath: 'destinations',

@ -1,4 +1,5 @@
<template> <template
>
<div <div
class="csc-cf-group" class="csc-cf-group"
v-if="group.destinations.length > 0" v-if="group.destinations.length > 0"
@ -11,30 +12,6 @@
class="col col-xs-12 col-md-4 text-right csc-cf-group-title-bold" class="col col-xs-12 col-md-4 text-right csc-cf-group-title-bold"
> >
{{groupTitle}} {{groupTitle}}
<span
class="csc-cf-destination-add-condition"
v-if="isTempGroup"
>
{{ $t('pages.newCallForward.conditionBtnLabelPrefix') }}
<span class="csc-cf-from-link">
{{ $t('pages.newCallForward.conditionBtnLabel') }}
</span>
<q-popover
ref="conditions"
@open="showConditions()"
@close="showFirstDestMenu()"
>
<csc-new-call-forward-condition-type-select
ref="addCondition"
:disableSourcesetMenu="false"
:disableTimesetMenu="false"
:disableDateRangeMenu="false"
:enabled="true"
:groupName="group.name"
:groupId="group.id"
/>
</q-popover>
</span>
<span <span
v-if="groupSourceset" v-if="groupSourceset"
> >
@ -66,6 +43,7 @@
</span> </span>
<q-popover <q-popover
ref="day" ref="day"
class="csc-cf-popover-top-valign"
@open="showQDate()" @open="showQDate()"
> >
<q-datetime <q-datetime
@ -94,59 +72,17 @@
<q-popover <q-popover
ref="daterange" ref="daterange"
class="csc-cf-calendar-day" class="csc-cf-calendar-day"
enabled="enabled" @open="showDateRange()"
>
<q-field
label="Date range"
:labelWidth="11"
class="csc-cf-popover-daterange-title"
/>
<q-field
dark
:helper="$t('pages.newCallForward.dateRangeDateHelper')"
>
<q-datetime-range
ref="dayRangeWidget"
type="date"
no-clear
v-model="rangeDateModel"
:min="today"
@change="rangeDateChanged()"
format="DD/MM/YYYY"
:after="[
{
icon: 'today'
}
]"
/>
</q-field>
<q-field
dark
:helper="$t('pages.newCallForward.dateRangeTimeHelper')"
> >
<q-datetime-range <csc-new-call-forward-date-range
ref="dayRangeWidget" ref="dateRangePopover"
type="time" :groupName="group.name"
no-clear :groupId="group.id"
v-model="rangeTimeModel" :groupTimeRange="groupTimeRangeObj"
@change="rangeTimeChanged()" @open-daterange-popover="rangeChanged()"
:after="[ @confirm-delete="showConfirmDeleteTimesetDialog()"
{
icon: 'access_time'
}
]"
/> />
</q-field>
<div
class="csc-cf-daterange-btn-cont"
>
<q-btn
flat
color="red"
icon="delete"
@mousedown.native="showRemoveDateRangeDialog()"
>
{{ $t('buttons.remove') }}
<csc-confirm-dialog <csc-confirm-dialog
ref="confirmDeleteTimesetDialog" ref="confirmDeleteTimesetDialog"
title-icon="delete" title-icon="delete"
@ -154,30 +90,33 @@
:message="$t('pages.newCallForward.cancelTimesetText', {name: this.groupTimeRange})" :message="$t('pages.newCallForward.cancelTimesetText', {name: this.groupTimeRange})"
@confirm="deleteTimeset" @confirm="deleteTimeset"
/> />
</q-btn> </q-popover>
<q-btn </span>
flat <span
color="default" v-if="isWeekdays"
icon="clear"
@mousedown.native="cancelTimerange()"
> >
{{ $t('buttons.cancel') }} {{ $t('pages.newCallForward.conditionBtnLabelPrefix') }}
</q-btn> <span class="csc-cf-from-link" ref="isWeekdayLink">
<q-btn {{ weekdaysLabelShort + groupWeekdays }}
flat </span>
color="primary" <q-popover
icon="done" ref="weekdayEditPanel"
@click="saveDateRange();" class="csc-cf-number-form"
:disable="!allFieldsFilled" @open="showWeekdayEditForm()"
> >
{{ $t('buttons.save') }} <csc-new-call-forward-add-weekday-form
</q-btn> ref="weekdayEditForm"
</div> :days="times"
:id="timeSet.id"
:enabled="true"
:groupName="group.name"
:groupId="group.id"
/>
</q-popover> </q-popover>
</span> </span>
<span <span
class="csc-cf-destination-add-condition" class="csc-cf-destination-add-condition"
v-if="!isTempGroup && !(groupSourceset && groupTimeset)" v-if="isTempGroup || (!isTempGroup && !(groupSourceset && groupTimeset || groupSourceset && isWeekdays || groupTimeset && isWeekdays ))"
> >
{{ $t('pages.newCallForward.conditionBtnLabelPrefix') }} {{ $t('pages.newCallForward.conditionBtnLabelPrefix') }}
<span class="csc-cf-from-link"> <span class="csc-cf-from-link">
@ -190,20 +129,22 @@
> >
<csc-new-call-forward-condition-type-select <csc-new-call-forward-condition-type-select
ref="addCondition" ref="addCondition"
:disableSourcesetMenu="!groupSourceset" :disableSourcesetMenu="isTempGroup || !groupSourceset"
:disableTimesetMenu="!groupTimeset" :disableTimesetMenu="isTempGroup || !groupTimeset && !isRange && !isWeekdays"
:disableDateRangeMenu="!groupTimeset" :disableDateRangeMenu="isTempGroup || !groupTimeset && !isRange && !isWeekdays"
:disableWeekdaysMenu="isTempGroup || !groupTimeset && !isRange && !isWeekdays"
:enabled="true" :enabled="true"
:groupName="group.name" :groupName="group.name"
:groupId="group.id" :groupId="group.id"
/> />
</q-popover> </q-popover>
<span>
<q-popover <q-popover
ref="onlineSourceset" ref="onlineSourceset"
class="csc-cf-number-form" class="csc-cf-number-form csc-cf-popover-left-align"
v-bind:class="{ 'csc-cf-popover-hide': toggleConditionFromForm}" v-bind:class="{ 'csc-cf-popover-hide': toggleConditionFromForm}"
@open="showSourcesetForm()" @open="showSourcesetForm()"
@close="resetToggleCondition()" @close="resetToggleCondition(); resetAction()"
> >
<csc-new-call-forward-add-sourceset-form <csc-new-call-forward-add-sourceset-form
ref="addSourceSet" ref="addSourceSet"
@ -213,7 +154,57 @@
/> />
</q-popover> </q-popover>
</span> </span>
<span>
<q-popover
ref="day"
class="csc-cf-popover-left-align csc-cf-popover-top-valign"
@open="showQDate()"
@close="resetAction()"
v-bind:class="{ 'csc-cf-popover-hide': toggleIsDatePanel}"
>
<q-datetime
ref="dayWidget"
anchor="bottom right"
no-clear
v-model="dayModel"
:min="today"
/>
</q-popover>
</span>
<span>
<q-popover
ref="daterange"
class="csc-cf-popover-left-align csc-cf-calendar-day"
v-bind:class="{ 'csc-cf-popover-hide': toggleIsRangePanel}"
@open="showDateRange()"
@close="resetAction()"
>
<csc-new-call-forward-date-range
ref="dateRangePopover"
:groupName="group.name"
:groupId="group.id"
:noClear="true"
@open-daterange-popover="rangeChanged()"
/>
</q-popover>
</span>
<span>
<q-popover
ref="weekdayPanel"
class="csc-cf-number-form csc-cf-popover-left-align"
v-bind:class="{ 'csc-cf-popover-hide': toggleWeekdayPanel}"
@open="showWeekdayPanel()"
@close="resetWeekdayCondition(); resetAction()"
>
<csc-new-call-forward-add-weekday-form
ref="weekdayForm"
:enabled="true"
:groupName="group.name"
:groupId="group.id"
/>
</q-popover>
</span>
</span>
</div> </div>
<div class="col text-left col-xs-12 col-md-2 csc-cf-dest-number-cont"> <div class="col text-left col-xs-12 col-md-2 csc-cf-dest-number-cont">
<q-toggle <q-toggle
@ -333,6 +324,8 @@
<script> <script>
// import _ from 'lodash'
import moment from 'moment' import moment from 'moment'
import { import {
@ -360,8 +353,10 @@
import CscNewCallForwardAddDestinationForm from './CscNewCallForwardAddDestinationForm' import CscNewCallForwardAddDestinationForm from './CscNewCallForwardAddDestinationForm'
import CscNewCallForwardEditSources from './CscNewCallForwardEditSources' import CscNewCallForwardEditSources from './CscNewCallForwardEditSources'
import CscNewCallForwardAddSourcesetForm from './CscNewCallForwardAddSourcesetForm' import CscNewCallForwardAddSourcesetForm from './CscNewCallForwardAddSourcesetForm'
import CscNewCallForwardAddWeekdayForm from './CscNewCallForwardAddWeekdayForm'
import CscNewCallForwardConditionTypeSelect from './CscNewCallForwardConditionTypeSelect' import CscNewCallForwardConditionTypeSelect from './CscNewCallForwardConditionTypeSelect'
import CscNewCallForwardDestinationTypeForm from './CscNewCallForwardDestinationTypeForm' import CscNewCallForwardDestinationTypeForm from './CscNewCallForwardDestinationTypeForm'
import CscNewCallForwardDateRange from './CscNewCallForwardDateRange'
export default { export default {
name: 'csc-cf-group', name: 'csc-cf-group',
props: [ props: [
@ -387,15 +382,21 @@
CscNewCallForwardAddDestinationForm, CscNewCallForwardAddDestinationForm,
CscNewCallForwardEditSources, CscNewCallForwardEditSources,
CscNewCallForwardAddSourcesetForm, CscNewCallForwardAddSourcesetForm,
CscNewCallForwardAddWeekdayForm,
CscNewCallForwardConditionTypeSelect, CscNewCallForwardConditionTypeSelect,
CscNewCallForwardDestinationTypeForm CscNewCallForwardDestinationTypeForm,
CscNewCallForwardDateRange
}, },
data () { data () {
return { return {
firstDestinationInCreation: false,
toggleGroup: true, toggleGroup: true,
isEnabled: true, isEnabled: true,
toggleNumberForm: true, toggleNumberForm: true,
toggleConditionFromForm: true, toggleConditionFromForm: true,
toggleWeekdayPanel: true,
toggleIsDatePanel: true,
toggleIsRangePanel: true,
groupIsLoading: false, groupIsLoading: false,
sourceSet: null, sourceSet: null,
sources: [], sources: [],
@ -404,16 +405,7 @@
action: null, action: null,
enabled: false, enabled: false,
day: null, day: null,
rangeDateModel: { today: new Date()
from: null,
to: null
},
rangeTimeModel: {
from: null,
to: null
},
today: new Date(),
firstDestinationInCreation: false
}; };
}, },
async mounted(){ async mounted(){
@ -441,12 +433,6 @@
'getTimesets', 'getTimesets',
'getFirstDestinationInCreation' 'getFirstDestinationInCreation'
]), ]),
allFieldsFilled(){
return this.rangeDateModel.from !== null &&
this.rangeDateModel.to !== null &&
this.rangeTimeModel.from !== null &&
this.rangeTimeModel.to !== null;
},
showAddDestBtn(){ showAddDestBtn(){
const destinations = this.group.destinations; const destinations = this.group.destinations;
for(let dest of destinations){ for(let dest of destinations){
@ -484,9 +470,11 @@
let retVal = false, dateN, time; let retVal = false, dateN, time;
if(this.timeSet && this.timeSet.times && this.timeSet.times.length > 0){ if(this.timeSet && this.timeSet.times && this.timeSet.times.length > 0){
time = this.timeSet.times[0]; time = this.timeSet.times[0];
if(time.year && time.month && time.mday){
dateN = new Date(parseInt(time.year), parseInt(time.month) - 1 , parseInt(time.mday), 0, 0, 0, 0); dateN = new Date(parseInt(time.year), parseInt(time.month) - 1 , parseInt(time.mday), 0, 0, 0, 0);
retVal = date.formatDate( dateN, 'ddd, MMM D YYYY') retVal = date.formatDate( dateN, 'ddd, MMM D YYYY')
} }
}
return retVal; return retVal;
}, },
groupTimeRange(){ groupTimeRange(){
@ -499,6 +487,23 @@
} }
return retVal; return retVal;
}, },
groupTimeRangeObj(){
let retVal = false, time;
if(this.timeSet && this.timeSet.times && this.timeSet.times.length > 0){
time = this.timeSet.times[0];
// this.rangeDateModel.from = moment(new Date(parseInt(time.year.split('-')[0]),parseInt(time.month.split('-')[0])-1,parseInt(time.mday.split('-')[0]),parseInt(time.hour.split('-')[0]),parseInt(time.minute.split('-')[0]),0,0)).format();
// this.rangeDateModel.to = moment(new Date(parseInt(time.year.split('-')[1]),parseInt(time.month.split('-')[1])-1,parseInt(time.mday.split('-')[1]),parseInt(time.hour.split('-')[1]),parseInt(time.minute.split('-')[1]),0,0)).format();
// this.rangeTimeModel.from = moment(new Date(parseInt(time.year.split('-')[0]),parseInt(time.month.split('-')[0])-1,parseInt(time.mday.split('-')[0]),parseInt(time.hour.split('-')[0]),parseInt(time.minute.split('-')[0]),0,0)).format();
// this.rangeTimeModel.to = moment(new Date(parseInt(time.year.split('-')[1]),parseInt(time.month.split('-')[1])-1,parseInt(time.mday.split('-')[1]),parseInt(time.hour.split('-')[1]),parseInt(time.minute.split('-')[1]),0,0)).format();
retVal = {
dateFrom: moment(new Date(parseInt(time.year.split('-')[0]),parseInt(time.month.split('-')[0])-1,parseInt(time.mday.split('-')[0]),parseInt(time.hour.split('-')[0]),parseInt(time.minute.split('-')[0]),0,0)).format(),
dateTo: moment(new Date(parseInt(time.year.split('-')[1]),parseInt(time.month.split('-')[1])-1,parseInt(time.mday.split('-')[1]),parseInt(time.hour.split('-')[1]),parseInt(time.minute.split('-')[1]),0,0)).format(),
}
}
return retVal;
},
isRange(){ isRange(){
const isRange = this.timeSet const isRange = this.timeSet
&& this.timeSet.times && this.timeSet.times
@ -507,6 +512,51 @@
&& this.timeSet.times[0].year.includes('-'); && this.timeSet.times[0].year.includes('-');
return isRange; return isRange;
}, },
weekdaysLabelShort(){
return this.timeSet.times.length > 1
? `${this.$t('pages.newCallForward.weekdaysLabelShort')}`
: `${this.$t('pages.newCallForward.weekdayLabelShort')}`;
},
groupWeekdays(){
let retVal = '', times = this.timeSet.times.sort((a,b) => (parseInt(a.wday) > parseInt(b.wday)) ? 1 : ((parseInt(b.wday) > parseInt(a.wday)) ? -1 : 0));
times.forEach((time, index) => {
const separator = (index === times.length - 1) ? '': ', ';
switch(time.wday){
case '2':
retVal += `${this.$t('pages.callForward.times.monday')}`
break;
case '3':
retVal += `${this.$t('pages.callForward.times.tuesday')}`
break;
case '4':
retVal += `${this.$t('pages.callForward.times.wednesday')}`
break;
case '5':
retVal += `${this.$t('pages.callForward.times.thursday')}`
break;
case '6':
retVal += `${this.$t('pages.callForward.times.friday')}`
break;
case '7':
retVal += `${this.$t('pages.callForward.times.saturday')}`
break;
case '1':
retVal += `${this.$t('pages.callForward.times.sunday')}`
break;
}
retVal += separator;
})
return retVal;
},
isWeekdays(){
const isWeekdays = this.timeSet
&& this.timeSet.times
&& this.timeSet.times.length > 0
&& this.timeSet.times[0].wday
&& this.timeSet.times[0].wday > 0;
return isWeekdays;
},
isTempGroup(){ isTempGroup(){
return this.group.id.toString().includes('temp-'); return this.group.id.toString().includes('temp-');
}, },
@ -521,6 +571,9 @@
}, },
dayModel: { dayModel: {
get() { get() {
if(!this.timeSet){
return;
}
let time = this.timeSet.times[0]; let time = this.timeSet.times[0];
let dateN = new Date(parseInt(time.year), parseInt(time.month) - 1 , parseInt(time.mday), 0, 0, 0, 0); let dateN = new Date(parseInt(time.year), parseInt(time.month) - 1 , parseInt(time.mday), 0, 0, 0, 0);
return dateN; return dateN;
@ -547,8 +600,7 @@
this.groupIsLoading = groupLoaders.includes(this.group.id); this.groupIsLoading = groupLoaders.includes(this.group.id);
}, },
getFirstDestinationInCreation: function(){ getFirstDestinationInCreation: function(){
if(this.getFirstDestinationInCreation === this.group.id.toString()){ if(this.getFirstDestinationInCreation === this.group.id.toString() && this.$refs.conditions){
this.toggleConditionFromForm = false;
this.$refs.conditions.open(); this.$refs.conditions.open();
} }
} }
@ -588,6 +640,10 @@
firstDestinationCmp.$refs.destTypeForm.open(); firstDestinationCmp.$refs.destTypeForm.open();
}, },
showConditionForm(){ showConditionForm(){
if(this.isTempGroup){
this.showFirstDestMenu();
return;
}
const action = this.$refs.addCondition.action; const action = this.$refs.addCondition.action;
switch(action){ switch(action){
case "addFromCondition": case "addFromCondition":
@ -595,15 +651,26 @@
this.$refs.onlineSourceset.open(); this.$refs.onlineSourceset.open();
break; break;
case "addDateIsCondition": case "addDateIsCondition":
this.toggleIsDatePanel = false;
this.$refs.day.open();
break;
case "addDateRangeCondition":
this.toggleIsRangePanel = false;
this.$refs.daterange.open();
break;
case "addWeekdayCondition":
this.toggleWeekdayPanel = false;
this.$refs.weekdayPanel.open();
break; break;
} }
}, },
showDestTypeForm(){ showDestTypeForm(){
this.toggleNumberForm = true; this.toggleNumberForm = true;
this.$refs.selectDestinationType.add(); this.$refs.selectDestinationType.add();
}, },
showWeekdayEditForm(){
this.$refs.weekdayEditForm.add();
},
getDestName(index){ getDestName(index){
return "destination" + index; return "destination" + index;
}, },
@ -626,19 +693,30 @@
}); });
this.$store.dispatch('newCallForward/removeGroupLoader', this.group.id); this.$store.dispatch('newCallForward/removeGroupLoader', this.group.id);
}, },
openConditionsPopover(){
this.$refs.conditions.open();
},
showConditions(){ showConditions(){
this.$refs.addCondition.add(); this.$refs.addCondition.add();
}, },
showSourcesetForm(){ showSourcesetForm(){
this.$refs.addSourceSet.add(); this.$refs.addSourceSet.add();
}, },
showWeekdayPanel(){
this.$refs.weekdayForm.add();
},
showSources(){ showSources(){
this.$refs.editSources.add(); this.$refs.editSources.add();
}, },
resetToggleCondition(){ resetToggleCondition(){
this.toggleConditionFromForm = true; this.toggleConditionFromForm = true;
}, },
resetAction(){
this.$refs.addCondition.action = null;
},
resetWeekdayCondition(){
this.toggleWeekdayPanel = true;
},
async updateSourcesetNames(){ async updateSourcesetNames(){
const mappings = this.getMappings; const mappings = this.getMappings;
const groupMappingId = await this.$store.dispatch('newCallForward/getMappingIdByGroupName', this.group.name); const groupMappingId = await this.$store.dispatch('newCallForward/getMappingIdByGroupName', this.group.name);
@ -671,13 +749,6 @@
if(timeSet){ if(timeSet){
this.timeSet = timeSet; this.timeSet = timeSet;
this.times = this.timeSet.times; this.times = this.timeSet.times;
if(this.times[0] && this.times[0].year && this.times[0].year.includes('-')){
const time = this.times[0];
this.rangeDateModel.from = moment(new Date(parseInt(time.year.split('-')[0]),parseInt(time.month.split('-')[0])-1,parseInt(time.mday.split('-')[0]),parseInt(time.hour.split('-')[0]),parseInt(time.minute.split('-')[0]),0,0)).format();
this.rangeDateModel.to = moment(new Date(parseInt(time.year.split('-')[1]),parseInt(time.month.split('-')[1])-1,parseInt(time.mday.split('-')[1]),parseInt(time.hour.split('-')[1]),parseInt(time.minute.split('-')[1]),0,0)).format();
this.rangeTimeModel.from = moment(new Date(parseInt(time.year.split('-')[0]),parseInt(time.month.split('-')[0])-1,parseInt(time.mday.split('-')[0]),parseInt(time.hour.split('-')[0]),parseInt(time.minute.split('-')[0]),0,0)).format();
this.rangeTimeModel.to = moment(new Date(parseInt(time.year.split('-')[1]),parseInt(time.month.split('-')[1])-1,parseInt(time.mday.split('-')[1]),parseInt(time.hour.split('-')[1]),parseInt(time.minute.split('-')[1]),0,0)).format();
}
} }
else{ else{
this.timeSet = null; this.timeSet = null;
@ -700,17 +771,23 @@
} }
}, },
showQDateContainer(){
this.toggleIsDatePanel = false;
this.$refs.day.open()
},
showQDate(){ showQDate(){
this.$refs.dayWidget.open() this.$refs.dayWidget.open()
}, },
showDateRange(){
this.$refs.dateRangePopover.add()
},
showConfirmDeleteTimesetDialog(){ showConfirmDeleteTimesetDialog(){
this.$refs.confirmDeleteTimesetDialog.open(); this.$refs.confirmDeleteTimesetDialog.open();
}, },
async deleteTimeset(){ async deleteTimeset(){
try{ try{
this.$store.dispatch('newCallForward/addGroupLoader', this.group.id); this.$store.dispatch('newCallForward/addGroupLoader', this.group.id);
await this.$store.dispatch('newCallForward/deleteTimesFromTimeset', this.timeSet.id); await this.$store.dispatch('newCallForward/deleteTimeset', this.timeSet.id);
await this.$store.dispatch('newCallForward/loadTimesets');
this.$store.dispatch('newCallForward/loadMappings'); this.$store.dispatch('newCallForward/loadMappings');
this.$store.dispatch('newCallForward/removeGroupLoader', this.group.id); this.$store.dispatch('newCallForward/removeGroupLoader', this.group.id);
} }
@ -720,6 +797,13 @@
}, },
async addTimeToExistingTimeset(time){ async addTimeToExistingTimeset(time){
try{ try{
let timseSetId;
if(!this.timeSet){
timseSetId = await this.$store.dispatch('newCallForward/createTimeSet', this.timesetName = 'timeset-'+this.group.id);
}
else{
timseSetId = this.timeSet.id
}
this.$store.dispatch('newCallForward/addGroupLoader', this.group.id); this.$store.dispatch('newCallForward/addGroupLoader', this.group.id);
this.day = { this.day = {
"year": date.formatDate(time, 'YYYY'), "year": date.formatDate(time, 'YYYY'),
@ -728,76 +812,26 @@
} }
const updatedTimeset = await this.$store.dispatch('newCallForward/addTimeToTimeset', { const updatedTimeset = await this.$store.dispatch('newCallForward/addTimeToTimeset', {
id: this.timeSet.id, id: timseSetId,
time: this.day time: this.day
}); });
this.$store.dispatch('newCallForward/editTimes', updatedTimeset);
if(!this.timeSet){
this.$store.dispatch('newCallForward/addTimesetToGroup', {
name: this.group.name,
groupId: this.group.id,
timeSetId: timseSetId
});
}
this.$store.dispatch('newCallForward/setTimeset', updatedTimeset);
this.$store.dispatch('newCallForward/removeGroupLoader', this.group.id); this.$store.dispatch('newCallForward/removeGroupLoader', this.group.id);
} }
catch(e){ catch(e){
console.log(e) console.log(e)
} }
}, },
rangeDateChanged(){ rangeChanged(){
this.$refs.isRangeLink.click(); this.$refs.daterange.open();
},
rangeTimeChanged(){
this.$refs.isRangeLink.click();
},
resetTimeRange(){
this.rangeDateModel = {
from: null,
to: null
};
this.rangeTimeModel = {
from: null,
to: null
};
},
cancelTimerange() {
this.action = null;
this.enabled = false;
this.$refs.daterange.close();
},
formatRange(startDate, endDate, startTime, endTime){
const startDateOnly = startDate.split('T')[0];
const endDateOnly = endDate.split('T')[0];
const startTimeOnly = startTime.split('T')[1];
const endTimeOnly = endTime.split('T')[1];
const getDateObj = date => (([year, month, day ]) => ({ day, year, month }))(date.split('-'));
const getTimeObj = time => (([hour, minute, second]) => ({ hour, minute, second }))(time.split(':'));
const startDateObj = getDateObj(startDateOnly);
const endDateObj = getDateObj(endDateOnly);
const startTimeObj = getTimeObj(startTimeOnly);
const endTimeObj = getTimeObj(endTimeOnly);
return [
{
year: startDateObj.year +'-'+endDateObj.year,
month: startDateObj.month +'-'+endDateObj.month,
mday: startDateObj.day +'-'+endDateObj.day,
hour: startTimeObj.hour +'-'+endTimeObj.hour,
minute: startTimeObj.minute +'-'+endTimeObj.minute
}
]
},
async saveDateRange(){
const days = this.rangeDateModel;
const time = this.rangeTimeModel;
const datesTimesInRange = this.formatRange(days.from, days.to, time.from, time.to);
this.$store.dispatch('newCallForward/addGroupLoader', this.group.id);
const updatedTimeset = await this.$store.dispatch('newCallForward/addRangeToTimeset', {
id: this.timeSet.id,
times: datesTimesInRange
});
this.$refs.daterange.close();
this.$store.dispatch('newCallForward/setTimeset', updatedTimeset);
this.$store.dispatch('newCallForward/removeGroupLoader', this.group.id);
},
showRemoveDateRangeDialog(){
this.$refs.daterange.close();
this.showConfirmDeleteTimesetDialog();
} }
} }
} }
@ -828,6 +862,10 @@
cursor pointer cursor pointer
.csc-cf-group-popover-bottom .csc-cf-group-popover-bottom
margin-left 30px margin-left 30px
.csc-cf-popover-left-align
margin-left -120px
.csc-cf-popover-top-valign
margin-top -40px
.csc-cf-from-link .csc-cf-from-link
color $primary color $primary
cursor pointer cursor pointer

@ -141,6 +141,7 @@
cancel() { cancel() {
this.number = ''; this.number = '';
this.enabled = false; this.enabled = false;
this.$parent.close();
}, },
add() { add() {
this.number = ''; this.number = '';
@ -148,6 +149,7 @@
}, },
close() { close() {
this.enabled = false; this.enabled = false;
this.$parent.close();
}, },
reset() { reset() {
this.cancel(); this.cancel();

@ -114,6 +114,7 @@
return; return;
} }
try{ try{
this.close();
this.$store.dispatch('newCallForward/addGroupLoader', forwardGroupId); this.$store.dispatch('newCallForward/addGroupLoader', forwardGroupId);
sourceSetId = await this.$store.dispatch('newCallForward/createSourceSet', { sourceSetId = await this.$store.dispatch('newCallForward/createSourceSet', {
name: this.name, name: this.name,
@ -136,6 +137,7 @@
this.number = ''; this.number = '';
this.name = ''; this.name = '';
this.enabled = false; this.enabled = false;
this.$parent.close();
}, },
add() { add() {
this.number = ''; this.number = '';
@ -144,6 +146,7 @@
}, },
close() { close() {
this.enabled = false; this.enabled = false;
this.$parent.close();
}, },
reset() { reset() {
this.cancel(); this.cancel();

@ -0,0 +1,261 @@
<template>
<div
v-if="enabled"
class="csc-form"
v-bind:class="{ 'csc-cf-popover-hide': toggleFormVisibility}"
>
<div
class="csc-cf-delete-weekdays-btn"
>
<csc-confirm-dialog
ref="confirmDeleteTimesetDialog"
title-icon="delete"
:title="$t('pages.newCallForward.cancelTimesetDialogTitle', {name: 'weekdays'})"
:message="$t('pages.newCallForward.cancelTimesetText', {name: 'this'})"
@confirm="deleteTimeset"
/>
</div>
<div
class="csc-form-actions row justify-center csc-actions-cont"
>
<q-btn
class="day-btn"
v-bind:class="{ 'day-selected-btn': weekdays.includes('2')}"
rounded
@click="toggleWeekday('2')"
>
M
</q-btn>
<q-btn
class="day-btn"
v-bind:class="{ 'day-selected-btn': weekdays.includes('3')}"
rounded
@click="toggleWeekday('3')"
>
T
</q-btn>
<q-btn
class="day-btn"
v-bind:class="{ 'day-selected-btn': weekdays.includes('4')}"
rounded
@click="toggleWeekday('4')"
>
W
</q-btn>
<q-btn
class="day-btn"
v-bind:class="{ 'day-selected-btn': weekdays.includes('5')}"
rounded
@click="toggleWeekday('5')"
>
T
</q-btn>
<q-btn
class="day-btn"
v-bind:class="{ 'day-selected-btn': weekdays.includes('6')}"
rounded
@click="toggleWeekday('6')"
>
F
</q-btn>
<q-btn
class="day-btn"
v-bind:class="{ 'day-selected-btn': weekdays.includes('7')}"
rounded
@click="toggleWeekday('7')"
>
S
</q-btn>
<q-btn
class="day-btn"
v-bind:class="{ 'day-selected-btn': weekdays.includes('1')}"
rounded
@click="toggleWeekday('1')"
>
S
</q-btn>
</div>
<div
class="csc-form-actions row justify-center csc-actions-cont"
>
<q-btn
:disabled="this.weekdays.length < 1"
flat
color="red"
icon="delete"
@mousedown.native="showRemoveDialog()"
>
{{ $t('buttons.remove') }}
</q-btn>
<q-btn
flat
color="default"
icon="clear"
@mousedown.native="cancel()"
>
{{ $t('buttons.cancel') }}
</q-btn>
<q-btn
v-if="!loading"
flat
color="primary"
icon="done"
@click="save(); close()"
>
{{ $t('buttons.save') }}
</q-btn>
<div
v-if="loading"
class="csc-form-actions-spinner"
>
<csc-spinner />
</div>
</div>
</div>
</template>
<script>
import CscNewCallForwardInput from './CscNewCallForwardInput'
import CscNewCallForwardInputText from './CscNewCallForwardInputText'
import CscConfirmDialog from "../../CscConfirmationDialog";
import CscSpinner from '../../CscSpinner'
import {
QField,
QInput,
QBtn
} from 'quasar-framework'
export default {
name: 'csc-new-call-forward-add-weekday-form',
components: {
CscNewCallForwardInput,
CscNewCallForwardInputText,
CscConfirmDialog,
CscSpinner,
QField,
QInput,
QBtn
},
data () {
return {
timesetId: null,
timesetName: null,
toggleFormVisibility: false,
loading: false,
enabled: false,
weekdays: []
}
},
props: [
'groupName',
'groupId',
'id',
'days'
],
computed: {
saveDisabled() {
return true;
}
},
mounted(){
this.timesetName = 'timeset-'+this.groupId;
this.timeSetId = this.id;
if(this.days){
for(let day of this.days){
this.weekdays.push(day.wday);
}
}
},
methods: {
async save() {
const forwardGroupId = this.groupId;
this.$store.dispatch('newCallForward/addGroupLoader', forwardGroupId);
try{
if(this.weekdays.length < 1){
this.deleteTimeset();
}
else{
if(this.id){
this.timeSetId = this.id
}
else{
this.timeSetId = await this.$store.dispatch('newCallForward/createTimeSet', this.timesetName);
}
this.$store.dispatch('newCallForward/addTimesetToGroup', {
name: this.groupName,
groupId: this.groupId,
timeSetId: this.timeSetId
});
this.weekdays.sort((a,b) => (parseInt(a) > parseInt(b)) ? 1 : ((parseInt(b) > parseInt(a)) ? -1 : 0));
const days = this.weekdays.map(item => { return {"wday":item}});
const updatedTimeset = await this.$store.dispatch('newCallForward/addTimeToTimeset', {
id: this.timeSetId,
time: days
});
this.$store.dispatch('newCallForward/setTimeset', updatedTimeset);
}
}
catch(err){
console.log(err)
}
this.$store.dispatch('newCallForward/removeGroupLoader', forwardGroupId);
},
cancel(){
this.weekdays = [];
if(this.days){
for(let day of this.days){
this.weekdays.push(day.wday);
}
}
this.close();
},
close() {
this.$parent.close();
this.enabled = false;
},
add() {
this.toggleFormVisibility = false;
this.enabled = true;
},
showRemoveDialog(){
this.toggleFormVisibility = true;
this.$refs.confirmDeleteTimesetDialog.open();
},
toggleWeekday(weekday){
if(this.weekdays.includes(weekday)){
this.weekdays = this.weekdays.filter(item => item !== weekday);
}
else{
this.weekdays.push(weekday);
}
},
async deleteTimeset(){
this.$store.dispatch('newCallForward/addGroupLoader', this.groupId);
await this.$store.dispatch('newCallForward/deleteTimeset', this.timeSetId);
this.$store.dispatch('newCallForward/loadMappings');
this.$store.dispatch('newCallForward/removeGroupLoader', this.groupId);
}
}
}
</script>
<style lang="stylus" rel="stylesheet/stylus">
@import '../../../themes/app.common.styl'
.csc-actions-cont
margin-bottom 15px
.day-btn
margin 5px
background rgba(37,51,85,0.8)
width 35px
.day-selected-btn
background $primary
.csc-cf-delete-weekdays-btn
float right
margin-top -10px
margin-right -20px
</style>

@ -15,18 +15,6 @@
@click="addDateIsCondition()" @click="addDateIsCondition()"
> >
{{ $t('pages.newCallForward.dateIsLabel') }} {{ $t('pages.newCallForward.dateIsLabel') }}
<q-popover
ref="day"
@open="showQDate()"
class="csc-cf-calendar-day"
>
<q-datetime
ref="dayWidget"
no-clear
v-model="dayModel"
:min="today"
/>
</q-popover>
</div> </div>
<div <div
class="csc-cf-dest-type" class="csc-cf-dest-type"
@ -35,73 +23,14 @@
@click="addDateRangeCondition()" @click="addDateRangeCondition()"
> >
{{ $t('pages.newCallForward.dateRangeLabel') }} {{ $t('pages.newCallForward.dateRangeLabel') }}
<q-popover
ref="daterange" </div>
class="csc-cf-calendar-day"
>
<q-field
label="Date range"
:labelWidth="11"
class="csc-cf-popover-daterange-title"
/>
<q-field
dark
:helper="$t('pages.newCallForward.dateRangeDateHelper')"
>
<q-datetime-range
ref="dayRangeWidget"
type="date"
no-clear
v-model="rangeDateModel"
:min="today"
@change="rangeDateChanged()"
format="DD/MM/YYYY"
:after="[
{
icon: 'today'
}
]"
/>
</q-field>
<q-field
dark
:helper="$t('pages.newCallForward.dateRangeTimeHelper')"
>
<q-datetime-range
ref="dayRangeWidget"
type="time"
no-clear
v-model="rangeTimeModel"
@change="rangeTimeChanged()"
:after="[
{
icon: 'access_time'
}
]"
/>
</q-field>
<div <div
class="csc-cf-daterange-btn-cont" class="csc-cf-dest-type"
> v-if="disableWeekdaysMenu"
<q-btn @click="addWeekdayCondition()"
flat
color="default"
icon="clear"
@mousedown.native="reset(); cancel()"
>
{{ $t('buttons.cancel') }}
</q-btn>
<q-btn
flat
color="primary"
icon="done"
@click="save(); close()"
:disable="!allFieldsFilled"
> >
{{ $t('buttons.save') }} {{ $t('pages.newCallForward.weekdaysLabel') }}
</q-btn>
</div>
</q-popover>
</div> </div>
</div> </div>
</template> </template>
@ -112,12 +41,9 @@
} from 'vuex' } from 'vuex'
import CscSpinner from '../../CscSpinner' import CscSpinner from '../../CscSpinner'
import { import {
QDatetime,
QDatetimeRange,
QPopover, QPopover,
QField, QField,
QBtn, QBtn
date
} from 'quasar-framework' } from 'quasar-framework'
export default { export default {
@ -127,12 +53,11 @@
'groupName', 'groupName',
'disableSourcesetMenu', 'disableSourcesetMenu',
'disableTimesetMenu', 'disableTimesetMenu',
'disableDateRangeMenu' 'disableDateRangeMenu',
'disableWeekdaysMenu'
], ],
components: { components: {
CscSpinner, CscSpinner,
QDatetimeRange,
QDatetime,
QPopover, QPopover,
QField, QField,
QBtn QBtn
@ -141,17 +66,7 @@
return { return {
enabled: true, enabled: true,
action: null, action: null,
timesetName: null, timesetName: null
day: null,
rangeDateModel: {
from: null,
to: null
},
rangeTimeModel: {
from: null,
to: null
},
today: new Date()
} }
}, },
mounted(){ mounted(){
@ -164,38 +79,6 @@
this.rangeDateModel.to !== null && this.rangeDateModel.to !== null &&
this.rangeTimeModel.from !== null && this.rangeTimeModel.from !== null &&
this.rangeTimeModel.to !== null; this.rangeTimeModel.to !== null;
},
dayModel: {
get() {
return this.day;
},
async set(value) {
try{
this.$store.dispatch('newCallForward/addGroupLoader', this.groupId);
const timeSetId = await this.$store.dispatch('newCallForward/createTimeSet', this.timesetName);
this.day = {
"year": date.formatDate(value, 'YYYY'),
"month": date.formatDate(value, 'M'),
"mday": date.formatDate(value, 'D')
}
this.$store.dispatch('newCallForward/addTimesetToGroup', {
name: this.groupName,
groupId: this.groupId,
timeSetId: timeSetId
});
await this.$store.dispatch('newCallForward/addTimeToTimeset', {
id: timeSetId,
time: this.day
});
await this.$store.dispatch('newCallForward/loadTimesets');
this.$store.dispatch('newCallForward/removeGroupLoader', this.groupId);
}
catch(err){
console.log(err)
}
}
} }
}, },
methods: { methods: {
@ -209,11 +92,16 @@
}, },
addDateRangeCondition(){ addDateRangeCondition(){
this.action = "addDateRangeCondition"; this.action = "addDateRangeCondition";
this.$parent.close();
},
addWeekdayCondition(){
this.action = "addWeekdayCondition";
this.$parent.close() this.$parent.close()
}, },
cancel() { cancel() {
this.action = null; this.action = null;
this.enabled = false; this.enabled = false;
this.$parent.close();
}, },
add() { add() {
this.enabled = true; this.enabled = true;
@ -221,67 +109,10 @@
close() { close() {
this.action = null; this.action = null;
this.enabled = false; this.enabled = false;
this.$parent.close();
}, },
showQDate(){ showQDate(){
this.$refs.dayWidget.open() this.$refs.dayWidget.open()
},
rangeDateChanged(){
this.$parent.open(); // workaround to keep popver position
this.$refs.daterangeItem.click();
},
rangeTimeChanged(){
this.$parent.open(); // workaround to keep popver position
this.$refs.daterangeItem.click();
},
reset(){
this.rangeDateModel = {
from: null,
to: null
};
this.rangeTimeModel = {
from: null,
to: null
};
},
formatRange(startDate, endDate, startTime, endTime){
const startDateOnly = startDate.toString().split('T')[0];
const endDateOnly = endDate.toString().split('T')[0];
const startTimeOnly = startTime.toString().split('T')[1];
const endTimeOnly = endTime.toString().split('T')[1];
const getDateObj = date => (([year, month, day ]) => ({ day, year, month }))(date.split('-'));
const getTimeObj = time => (([hour, minute, second]) => ({ hour, minute, second }))(time.split(':'));
const startDateObj = getDateObj(startDateOnly);
const endDateObj = getDateObj(endDateOnly);
const startTimeObj = getTimeObj(startTimeOnly);
const endTimeObj = getTimeObj(endTimeOnly);
return [
{
year: startDateObj.year +'-'+endDateObj.year,
month: startDateObj.month +'-'+endDateObj.month,
mday: startDateObj.day +'-'+endDateObj.day,
hour: startTimeObj.hour +'-'+endTimeObj.hour,
minute: startTimeObj.minute +'-'+endTimeObj.minute
}
]
},
async save(){
const days = this.rangeDateModel;
const time = this.rangeTimeModel;
const datesTimesInRange = this.formatRange(days.from, days.to, time.from, time.to);
const timeSetId = await this.$store.dispatch('newCallForward/createTimeSet', this.timesetName);
this.$store.dispatch('newCallForward/addGroupLoader', this.groupId);
this.$store.dispatch('newCallForward/addTimesetToGroup', {
name: this.groupName,
groupId: this.groupId,
timeSetId: timeSetId
});
const updatedTimeset = await this.$store.dispatch('newCallForward/addRangeToTimeset', {
id: timeSetId,
times: datesTimesInRange
});
this.reset();
this.$store.dispatch('newCallForward/setTimeset', updatedTimeset);
this.$store.dispatch('newCallForward/removeGroupLoader', this.groupId);
} }
} }
} }
@ -296,33 +127,8 @@
.csc-cf-dest-type:hover .csc-cf-dest-type:hover
background $main-menu-item-hover-background background $main-menu-item-hover-background
.csc-cf-calendar-day .csc-cf-calendar-day
margin-top -100px !important
padding 20px padding 20px
min-width 400px min-width 400px
.csc-cf-popover-daterange-title
text-align center
margin-left 40px
.q-field-label-inner
color $white
margin-top -25px
margin-bottom 10px
font-weight bold
span
width 100%
text-align center
.q-datetime-weekdays .q-datetime-weekdays
color $tertiary color $tertiary
.q-datetime-days div:not(.q-datetime-day-active),
.q-datetime-dark,
.q-datetime-range .q-datetime-input .q-input-target,
.q-datetime-range .q-icon,
.q-datetime-range .q-if:before,
.q-item-icon
color $white !important
.q-datetime-range.row .q-datetime-range-right,
.q-datetime-range.row .q-datetime-range-left
padding-left 20px
.csc-cf-daterange-btn-cont
width 100%
text-align right
</style> </style>

@ -0,0 +1,400 @@
<template>
<div
v-if="enabled"
class="csc-form"
>
<div
class="csc-cf-daterange-popovers-container"
>
<q-datetime
class="csc-cf-datetime"
v-model="dayFrom"
type="date"
format="DD/MM/YYYY"
ref="dayFrom"
:min="today"
@blur="openParent()"
/>
<q-datetime
class="csc-cf-datetime"
v-model="dayTo"
type="date"
format="DD/MM/YYYY"
ref="dayTo"
:min="dayFrom"
@blur="openParent()"
/>
<q-datetime
class="csc-cf-datetime"
v-model="hourFrom"
type="time"
format="HH:MM"
ref="hourFrom"
@blur="openParent()"
/>
<q-datetime
class="csc-cf-datetime"
v-model="hourTo"
type="time"
format="HH:MM"
:min="hourFrom"
ref="hourTo"
@blur="openParent()"
/>
</div>
<div
class="csc-cf-daterange-fields-cont csc-form-actions row justify-center csc-actions-cont"
>
<q-field
dark
label="Date range"
:labelWidth="11"
class="csc-cf-popover-daterange-title"
/>
</div>
<div
class="csc-cf-daterange-fields-cont csc-form-actions row justify-center csc-actions-cont"
>
<q-input
dark
v-model="dayFromFormatted"
@click="openDayFrom()"
:placeholder="$t('pages.newCallForward.dateRangeStartDate')"
:after="[
{
icon: 'today',
handler () {
openDayFrom();
}
}
]"
/>
<q-input
dark
v-model="dayToFormatted"
@click="openDayTo()"
:placeholder="$t('pages.newCallForward.dateRangeEndDate')"
:after="[
{
icon: 'today',
handler () {
openDayTo();
}
}
]"
/>
</div>
<div
class="csc-form-actions row justify-center csc-actions-cont"
>
<q-input
dark
v-model="hourFromFormatted"
@click="openHourFrom()"
:placeholder="$t('pages.newCallForward.dateRangeStartTime')"
:after="[
{
icon: 'access_time',
handler () {
openHourFrom();
}
}
]"
/>
<q-input
dark
v-model="hourToFormatted"
@click="openHourTo()"
:placeholder="$t('pages.newCallForward.dateRangeEndTime')"
:after="[
{
icon: 'access_time',
handler () {
openHourTo();
}
}
]"
/>
</div>
<div
class="csc-cf-daterange-btn-cont"
>
<q-btn
flat
color="red"
icon="delete"
v-if="!noClear"
@mousedown.native="showRemoveDateRangeDialog()"
>
{{ $t('buttons.remove') }}
<csc-confirm-dialog
ref="confirmDeleteTimesetDialog"
title-icon="delete"
:title="$t('pages.newCallForward.cancelTimesetDialogTitle', {name: this.groupTimeRange})"
:message="$t('pages.newCallForward.cancelTimesetText', {name: this.groupTimeRange})"
@confirm="deleteTimeset"
/>
</q-btn>
<q-btn
flat
color="default"
icon="clear"
@click="cancelTimerange(); resetTimeRange()"
>
{{ $t('buttons.cancel') }}
</q-btn>
<q-btn
flat
color="primary"
icon="done"
@click="save();"
:disable="!allFieldsFilled"
>
{{ $t('buttons.save') }}
</q-btn>
</div>
</div>
</template>
<script>
import CscConfirmDialog from "../../CscConfirmationDialog";
import CscSpinner from '../../CscSpinner'
import {
QDatetime,
QField,
QInput,
QBtn,
date
} from 'quasar-framework'
export default {
name: 'csc-new-call-forward-date-range',
components: {
CscConfirmDialog,
CscSpinner,
QDatetime,
QField,
QInput,
QBtn
},
data () {
return {
enabled: false,
timesetId: null,
timesetName: null,
dayFrom: null,
dayTo: null,
hourFrom: null,
hourTo: null,
today: new Date(),
dayRegExp: /^([0-2][0-9]|(3)[0-1])(\/)(((0)[0-9])|((1)[0-2]))(\/)\d{4}$/i,
timeRegExp: /^(0[0-9]|1[0-9]|2[0-3]):[0-5][0-9]$/,
}
},
props: [
'groupName',
'groupId',
'groupTimeRange',
'noClear',
'id'
],
mounted(){
this.setDaysAndTimes()
},
computed: {
dayFromFormatted(){
let day = this.dayFrom ? this.dayFrom : '';
if(day.toString().length > 0 && !day.match(this.dayRegExp)){
day = date.formatDate(day, 'DD/MM/YYYY');
}
return day;
},
dayToFormatted(){
let day = this.dayTo ? this.dayTo : '';
if(day.toString().length > 0 && !day.match(this.dayRegExp)){
day = date.formatDate(day, 'DD/MM/YYYY');
}
return day;
},
hourFromFormatted(){
let time = this.hourFrom ? this.hourFrom : '';
if(time.toString().length > 0 && !time.match(this.timeRegExp)){
time = date.formatDate(time, 'hh:mm');
}
return time;
},
hourToFormatted(){
let time = this.hourTo ? this.hourTo : '';
if(time.toString().length > 0 && !time.match(this.timeRegExp)){
time = date.formatDate(time, 'hh:mm');
}
return time;
},
allFieldsFilled(){
return this.dayFrom !== null &&
this.dayTo !== null &&
this.hourFrom !== null &&
this.hourTo !== null;
}
},
methods: {
openParent(){
this.$emit('open-daterange-popover');
},
openDayFrom(){
this.$refs.dayFrom.open();
},
openDayTo(){
this.$refs.dayTo.open();
},
openHourFrom(){
this.$refs.hourFrom.open();
},
openHourTo(){
this.$refs.hourTo.open();
},
cancel(){
this.close();
},
close() {
this.$parent.close();
this.enabled = false;
},
add() {
this.enabled = true;
},
showRemoveDialog(){
},
formatRange(startDate, endDate, startTime, endTime){
const startDateOnly = startDate.toString().split('T')[0];
const endDateOnly = endDate.toString().split('T')[0];
const startTimeOnly = startTime.toString().split('T')[1];
const endTimeOnly = endTime.toString().split('T')[1];
const getDateObj = date => (([year, month, day ]) => ({ day, year, month }))(date.split('-'));
const getTimeObj = time => (([hour, minute, second]) => ({ hour, minute, second }))(time.split(':'));
const startDateObj = getDateObj(startDateOnly);
const endDateObj = getDateObj(endDateOnly);
const startTimeObj = getTimeObj(startTimeOnly);
const endTimeObj = getTimeObj(endTimeOnly);
return [
{
year: startDateObj.year +'-'+endDateObj.year,
month: startDateObj.month +'-'+endDateObj.month,
mday: startDateObj.day +'-'+endDateObj.day,
hour: startTimeObj.hour +'-'+endTimeObj.hour,
minute: startTimeObj.minute +'-'+endTimeObj.minute
}
]
},
async save(){
this.$store.dispatch('newCallForward/addGroupLoader', this.groupId);
const datesTimesInRange = this.formatRange(this.dayFrom, this.dayTo, this.hourFrom, this.hourTo);
if(!this.timesetName){
this.timesetName = 'timeset-' + this.groupId;
}
const timeSetId = await this.$store.dispatch('newCallForward/createTimeSet', this.timesetName);
this.$store.dispatch('newCallForward/addTimesetToGroup', {
name: this.groupName,
groupId: this.groupId,
timeSetId: timeSetId
});
const updatedTimeset = await this.$store.dispatch('newCallForward/addRangeToTimeset', {
id: timeSetId,
times: datesTimesInRange
});
this.$store.dispatch('newCallForward/setTimeset', updatedTimeset);
this.$store.dispatch('newCallForward/removeGroupLoader', this.groupId);
this.cancelTimerange();
},
async deleteTimeset(){
try{
this.$store.dispatch('newCallForward/addGroupLoader', this.groupId);
await this.$store.dispatch('newCallForward/deleteTimeset', this.timesetId);
this.$store.dispatch('newCallForward/loadMappings');
this.$store.dispatch('newCallForward/removeGroupLoader', this.groupId);
}
catch(e){
console.log(e)
}
},
resetTimeRange(){
this.dayFrom = null;
this.dayTo = null;
this.hourFrom = null;
this.hourTo = null;
},
cancelTimerange() {
this.$parent.close()
this.action = null;
this.enabled = false;
},
setDaysAndTimes(){
if(this.groupTimeRange){
this.dayFrom = this.groupTimeRange.dateFrom;
this.dayTo = this.groupTimeRange.dateTo;
this.hourFrom = this.groupTimeRange.dateFrom;
this.hourTo = this.groupTimeRange.dateTo;
}
else{
this.resetTimeRange();
}
},
showRemoveDateRangeDialog(){
this.$parent.close();
this.$emit('confirm-delete');
}
}
}
</script>
<style lang="stylus" rel="stylesheet/stylus">
@import '../../../themes/app.common.styl'
.csc-cf-popover-daterange-title
text-align center
width 100%
margin-left 40px
margin-top 50px
margin-bottom -60px
.q-field-label-inner
color $white
margin-top -25px
margin-bottom 10px
font-weight bold
span
width 100%
text-align center
.csc-actions-cont
margin-bottom 15px
.q-input
margin-left 10px
margin-right 20px
max-width 160px
.csc-cf-daterange-fields-cont
margin-top 73px !important
.csc-cf-daterange-popovers-container
width 100%
height 1px !important
margin-top -70px !important
margin-bottom -30px !important
position relative
.csc-cf-datetime
position absolute
top 0
left 0
.csc-cf-daterange-btn-cont
width 100%
text-align center
.q-datetime-days div:not(.q-datetime-day-active),
.q-datetime-dark,
.q-datetime-range .q-datetime-input .q-input-target,
.q-datetime-range .q-icon,
.q-datetime-range .q-if:before,
.q-item-icon
color $white !important
.q-datetime-range.row .q-datetime-range-right,
.q-datetime-range.row .q-datetime-range-left
padding-left 20px
</style>

@ -197,7 +197,6 @@
await this.$store.dispatch('newCallForward/setFirstDestinationInCreation', newGroupId); await this.$store.dispatch('newCallForward/setFirstDestinationInCreation', newGroupId);
this.firstDestinationInCreation = false; this.firstDestinationInCreation = false;
} }
} }
else{ else{
await this.$store.dispatch('newCallForward/addVoiceMail', this.groupId); await this.$store.dispatch('newCallForward/addVoiceMail', this.groupId);

@ -12,7 +12,6 @@
<span <span
class="csc-cf-delete-sourceset-btn" class="csc-cf-delete-sourceset-btn"
> >
<csc-confirm-dialog <csc-confirm-dialog
ref="confirmDialog" ref="confirmDialog"
title-icon="delete" title-icon="delete"
@ -213,6 +212,7 @@
cancel() { cancel() {
this.number = ''; this.number = '';
this.enabled = false; this.enabled = false;
this.$parent.close();
}, },
add() { add() {
this.number = ''; this.number = '';
@ -220,6 +220,7 @@
}, },
close() { close() {
this.enabled = false; this.enabled = false;
this.$parent.close();
}, },
reset() { reset() {
this.cancel(); this.cancel();

@ -251,6 +251,15 @@
"dateRangeTimeHelper": "Pick start and end time", "dateRangeTimeHelper": "Pick start and end time",
"dateIsShort": " date is ", "dateIsShort": " date is ",
"dateRangeShort": " date range is ", "dateRangeShort": " date range is ",
"dateRangeStartDate" : "Start date",
"dateRangeEndDate" : "End date",
"dateRangeStartTime" : "Start time",
"dateRangeEndTime" : "End time",
"weekdaysLabel": "If weekdays are ...",
"weekdayLabel": "If weekday is ...",
"weekdaysLabelShort": " weekdays are ",
"weekdays":"weekdays",
"weekdayLabelShort": " weekday is ",
"offlineLabel": "If not available", "offlineLabel": "If not available",
"busyLabel": "If busy", "busyLabel": "If busy",
"sourcesetName": "List name", "sourcesetName": "List name",

@ -18,7 +18,7 @@ import {
getTimesets, getTimesets,
addNewTimeset, addNewTimeset,
addTimeToTimeset, addTimeToTimeset,
deleteTimeFromTimeset deleteTimesetById
} from '../api/call-forward'; } from '../api/call-forward';
const ForwardGroup = { const ForwardGroup = {
@ -219,6 +219,9 @@ export default {
setOwnPhoneTimeout(state, cft_ringtimeout){ setOwnPhoneTimeout(state, cft_ringtimeout){
const mappings = state.mappings; const mappings = state.mappings;
mappings.cft_ringtimeout = cft_ringtimeout mappings.cft_ringtimeout = cft_ringtimeout
},
removeTimeset(state, timesSetId){
state.timeSets = state.timeSets.filter($timeset => $timeset.id !== timesSetId);
} }
}, },
actions: { actions: {
@ -301,7 +304,7 @@ export default {
groupId: newForwardGroupId groupId: newForwardGroupId
}); });
addDestinationToDestinationset({ await addDestinationToDestinationset({
id: newForwardGroupId, id: newForwardGroupId,
data: [destination] data: [destination]
}); });
@ -719,7 +722,7 @@ export default {
try{ try{
const timeset = await addTimeToTimeset({ const timeset = await addTimeToTimeset({
id: data.id, id: data.id,
times: [data.time] times: _.isArray(data.time) ? data.time : [data.time]
}); });
return timeset; return timeset;
} }
@ -739,12 +742,10 @@ export default {
console.log(err) console.log(err)
} }
}, },
async deleteTimesFromTimeset(context, timesetId){ async deleteTimeset(context, timesetId){
try{ try{
await deleteTimeFromTimeset({ await deleteTimesetById(timesetId);
timesetId: timesetId, context.commit('removeTimeset', timesetId);
times: []
});
} }
catch(err){ catch(err){
console.log(err) console.log(err)

Loading…
Cancel
Save