TT#94101 CSC: Upgrade new Call Forwarding to latest Quasar

Change-Id: I383a67d94d2ca6e31b8afcdbd1a2d6d7e70db2c3
mr9.1.1
Carlo Venusino 5 years ago
parent 88b66464c6
commit 3aabf8c3c9

@ -119,7 +119,7 @@ export default {
default: null default: null
}, },
sourcesetId: { sourcesetId: {
type: Number, type: [Number, String],
default: null default: null
} }
}, },

@ -33,7 +33,7 @@ export default {
name: 'CscSourcesetsForm', name: 'CscSourcesetsForm',
props: { props: {
sourcesetId: { sourcesetId: {
type: Number, type: [Number, String],
default: null default: null
} }
}, },

@ -4,10 +4,10 @@
class="csc-cf-group" class="csc-cf-group"
> >
<div <div
class="row csc-cf-destination-cont" class="row csc-cf-destination-cont csc-cf-group-header"
> >
<div <div
class="col col-xs-12 col-md-4 text-right csc-cf-group-title-bold" class="col-xs-4 col-md-4 text-right csc-cf-group-title-bold"
> >
{{ groupTitle }} {{ groupTitle }}
<span <span
@ -17,19 +17,21 @@
<span class="csc-cf-from-link"> <span class="csc-cf-from-link">
{{ $t('pages.newCallForward.fromLabelShort') +'"'+ groupSourceset +'"' }} {{ $t('pages.newCallForward.fromLabelShort') +'"'+ groupSourceset +'"' }}
</span> </span>
<q-popover <q-menu
ref="sourcesList" ref="sourcesList"
class="csc-cf-number-form" :target="$refs.target"
@open="showSources()" @show="showSources()"
> >
<csc-new-call-forward-edit-sources <csc-new-call-forward-edit-sources
ref="editSources" ref="editSources"
class="q-pa-md"
:source-set-name="groupSourceset" :source-set-name="groupSourceset"
:source-set-id="sourceSet.id" :source-set-id="sourceSet.id"
:group-name="group.name" :group-name="group.name"
:group-id="group.id" :group-id="group.id"
@close="()=>{this.$refs.sourcesList.hide}"
/> />
</q-popover> </q-menu>
</span> </span>
<span <span
@ -39,18 +41,35 @@
<span class="csc-cf-from-link"> <span class="csc-cf-from-link">
{{ $t('pages.newCallForward.dateIsShort') + groupTimeset }} {{ $t('pages.newCallForward.dateIsShort') + groupTimeset }}
</span> </span>
<q-popover <q-menu
ref="day"
class="csc-cf-popover-top-valign"
@open="showQDate()"
>
<q-datetime
ref="dayWidget" ref="dayWidget"
>
<q-date
v-model="dayModel" v-model="dayModel"
clear-label="REMOVE" :options="minDate"
:min="today" :no-unset="true"
/> >
</q-popover> <div class="row items-center justify-end q-gutter-sm">
<q-btn
v-close-popup
flat
color="primary"
icon="clear"
>
{{ $t('buttons.close') }}
</q-btn>
<q-btn
v-close-popup
flat
color="red"
icon="delete"
@click="showConfirmDeleteTimesetDialog"
>
{{ $t('buttons.remove') }}
</q-btn>
</div>
</q-date>
</q-menu>
<csc-confirm-dialog <csc-confirm-dialog
ref="confirmDeleteTimesetDialog" ref="confirmDeleteTimesetDialog"
title-icon="delete" title-icon="delete"
@ -69,19 +88,18 @@
class="csc-cf-from-link" class="csc-cf-from-link"
> >
{{ $t('pages.newCallForward.dateRangeShort') + groupTimeRange }} {{ $t('pages.newCallForward.dateRangeShort') + groupTimeRange }}
</span> <q-menu
<q-popover
ref="daterange" ref="daterange"
class="csc-cf-calendar-day" @hide="resetAction()"
@open="showDateRange()"
> >
<csc-new-call-forward-date-range <csc-new-call-forward-date-range
ref="dateRangePopover" ref="dateRangePopover"
class="q-pa-md"
:group-name="group.name" :group-name="group.name"
:group-id="group.id" :group-id="group.id"
:group-time-range="groupTimeRangeObj" :group-time-range="groupTimeRangeObj"
@open-daterange-popover="rangeChanged()"
@confirm-delete="showConfirmDeleteTimesetDialog()" @confirm-delete="showConfirmDeleteTimesetDialog()"
@close="() => {this.$refs.daterange.hide()}"
/> />
<csc-confirm-dialog <csc-confirm-dialog
ref="confirmDeleteTimesetDialog" ref="confirmDeleteTimesetDialog"
@ -90,7 +108,8 @@
:message="$t('pages.newCallForward.cancelTimesetText', {name: groupTimeRange})" :message="$t('pages.newCallForward.cancelTimesetText', {name: groupTimeRange})"
@confirm="deleteTimeset" @confirm="deleteTimeset"
/> />
</q-popover> </q-menu>
</span>
</span> </span>
<span <span
v-if="isWeekdays" v-if="isWeekdays"
@ -102,20 +121,20 @@
> >
{{ weekdaysLabelShort + groupWeekdays }} {{ weekdaysLabelShort + groupWeekdays }}
</span> </span>
<q-popover <q-menu
ref="weekdayEditPanel" ref="weekdayEditPanel"
class="csc-cf-number-form" @show="showWeekdayEditForm()"
@open="showWeekdayEditForm()"
> >
<csc-new-call-forward-add-weekday-form <csc-new-call-forward-add-weekday-form
:id="timeSet.id" :id="timeSet.id"
ref="weekdayEditForm" ref="weekdayEditForm"
class="q-pa-md"
:days="times" :days="times"
:enabled="true" :enabled="true"
:group-name="group.name" :group-name="group.name"
:group-id="group.id" :group-id="group.id"
/> />
</q-popover> </q-menu>
</span> </span>
<span <span
v-if="isTempGroup || (!isTempGroup && !(groupSourceset && groupTimeset || groupSourceset && isWeekdays || groupTimeset && isWeekdays ))" v-if="isTempGroup || (!isTempGroup && !(groupSourceset && groupTimeset || groupSourceset && isWeekdays || groupTimeset && isWeekdays ))"
@ -125,97 +144,134 @@
<span class="csc-cf-from-link"> <span class="csc-cf-from-link">
{{ $t('pages.newCallForward.conditionBtnLabel') }} {{ $t('pages.newCallForward.conditionBtnLabel') }}
</span> </span>
<q-popover <q-menu
ref="conditions" ref="conditions"
@open="showConditions()" :auto-close="true"
@close="showConditionForm()" @hide="showConditionForm()"
> >
<csc-new-call-forward-condition-type-select <q-list>
ref="addCondition" <q-item
:disable-sourceset-menu="isTempGroup || !groupSourceset" v-if="isTempGroup || !groupSourceset"
:disable-timeset-menu="isTempGroup || !groupTimeset && !isRange && !isWeekdays" ref="addFromConditionItem"
:disable-date-range-menu="isTempGroup || !groupTimeset && !isRange && !isWeekdays" v-close-popup
:disable-weekdays-menu="isTempGroup || !groupTimeset && !isRange && !isWeekdays" clickable
:enabled="true" @click="()=>{action = 'addFromCondition'}"
:group-name="group.name" >
:group-id="group.id" <q-item-section>{{ $t('pages.newCallForward.fromLabel') }}</q-item-section>
/> </q-item>
</q-popover> <q-item
v-if="isTempGroup || !groupTimeset && !isRange && !isWeekdays"
v-close-popup
clickable
@click="()=>{action = 'addDateIsCondition'}"
>
<q-item-section>{{ $t('pages.newCallForward.dateIsLabel') }}</q-item-section>
</q-item>
<q-item
v-if="isTempGroup || !groupTimeset && !isRange && !isWeekdays"
v-close-popup
clickable
@click="()=>{action = 'addDateRangeCondition'}"
>
<q-item-section>{{ $t('pages.newCallForward.dateRangeLabel') }}</q-item-section>
</q-item>
<q-item
v-if="isTempGroup || !groupTimeset && !isRange && !isWeekdays"
v-close-popup
clickable
@click="()=>{action = 'addWeekdayCondition'}"
>
<q-item-section>{{ $t('pages.newCallForward.weekdaysLabel') }}</q-item-section>
</q-item>
</q-list>
</q-menu>
<span> <span>
<q-popover <q-menu
ref="onlineSourceset" ref="onlineSourceset"
class="csc-cf-number-form csc-cf-popover-left-align" @show="showSourcesetForm()"
:class="{ 'csc-cf-popover-hide': toggleConditionFromForm}" @hide="resetToggleCondition(); resetAction()"
@open="showSourcesetForm()"
@close="resetToggleCondition(); resetAction()"
> >
<csc-new-call-forward-add-sourceset-form <csc-new-call-forward-add-sourceset-form
ref="addSourceSet" ref="addSourceSet"
class="q-pa-md"
:enabled="true" :enabled="true"
:group-name="group.name" :group-name="group.name"
:group-id="group.id" :group-id="group.id"
@close="()=>{this.$refs.onlineSourceset.hide()}"
/> />
</q-popover> </q-menu>
</span> </span>
<span> <span>
<q-popover <q-menu
ref="day" ref="dayWidgetFromMenu"
class="csc-cf-popover-left-align csc-cf-popover-top-valign" @hide="resetAction()"
:class="{ 'csc-cf-popover-hide': toggleIsDatePanel}" >
@open="showQDate()" <q-date
@close="resetAction()"
>
<q-datetime
ref="dayWidget"
v-model="dayModel" v-model="dayModel"
anchor="bottom right" :options="minDate"
no-clear :no-unset="true"
:min="today" >
/> <div class="row items-center justify-end q-gutter-sm">
</q-popover> <q-btn
v-close-popup
flat
color="primary"
icon="clear"
>
{{ $t('buttons.close') }}
</q-btn>
<q-btn
v-close-popup
flat
color="red"
icon="delete"
@click="showConfirmDeleteTimesetDialog"
>
{{ $t('buttons.remove') }}
</q-btn>
</div>
</q-date>
</q-menu>
</span> </span>
<span> <span>
<q-popover <q-menu
ref="daterange" ref="daterangeFromMenu"
class="csc-cf-popover-left-align csc-cf-calendar-day" @hide="resetAction()"
:class="{ 'csc-cf-popover-hide': toggleIsRangePanel}"
@open="showDateRange()"
@close="resetAction()"
> >
<csc-new-call-forward-date-range <csc-new-call-forward-date-range
ref="dateRangePopover" ref="dateRangePopover"
class="q-pa-md"
:group-name="group.name" :group-name="group.name"
:group-id="group.id" :group-id="group.id"
:no-clear="true" :no-clear="true"
@open-daterange-popover="rangeChanged()" @close="() => {this.$refs.daterangeFromMenu.hide()}"
/> />
</q-popover> </q-menu>
</span> </span>
<span> <span>
<q-popover <q-menu
ref="weekdayPanel" ref="weekdayPanel"
class="csc-cf-number-form csc-cf-popover-left-align" @show="showWeekdayPanel()"
:class="{ 'csc-cf-popover-hide': toggleWeekdayPanel}" @hide="resetWeekdayCondition(); resetAction()"
@open="showWeekdayPanel()"
@close="resetWeekdayCondition(); resetAction()"
> >
<csc-new-call-forward-add-weekday-form <csc-new-call-forward-add-weekday-form
ref="weekdayForm" ref="weekdayForm"
class="q-pa-md"
:enabled="true" :enabled="true"
:group-name="group.name" :group-name="group.name"
:group-id="group.id" :group-id="group.id"
/> />
</q-popover> </q-menu>
</span> </span>
</span> </span>
</div> </div>
<div class="col text-left col-xs-12 col-md-2 csc-cf-dest-number-cont"> <div class="text-left col-xs-2 col-md-2 csc-cf-dest-number-cont csc-cf-toggle-group">
<q-toggle <q-toggle
v-model="isEnabled" v-model="isEnabled"
@input="toggleGroupChange" @input="toggleGroupChange"
/> />
</div> </div>
<div class="col col-xs-12 col-md-5 csc-cf-group-actions"> <div class="col-xs-5 col-md-5 csc-cf-group-actions">
<q-icon <q-icon
name="delete" name="delete"
color="negative" color="negative"
@ -231,7 +287,7 @@
/> />
<q-spinner-dots <q-spinner-dots
v-if="groupIsLoading" v-if="groupIsLoading"
class="csc-call-spinner" class="q-ml-auto"
color="primary" color="primary"
:size="24" :size="24"
/> />
@ -241,27 +297,27 @@
<div <div
v-if="isTimeoutOrUnconditional" v-if="isTimeoutOrUnconditional"
class="csc-cf-destination-cont row" class="csc-cf-destination-cont row"
:class="{ 'csc-cf-destination-disabled': !isEnabled }"
> >
<div <div
class="col col-xs-12 col-md-4 text-right" class="col-xs-4 col-md-4 text-right"
:class="{ 'csc-cf-destination-disabled': !isEnabled }"
> >
{{ toggleLabel }} {{ toggleLabel }}
</div> </div>
<div <div
class="col col-xs-12 col-md-2 text-left csc-cf-self-number-cont" class="text-left col-xs-2 col-md-2 csc-cf-dest-number-cont"
> >
{{ subscriberDisplayName }} {{ subscriberDisplayName }}
</div> </div>
<div <div
class="col col-xs-12 col-md-6" class="col-xs-6 col-md-6"
/> />
</div> </div>
<div <div
v-for="(destination, index) in group.destinations" v-for="(destination, index) in group.destinations"
:key="index" :key="destination.display_id"
> >
<csc-new-call-forward-destination <csc-new-call-forward-destination
ref="destination" ref="destination"
@ -276,47 +332,54 @@
<div <div
class="row csc-cf-destination-cont" class="row csc-cf-destination-cont"
> >
<div class="col col-xs-12 col-md-4 text-right" /> <div class="col-xs-4 col-md-4 text-right" />
<div <div
v-if="showAddDestBtn" v-if="showAddDestBtn"
class="col col-xs-12 col-md-2 text-left" class="col-xs-2 col-md-2 text-left"
:class="{ 'csc-cf-destination-disabled': !isEnabled }" :class="{ 'csc-cf-destination-disabled': !isEnabled }"
> >
<div <div
class="csc-cf-destination-add-destination" class="csc-cf-destination-add-destination"
>
<q-btn
flat
color="primary"
class=""
> >
<q-icon <q-icon
name="add" name="add"
color="primary" color="primary"
size="24px" size="24px"
/> />
{{ $t('pages.newCallForward.addDestinationLabel') }} {{ $t('pages.newCallForward.addDestinationLabel') }}
</div> <q-menu
<q-popover
ref="destTypeForm" ref="destTypeForm"
class="csc-cf-group-popover-bottom" :auto-close="true"
@open="showDestTypeForm()" @show="showDestTypeForm()"
@close="showNext()" @hide="showNext()"
> >
<csc-new-call-forward-destination-type-form <csc-new-call-forward-destination-type-form
ref="selectDestinationType" ref="selectDestinationType"
/> />
</q-popover> </q-menu>
<q-popover </q-btn>
</div>
<q-menu
ref="numberForm" ref="numberForm"
class="csc-cf-number-form csc-cf-group-popover-bottom" :no-parent-event="true"
:class="{ 'csc-cf-popover-hide': toggleNumberForm }" :class="{ 'csc-cf-popover-hide': toggleNumberForm }"
@open="showNewDestNumber()" @show="showNewDestNumber()"
> >
<csc-new-call-forward-add-destination-form <csc-new-call-forward-add-destination-form
ref="addDestinationForm" ref="addDestinationForm"
class="q-pa-md"
:enabled="true"
:group-name="group.name" :group-name="group.name"
:group-id="group.id" :group-id="group.id"
/> />
</q-popover> </q-menu>
</div> </div>
<div class="col col-xs-12 col-md-6 " /> <div class="col-xs-6 col-md-6 " />
</div> </div>
</div> </div>
</template> </template>
@ -336,7 +399,6 @@ import CscNewCallForwardAddDestinationForm from './CscNewCallForwardAddDestinati
import CscNewCallForwardEditSources from './CscNewCallForwardEditSources' import CscNewCallForwardEditSources from './CscNewCallForwardEditSources'
import CscNewCallForwardAddSourcesetForm from './CscNewCallForwardAddSourcesetForm' import CscNewCallForwardAddSourcesetForm from './CscNewCallForwardAddSourcesetForm'
import CscNewCallForwardAddWeekdayForm from './CscNewCallForwardAddWeekdayForm' import CscNewCallForwardAddWeekdayForm from './CscNewCallForwardAddWeekdayForm'
import CscNewCallForwardConditionTypeSelect from './CscNewCallForwardConditionTypeSelect'
import CscNewCallForwardDestinationTypeForm from './CscNewCallForwardDestinationTypeForm' import CscNewCallForwardDestinationTypeForm from './CscNewCallForwardDestinationTypeForm'
import CscNewCallForwardDateRange from './CscNewCallForwardDateRange' import CscNewCallForwardDateRange from './CscNewCallForwardDateRange'
export default { export default {
@ -348,7 +410,6 @@ export default {
CscNewCallForwardEditSources, CscNewCallForwardEditSources,
CscNewCallForwardAddSourcesetForm, CscNewCallForwardAddSourcesetForm,
CscNewCallForwardAddWeekdayForm, CscNewCallForwardAddWeekdayForm,
CscNewCallForwardConditionTypeSelect,
CscNewCallForwardDestinationTypeForm, CscNewCallForwardDestinationTypeForm,
CscNewCallForwardDateRange CscNewCallForwardDateRange
}, },
@ -380,7 +441,7 @@ export default {
action: null, action: null,
enabled: false, enabled: false,
day: null, day: null,
today: new Date() today: new Date().toString()
} }
}, },
computed: { computed: {
@ -393,9 +454,13 @@ export default {
'getGroupsLoaders', 'getGroupsLoaders',
'getSourcesets', 'getSourcesets',
'getTimesets', 'getTimesets',
'getFirstDestinationInCreation' 'getFirstDestinationInCreation',
'getSelectedDestinationType'
]), ]),
showAddDestBtn () { showAddDestBtn () {
if (this.isTempGroup) {
return false
}
for (const destination of this.group.destinations) { for (const destination of this.group.destinations) {
const dest = _.get(destination, 'destination', '') const dest = _.get(destination, 'destination', '')
if (_.endsWith(dest, 'voicebox.local')) { if (_.endsWith(dest, 'voicebox.local')) {
@ -449,12 +514,24 @@ export default {
return retVal return retVal
}, },
groupTimeRangeObj () { groupTimeRangeObj () {
let retVal = false, time let retVal = false, time, fromYear, fromMonth, fromDay, fromHour, fromMinute, toYear, toMonth, toDay, toHour, toMinute, dateFrom, dateTo
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]
fromYear = parseInt(time.year.split('-')[0])
fromMonth = parseInt(time.month.split('-')[0]) - 1
fromDay = parseInt(time.mday.split('-')[0])
fromHour = time.hour && time.hour.includes('-') ? parseInt(time.hour.split('-')[0]) : null
fromMinute = time.minute && time.minute.includes('-') ? parseInt(time.minute.split('-')[0]) : null
toYear = parseInt(time.year.split('-')[1])
toMonth = parseInt(time.month.split('-')[1]) - 1
toDay = parseInt(time.mday.split('-')[1])
toHour = time.hour && time.hour.includes('-') ? parseInt(time.hour.split('-')[1]) : null
toMinute = time.minute && time.minute.includes('-') ? parseInt(time.minute.split('-')[1]) : null
dateFrom = moment(new Date(fromYear, fromMonth, fromDay, fromHour, fromMinute), 0, 0)
dateTo = moment(new Date(toYear, toMonth, toDay, toHour, toMinute), 0, 0)
retVal = { 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(), dateFrom: fromHour ? dateFrom.format() : dateFrom.format('YYYY-MM-DD'),
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() dateTo: toHour ? dateTo.format() : dateTo.format('YYYY-MM-DD')
} }
} }
return retVal return retVal
@ -474,7 +551,7 @@ export default {
}, },
groupWeekdays () { groupWeekdays () {
let retVal = '' let retVal = ''
let times = _.get(this.timeSet, 'times', []) let times = _.cloneDeep(_.get(this.timeSet, 'times', []))
times = times.sort((a, b) => (parseInt(a.wday) > parseInt(b.wday)) ? 1 : ((parseInt(b.wday) > parseInt(a.wday)) ? -1 : 0)) times = times.sort((a, b) => (parseInt(a.wday) > parseInt(b.wday)) ? 1 : ((parseInt(b.wday) > parseInt(a.wday)) ? -1 : 0))
times.forEach((time, index) => { times.forEach((time, index) => {
const separator = (index === times.length - 1) ? '' : ', ' const separator = (index === times.length - 1) ? '' : ', '
@ -528,11 +605,11 @@ export default {
dayModel: { dayModel: {
get () { get () {
if (!this.timeSet) { if (!this.timeSet) {
return return ''
} }
const time = this.timeSet.times[0] const time = this.timeSet.times[0]
const dateN = new Date(parseInt(time.year), parseInt(time.month) - 1, parseInt(time.mday), 0, 0, 0, 0) const dateN = new Date(parseInt(time.year), parseInt(time.month) - 1, parseInt(time.mday), 0, 0, 0, 0)
return dateN return date.formatDate(dateN, 'YYYY/MM/DD')
}, },
set (value) { set (value) {
if (value !== '') { if (value !== '') {
@ -556,7 +633,7 @@ export default {
}, },
getFirstDestinationInCreation: function () { getFirstDestinationInCreation: function () {
if (this.getFirstDestinationInCreation === this.group.id.toString() && this.$refs.conditions) { if (this.getFirstDestinationInCreation === this.group.id.toString() && this.$refs.conditions) {
this.$refs.conditions.open() this.$refs.conditions.show()
} }
} }
}, },
@ -565,8 +642,10 @@ export default {
if (!this.firstDestinationInCreation) { if (!this.firstDestinationInCreation) {
this.isEnabled = await this.$store.dispatch('newCallForward/isGroupEnabled', { groupName: this.group.name, id: this.group.id }) this.isEnabled = await this.$store.dispatch('newCallForward/isGroupEnabled', { groupName: this.group.name, id: this.group.id })
} }
this.$store.dispatch('newCallForward/addGroupLoader', this.group.id)
await this.updateSourcesetNames() await this.updateSourcesetNames()
await this.updateTimeSetNames() await this.updateTimeSetNames()
this.$store.dispatch('newCallForward/removeGroupLoader', this.group.id)
} catch (err) { } catch (err) {
console.log(err) console.log(err)
} }
@ -580,10 +659,10 @@ export default {
this.$refs.addDestinationForm.add() this.$refs.addDestinationForm.add()
}, },
async showNext () { async showNext () {
switch (this.$refs.selectDestinationType.action) { switch (this.getSelectedDestinationType) {
case 'destination': case 'destination':
this.toggleNumberForm = false this.toggleNumberForm = false
this.$refs.numberForm.open() this.$refs.numberForm.show()
break break
case 'voicemail': case 'voicemail':
this.$store.dispatch('newCallForward/addGroupLoader', this.group.id) this.$store.dispatch('newCallForward/addGroupLoader', this.group.id)
@ -602,30 +681,34 @@ export default {
firstDestinationCmp.movePopoverToTop() firstDestinationCmp.movePopoverToTop()
} }
firstDestinationCmp.$refs.destTypeForm.open() firstDestinationCmp.$refs.destTypeForm.show()
},
setCondition (action) {
this.action = action
this.$refs.conditions.hide()
}, },
showConditionForm () { showConditionForm () {
if (this.isTempGroup) { if (this.isTempGroup) {
this.showFirstDestMenu() this.showFirstDestMenu()
return return
} }
const action = this.$refs.addCondition.action const action = this.action
switch (action) { switch (action) {
case 'addFromCondition': case 'addFromCondition':
this.toggleConditionFromForm = false this.toggleConditionFromForm = false
this.$refs.onlineSourceset.open() this.$refs.onlineSourceset.show()
break break
case 'addDateIsCondition': case 'addDateIsCondition':
this.toggleIsDatePanel = false this.toggleIsDatePanel = false
this.$refs.day.open() this.$refs.dayWidgetFromMenu.show()
break break
case 'addDateRangeCondition': case 'addDateRangeCondition':
this.toggleIsRangePanel = false this.toggleIsRangePanel = false
this.$refs.daterange.open() this.$refs.daterangeFromMenu.show()
break break
case 'addWeekdayCondition': case 'addWeekdayCondition':
this.toggleWeekdayPanel = false this.toggleWeekdayPanel = false
this.$refs.weekdayPanel.open() this.$refs.weekdayPanel.show()
break break
} }
}, },
@ -658,7 +741,7 @@ export default {
this.$store.dispatch('newCallForward/removeGroupLoader', this.group.id) this.$store.dispatch('newCallForward/removeGroupLoader', this.group.id)
}, },
openConditionsPopover () { openConditionsPopover () {
this.$refs.conditions.open() this.$refs.conditions.show()
}, },
showConditions () { showConditions () {
this.$refs.addCondition.add() this.$refs.addCondition.add()
@ -676,7 +759,7 @@ export default {
this.toggleConditionFromForm = true this.toggleConditionFromForm = true
}, },
resetAction () { resetAction () {
this.$refs.addCondition.action = null this.action = null
}, },
resetWeekdayCondition () { resetWeekdayCondition () {
this.toggleWeekdayPanel = true this.toggleWeekdayPanel = true
@ -731,16 +814,6 @@ export default {
console.log(e) console.log(e)
} }
}, },
showQDateContainer () {
this.toggleIsDatePanel = false
this.$refs.day.open()
},
showQDate () {
this.$refs.dayWidget.open()
},
showDateRange () {
this.$refs.dateRangePopover.add()
},
showConfirmDeleteTimesetDialog () { showConfirmDeleteTimesetDialog () {
this.$refs.confirmDeleteTimesetDialog.open() this.$refs.confirmDeleteTimesetDialog.open()
}, },
@ -775,7 +848,7 @@ export default {
}) })
if (!this.timeSet) { if (!this.timeSet) {
this.$store.dispatch('newCallForward/addTimesetToGroup', { await this.$store.dispatch('newCallForward/addTimesetToGroup', {
name: this.group.name, name: this.group.name,
groupId: this.group.id, groupId: this.group.id,
timeSetId: timseSetId timeSetId: timseSetId
@ -788,7 +861,10 @@ export default {
} }
}, },
rangeChanged () { rangeChanged () {
this.$refs.daterange.open() this.$refs.daterange.show()
},
minDate (day) {
return day >= date.formatDate(new Date(), 'YYYY/MM/DD')
} }
} }
} }
@ -797,8 +873,12 @@ export default {
<style lang="stylus" rel="stylesheet/stylus"> <style lang="stylus" rel="stylesheet/stylus">
.csc-cf-group .csc-cf-group
width 100% width 100%
.csc-cf-toggle-group
height 25px !important
.csc-cf-destination-cont
width 100%
margin-bottom 4px
.csc-cf-group-title-bold .csc-cf-group-title-bold
text-align right
font-weight bold font-weight bold
.csc-cf-group-cont .csc-cf-group-cont
position relative position relative
@ -807,21 +887,14 @@ export default {
.csc-cf-destination-value .csc-cf-destination-value
text-align center text-align center
.csc-cf-destination-add-condition .csc-cf-destination-add-condition
font-size 16px font-size 14px
.csc-cf-destination-add-destination .csc-cf-destination-add-destination
padding-left 25px
width 250px width 250px
white-space nowrap white-space nowrap
overflow hidden overflow hidden
text-overflow ellipsis text-overflow ellipsis
color $primary color $primary
cursor pointer cursor pointer
.csc-cf-group-popover-bottom
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

@ -3,15 +3,14 @@
v-if="enabled" v-if="enabled"
class="csc-form" class="csc-form"
> >
<csc-new-call-forward-input <csc-input
v-model="number" v-model="number"
:label="$t('callBlocking.number')" :label="$t('callBlocking.number')"
:prefilled="destination"
@submit="save" @submit="save"
@error="error" @error="error"
/> />
<div <div
class="csc-form-actions row justify-center csc-actions-cont" class="row justify-center csc-actions-cont"
> >
<q-btn <q-btn
flat flat
@ -42,7 +41,7 @@
</template> </template>
<script> <script>
import CscNewCallForwardInput from './CscNewCallForwardInput' import CscInput from '../../form/CscInput'
import CscSpinner from '../../CscSpinner' import CscSpinner from '../../CscSpinner'
import { import {
showGlobalError showGlobalError
@ -54,12 +53,12 @@ import {
export default { export default {
name: 'CscNewCallForwardAddDestinationForm', name: 'CscNewCallForwardAddDestinationForm',
components: { components: {
CscNewCallForwardInput, CscInput,
CscSpinner CscSpinner
}, },
props: { props: {
destination: { destination: {
type: Object, type: String,
default: null default: null
}, },
index: { index: {
@ -79,7 +78,7 @@ export default {
default: '' default: ''
}, },
groupId: { groupId: {
type: String, type: [String, Number],
default: null default: null
}, },
firstDestinationInCreation: { firstDestinationInCreation: {
@ -105,6 +104,9 @@ export default {
return this.numberError || this.disable || this.loading return this.numberError || this.disable || this.loading
} }
}, },
mounted () {
this.number = this.destination
},
updated () { updated () {
if (Number.isInteger(this.index)) { if (Number.isInteger(this.index)) {
this.destinationIndex = this.index this.destinationIndex = this.index
@ -126,14 +128,11 @@ export default {
}) })
} else { } else {
if (forwardGroup.id.toString().includes('temp-')) { // unexisting group if (forwardGroup.id.toString().includes('temp-')) { // unexisting group
forwardGroup.destinations[0].simple_destination = this.number // optimistic UI update :)
const newGroupId = await this.$store.dispatch('newCallForward/addForwardGroup', { const newGroupId = await this.$store.dispatch('newCallForward/addForwardGroup', {
name: forwardGroupName, name: forwardGroupName,
destination: this.number destination: this.number
}) })
await this.$store.dispatch('newCallForward/loadForwardGroups') await this.$store.dispatch('newCallForward/loadForwardGroups')
if (this.destinationIndex === 0 && this.firstDestinationInCreation) { if (this.destinationIndex === 0 && this.firstDestinationInCreation) {
await this.$store.dispatch('newCallForward/setFirstDestinationInCreation', newGroupId) await this.$store.dispatch('newCallForward/setFirstDestinationInCreation', newGroupId)
} }
@ -148,17 +147,13 @@ export default {
this.$store.dispatch('newCallForward/removeGroupLoader', this.groupId) this.$store.dispatch('newCallForward/removeGroupLoader', this.groupId)
}, },
cancel () { cancel () {
this.number = ''
this.enabled = false this.enabled = false
this.$parent.close()
}, },
add () { add () {
this.number = ''
this.enabled = true this.enabled = true
}, },
close () { close () {
this.enabled = false this.enabled = false
this.$parent.close()
}, },
reset () { reset () {
this.cancel() this.cancel()
@ -171,6 +166,4 @@ export default {
</script> </script>
<style lang="stylus" rel="stylesheet/stylus"> <style lang="stylus" rel="stylesheet/stylus">
.csc-actions-cont
margin-bottom 15px
</style> </style>

@ -3,14 +3,14 @@
v-if="enabled" v-if="enabled"
class="csc-form" class="csc-form"
> >
<csc-new-call-forward-input-text <csc-input
v-model="name" v-model="name"
:label="$t('pages.newCallForward.sourcesetName')" :label="$t('pages.newCallForward.sourcesetName')"
@submit="save" @submit="save"
@error="errorName" @error="errorName"
/> />
<csc-new-call-forward-input <csc-call-input
v-model="number" v-model="number"
:label="$t('callBlocking.number')" :label="$t('callBlocking.number')"
@submit="save" @submit="save"
@ -18,7 +18,7 @@
/> />
<div <div
class="csc-form-actions row justify-center csc-actions-cont" class="row justify-center csc-actions-cont"
> >
<q-btn <q-btn
flat flat
@ -49,8 +49,8 @@
</template> </template>
<script> <script>
import CscNewCallForwardInput from './CscNewCallForwardInput' import CscCallInput from '../../form/CscCallInput'
import CscNewCallForwardInputText from './CscNewCallForwardInputText' import CscInput from '../../form/CscInput'
import CscSpinner from '../../CscSpinner' import CscSpinner from '../../CscSpinner'
import { import {
showGlobalError showGlobalError
@ -62,8 +62,8 @@ import {
export default { export default {
name: 'CscNewCallForwardAddSourcesetForm', name: 'CscNewCallForwardAddSourcesetForm',
components: { components: {
CscNewCallForwardInput, CscCallInput,
CscNewCallForwardInputText, CscInput,
CscSpinner CscSpinner
}, },
props: { props: {
@ -72,7 +72,7 @@ export default {
default: '' default: ''
}, },
groupId: { groupId: {
type: String, type: [String, Number],
default: null default: null
} }
}, },
@ -112,7 +112,7 @@ export default {
return return
} }
try { try {
this.close() this.$emit('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,
@ -133,7 +133,7 @@ export default {
this.number = '' this.number = ''
this.name = '' this.name = ''
this.enabled = false this.enabled = false
this.$parent.close() this.$emit('close')
}, },
add () { add () {
this.number = '' this.number = ''
@ -142,7 +142,7 @@ export default {
}, },
close () { close () {
this.enabled = false this.enabled = false
this.$parent.close() this.$emit('close')
}, },
reset () { reset () {
this.cancel() this.cancel()
@ -158,6 +158,4 @@ export default {
</script> </script>
<style lang="stylus" rel="stylesheet/stylus"> <style lang="stylus" rel="stylesheet/stylus">
.csc-actions-cont
margin-bottom 15px
</style> </style>

@ -16,7 +16,7 @@
/> />
</div> </div>
<div <div
class="csc-form-actions row justify-center csc-actions-cont" class="row justify-center csc-actions-cont"
> >
<q-btn <q-btn
class="day-btn" class="day-btn"
@ -76,7 +76,7 @@
</q-btn> </q-btn>
</div> </div>
<div <div
class="csc-form-actions row justify-center csc-actions-cont" class="row justify-center csc-actions-cont"
> >
<q-btn <q-btn
:disabled="weekdays.length < 1" :disabled="weekdays.length < 1"
@ -130,7 +130,7 @@ export default {
default: '' default: ''
}, },
groupId: { groupId: {
type: String, type: [String, Number],
default: null default: null
}, },
id: { id: {
@ -180,7 +180,7 @@ export default {
this.timeSetId = await this.$store.dispatch('newCallForward/createTimeSet', this.timesetName) this.timeSetId = await this.$store.dispatch('newCallForward/createTimeSet', this.timesetName)
} }
this.$store.dispatch('newCallForward/addTimesetToGroup', { await this.$store.dispatch('newCallForward/addTimesetToGroup', {
name: this.groupName, name: this.groupName,
groupId: this.groupId, groupId: this.groupId,
timeSetId: this.timeSetId timeSetId: this.timeSetId
@ -208,7 +208,7 @@ export default {
this.close() this.close()
}, },
close () { close () {
this.$parent.close() this.$emit('close')
this.enabled = false this.enabled = false
}, },
add () { add () {
@ -237,8 +237,6 @@ export default {
</script> </script>
<style lang="stylus" rel="stylesheet/stylus"> <style lang="stylus" rel="stylesheet/stylus">
.csc-actions-cont
margin-bottom 15px
.day-btn .day-btn
margin 5px margin 5px
background rgba(37,51,85,0.8) background rgba(37,51,85,0.8)

@ -1,133 +0,0 @@
<template>
<div
v-if="enabled"
>
<div
v-if="disableSourcesetMenu"
class="csc-cf-dest-type"
@click="addFromCondition()"
>
{{ $t('pages.newCallForward.fromLabel') }}
</div>
<div
v-if="disableTimesetMenu"
class="csc-cf-dest-type"
@click="addDateIsCondition()"
>
{{ $t('pages.newCallForward.dateIsLabel') }}
</div>
<div
v-if="disableDateRangeMenu"
ref="daterangeItem"
class="csc-cf-dest-type"
@click="addDateRangeCondition()"
>
{{ $t('pages.newCallForward.dateRangeLabel') }}
</div>
<div
v-if="disableWeekdaysMenu"
class="csc-cf-dest-type"
@click="addWeekdayCondition()"
>
{{ $t('pages.newCallForward.weekdaysLabel') }}
</div>
</div>
</template>
<script>
export default {
name: 'CscNewCallForwardConditionTypeSelect',
props: {
groupId: {
type: String,
default: null
},
groupName: {
type: String,
default: ''
},
disableSourcesetMenu: {
type: Boolean,
default: false
},
disableTimesetMenu: {
type: Boolean,
default: false
},
disableDateRangeMenu: {
type: Boolean,
default: false
},
disableWeekdaysMenu: {
type: Boolean,
default: false
}
},
data () {
return {
enabled: true,
action: null,
timesetName: null
}
},
computed: {
allFieldsFilled () {
return this.rangeDateModel.from !== null &&
this.rangeDateModel.to !== null &&
this.rangeTimeModel.from !== null &&
this.rangeTimeModel.to !== null
}
},
mounted () {
this.timesetName = 'timeset-' + this.groupId
},
methods: {
addFromCondition () {
this.action = 'addFromCondition'
this.$parent.close()
},
addDateIsCondition () {
this.action = 'addDateIsCondition'
this.$parent.close()
},
addDateRangeCondition () {
this.action = 'addDateRangeCondition'
this.$parent.close()
},
addWeekdayCondition () {
this.action = 'addWeekdayCondition'
this.$parent.close()
},
cancel () {
this.action = null
this.enabled = false
this.$parent.close()
},
add () {
this.enabled = true
},
close () {
this.action = null
this.enabled = false
this.$parent.close()
},
showQDate () {
this.$refs.dayWidget.open()
}
}
}
</script>
<style lang="stylus" rel="stylesheet/stylus">
.csc-cf-dest-type
min-width 100px
padding 10px
cursor pointer
.csc-cf-dest-type:hover
background $main-menu-item-hover-background
.csc-cf-calendar-day
padding 20px
min-width 400px
.q-datetime-weekdays
color $tertiary
</style>

@ -1,120 +1,161 @@
<template> <template>
<div <div
v-if="enabled"
class="csc-form" class="csc-form"
> >
<div <div
class="csc-cf-daterange-popovers-container" class="csc-cf-daterange-popovers-container"
> >
<q-datetime <q-popup-proxy
ref="dayFromProxy"
class="csc-cf-datetime"
>
<q-date
ref="dayFrom" ref="dayFrom"
v-model="dayFrom" v-model="dayFrom"
mask="YYYY/MM/DD"
:options="minDateFrom"
:no-unset="true"
>
<div class="row items-center justify-end q-gutter-sm">
<q-btn
v-close-popup
flat
color="primary"
icon="done"
>
{{ $t('buttons.confirm') }}
</q-btn>
</div>
</q-date>
</q-popup-proxy>
<q-popup-proxy
ref="dayToProxy"
class="csc-cf-datetime" class="csc-cf-datetime"
type="date" >
format="DD/MM/YYYY" <q-date
:min="today"
@blur="openParent()"
/>
<q-datetime
ref="dayTo" ref="dayTo"
v-model="dayTo" v-model="dayTo"
mask="YYYY/MM/DD"
:options="minDateTo"
:no-unset="true"
>
<div class="row items-center justify-end q-gutter-sm">
<q-btn
v-close-popup
flat
color="primary"
icon="done"
>
{{ $t('buttons.confirm') }}
</q-btn>
</div>
</q-date>
</q-popup-proxy>
<q-popup-proxy
ref="hourFromProxy"
class="csc-cf-datetime" class="csc-cf-datetime"
type="date" >
format="DD/MM/YYYY" <q-time
:min="dayFrom"
@blur="openParent()"
/>
<q-datetime
ref="hourFrom" ref="hourFrom"
v-model="hourFrom" v-model="hourFrom"
:no-unset="true"
>
<div class="row items-center justify-end q-gutter-sm">
<q-btn
v-close-popup
flat
color="primary"
icon="done"
>
{{ $t('buttons.confirm') }}
</q-btn>
</div>
</q-time>
</q-popup-proxy>
<q-popup-proxy
ref="hourToProxy"
class="csc-cf-datetime" class="csc-cf-datetime"
type="time" >
format="HH:MM" <q-time
@blur="openParent()"
/>
<q-datetime
ref="hourTo" ref="hourTo"
v-model="hourTo" v-model="hourTo"
class="csc-cf-datetime" :no-unset="true"
type="time"
format="HH:MM"
:min="hourFrom"
@blur="openParent()"
/>
</div>
<div
class="csc-cf-daterange-fields-cont csc-form-actions row justify-center csc-actions-cont"
> >
<q-field <div class="row items-center justify-end q-gutter-sm">
dark <q-btn
label="Date range" v-close-popup
:label-width="11" flat
class="csc-cf-popover-daterange-title" color="primary"
/> icon="done"
>
{{ $t('buttons.confirm') }}
</q-btn>
</div>
</q-time>
</q-popup-proxy>
</div> </div>
<div <div
class="csc-cf-daterange-fields-cont csc-form-actions row justify-center csc-actions-cont" class="csc-actions-cont row justify-center"
> >
<q-input <q-input
v-model="dayFromFormatted" v-model="dayFromFormatted"
dark dark
:placeholder="$t('pages.newCallForward.dateRangeStartDate')" :placeholder="$t('pages.newCallForward.dateRangeStartDate')"
:after="[ @click="openDayFrom()"
{ >
icon: 'today', <template v-slot:append>
handler () { <q-icon
openDayFrom(); name="today"
}
}
]"
@click="openDayFrom()" @click="openDayFrom()"
/> />
</template>
</q-input>
<q-input <q-input
v-model="dayToFormatted" v-model="dayToFormatted"
:disable="!dayFrom"
dark dark
:placeholder="$t('pages.newCallForward.dateRangeEndDate')" :placeholder="$t('pages.newCallForward.dateRangeEndDate')"
:after="[ @click="openDayTo()"
{ >
icon: 'today', <template v-slot:append>
handler () { <q-icon
openDayTo(); name="today"
}
}
]"
@click="openDayTo()" @click="openDayTo()"
/> />
</template>
</q-input>
</div> </div>
<div <div
class="csc-form-actions row justify-center csc-actions-cont" class="csc-actions-cont row justify-center"
> >
<q-input <q-input
v-model="hourFromFormatted" v-model="hourFromFormatted"
dark dark
:disable="!dayFrom"
:placeholder="$t('pages.newCallForward.dateRangeStartTime')" :placeholder="$t('pages.newCallForward.dateRangeStartTime')"
:after="[ @click="openHourFrom()"
{ >
icon: 'access_time', <template v-slot:append>
handler () { <q-icon
openHourFrom(); name="access_time"
}
}
]"
@click="openHourFrom()" @click="openHourFrom()"
/> />
</template>
</q-input>
<q-input <q-input
v-model="hourToFormatted" v-model="hourToFormatted"
dark dark
:placeholder="$t('pages.newCallForward.dateRangeEndTime')" :placeholder="$t('pages.newCallForward.dateRangeEndTime')"
:after="[ :disable="!dayTo"
{ @click="openHourTo()"
icon: 'access_time', >
handler () { <template v-slot:append>
openHourTo(); <q-icon
} name="access_time"
}
]"
@click="openHourTo()" @click="openHourTo()"
/> />
</template>
</q-input>
</div> </div>
<div <div
class="csc-cf-daterange-btn-cont" class="csc-cf-daterange-btn-cont"
@ -139,7 +180,7 @@
flat flat
color="default" color="default"
icon="clear" icon="clear"
@click="cancelTimerange(); resetTimeRange()" @click="resetTimeRange(); close()"
> >
{{ $t('buttons.cancel') }} {{ $t('buttons.cancel') }}
</q-btn> </q-btn>
@ -147,7 +188,7 @@
flat flat
color="primary" color="primary"
icon="done" icon="done"
:disable="!allFieldsFilled" :disable="!isDateReadyForSubmit"
@click="save();" @click="save();"
> >
{{ $t('buttons.save') }} {{ $t('buttons.save') }}
@ -172,7 +213,7 @@ export default {
default: '' default: ''
}, },
groupId: { groupId: {
type: String, type: [String, Number],
default: null default: null
}, },
groupTimeRange: { groupTimeRange: {
@ -190,14 +231,13 @@ export default {
}, },
data () { data () {
return { return {
enabled: false,
timesetId: null, timesetId: null,
timesetName: null, timesetName: null,
dayFrom: null,
dayTo: null,
hourFrom: null,
hourTo: null,
today: new Date(), today: new Date(),
dayFrom: '',
dayTo: '',
hourFrom: '',
hourTo: '',
dayRegExp: /^([0-2][0-9]|(3)[0-1])(\/)(((0)[0-9])|((1)[0-2]))(\/)\d{4}$/i, 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]$/ timeRegExp: /^(0[0-9]|1[0-9]|2[0-3]):[0-5][0-9]$/
} }
@ -219,6 +259,9 @@ export default {
}, },
hourFromFormatted () { hourFromFormatted () {
let time = this.hourFrom ? this.hourFrom : '' let time = this.hourFrom ? this.hourFrom : ''
if (!time.toString().includes(':')) {
return ''
}
if (time.toString().length > 0 && !time.match(this.timeRegExp)) { if (time.toString().length > 0 && !time.match(this.timeRegExp)) {
time = date.formatDate(time, 'hh:mm') time = date.formatDate(time, 'hh:mm')
} }
@ -226,67 +269,60 @@ export default {
}, },
hourToFormatted () { hourToFormatted () {
let time = this.hourTo ? this.hourTo : '' let time = this.hourTo ? this.hourTo : ''
if (!time.toString().includes(':')) {
return ''
}
if (time.toString().length > 0 && !time.match(this.timeRegExp)) { if (time.toString().length > 0 && !time.match(this.timeRegExp)) {
time = date.formatDate(time, 'hh:mm') time = date.formatDate(time, 'hh:mm')
} }
return time return time
}, },
allFieldsFilled () { isDateReadyForSubmit () {
return this.dayFrom !== null && if (this.dayFrom !== '' && this.dayTo !== '') {
this.dayTo !== null && const ret = (this.hourFrom !== '' && this.hourTo !== '') || (this.hourFrom === '' && this.hourTo === '')
this.hourFrom !== null && return ret
this.hourTo !== null }
return false
} }
}, },
mounted () { mounted () {
this.setDaysAndTimes() this.setDaysAndTimes()
}, },
methods: { methods: {
openParent () {
this.$emit('open-daterange-popover')
},
openDayFrom () { openDayFrom () {
this.$refs.dayFrom.open() const splitDate = this.dayFromFormatted.split('/')
this.dayFrom = [splitDate[2], splitDate[1], splitDate[0]].join('/')
this.$refs.dayFromProxy.show()
}, },
openDayTo () { openDayTo () {
this.$refs.dayTo.open() const splitDate = this.dayToFormatted.split('/')
this.dayTo = [splitDate[2], splitDate[1], splitDate[0]].join('/')
this.$refs.dayToProxy.show()
}, },
openHourFrom () { openHourFrom () {
this.$refs.hourFrom.open() this.hourFrom = this.hourFromFormatted
this.$refs.hourFromProxy.show()
}, },
openHourTo () { openHourTo () {
this.$refs.hourTo.open() this.hourTo = this.hourToFormatted
}, this.$refs.hourToProxy.show()
cancel () {
this.close()
},
close () {
this.$parent.close()
this.enabled = false
},
add () {
this.enabled = true
},
showRemoveDialog () {
}, },
formatRange (startDate, endDate, startTime, endTime) { formatRange (startDate, endDate, startTime, endTime) {
const startDateOnly = startDate.toString().split('T')[0] startTime = startTime.includes('T') ? date.formatDate(startTime, 'hh:mm') : startTime
const endDateOnly = endDate.toString().split('T')[0] endTime = endTime.includes('T') ? date.formatDate(endTime, 'hh:mm') : endTime
const startTimeOnly = startTime.toString().split('T')[1] const getDateObj = date => (([year, month, day]) => ({ day, year, month }))(date.includes('T') ? date.split('T')[0].split('-') : date.includes('/') ? date.split('/') : date.split('-'))
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 getTimeObj = time => (([hour, minute, second]) => ({ hour, minute, second }))(time.split(':'))
const startDateObj = getDateObj(startDateOnly) const startDateObj = getDateObj(startDate)
const endDateObj = getDateObj(endDateOnly) const endDateObj = getDateObj(endDate)
const startTimeObj = getTimeObj(startTimeOnly) const startTimeObj = getTimeObj(startTime)
const endTimeObj = getTimeObj(endTimeOnly) const endTimeObj = getTimeObj(endTime)
return [ return [
{ {
year: startDateObj.year + '-' + endDateObj.year, year: startDateObj.year + '-' + endDateObj.year,
month: startDateObj.month + '-' + endDateObj.month, month: startDateObj.month + '-' + endDateObj.month,
mday: startDateObj.day + '-' + endDateObj.day, mday: startDateObj.day + '-' + endDateObj.day,
hour: startTimeObj.hour + '-' + endTimeObj.hour, hour: startTimeObj.hour && endTimeObj.hour ? startTimeObj.hour + '-' + endTimeObj.hour : null,
minute: startTimeObj.minute + '-' + endTimeObj.minute minute: startTimeObj.minute && endTimeObj.minute ? startTimeObj.minute + '-' + endTimeObj.minute : null
} }
] ]
}, },
@ -298,7 +334,7 @@ export default {
} }
const timeSetId = await this.$store.dispatch('newCallForward/createTimeSet', this.timesetName) const timeSetId = await this.$store.dispatch('newCallForward/createTimeSet', this.timesetName)
this.$store.dispatch('newCallForward/addTimesetToGroup', { await this.$store.dispatch('newCallForward/addTimesetToGroup', {
name: this.groupName, name: this.groupName,
groupId: this.groupId, groupId: this.groupId,
timeSetId: timeSetId timeSetId: timeSetId
@ -309,7 +345,7 @@ export default {
}) })
this.$store.dispatch('newCallForward/setTimeset', updatedTimeset) this.$store.dispatch('newCallForward/setTimeset', updatedTimeset)
this.$store.dispatch('newCallForward/removeGroupLoader', this.groupId) this.$store.dispatch('newCallForward/removeGroupLoader', this.groupId)
this.cancelTimerange() this.close()
}, },
async deleteTimeset () { async deleteTimeset () {
try { try {
@ -322,70 +358,44 @@ export default {
} }
}, },
resetTimeRange () { resetTimeRange () {
this.dayFrom = null this.dayFrom = ''
this.dayTo = null this.dayTo = ''
this.hourFrom = null this.hourFrom = ''
this.hourTo = null this.hourTo = ''
},
cancelTimerange () {
this.$parent.close()
this.action = null
this.enabled = false
}, },
setDaysAndTimes () { setDaysAndTimes () {
if (this.groupTimeRange) { if (this.groupTimeRange) {
this.dayFrom = this.groupTimeRange.dateFrom this.dayFrom = this.groupTimeRange.dateFrom
this.dayTo = this.groupTimeRange.dateTo this.dayTo = this.groupTimeRange.dateTo
this.hourFrom = this.groupTimeRange.dateFrom this.hourFrom = this.groupTimeRange.dateFrom.includes('T') ? this.groupTimeRange.dateFrom : ''
this.hourTo = this.groupTimeRange.dateTo this.hourTo = this.groupTimeRange.dateTo.includes('T') ? this.groupTimeRange.dateTo : ''
} else { } else {
this.resetTimeRange() this.resetTimeRange()
} }
}, },
showRemoveDateRangeDialog () { showRemoveDateRangeDialog () {
this.$parent.close()
this.$emit('confirm-delete') this.$emit('confirm-delete')
},
minDateFrom (day) {
return day >= date.formatDate(new Date(), 'YYYY/MM/DD')
},
minDateTo (day) {
return date.getDateDiff(day, this.dayFrom) > 0
},
close () {
this.$emit('close')
} }
} }
} }
</script> </script>
<style lang="stylus" rel="stylesheet/stylus"> <style lang="stylus" rel="stylesheet/stylus">
.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 .csc-cf-daterange-btn-cont
margin-top 10px
width 100% width 100%
text-align center text-align center
.q-menu
min-width auto !important
.q-datetime-days div:not(.q-datetime-day-active), .q-datetime-days div:not(.q-datetime-day-active),
.q-datetime-dark, .q-datetime-dark,
.q-datetime-range .q-datetime-input .q-input-target, .q-datetime-range .q-datetime-input .q-input-target,
@ -396,5 +406,10 @@ export default {
.q-datetime-range.row .q-datetime-range-right, .q-datetime-range.row .q-datetime-range-right,
.q-datetime-range.row .q-datetime-range-left .q-datetime-range.row .q-datetime-range-left
padding-left 20px padding-left 20px
.csc-actions-cont
.q-input
margin-left 10px
margin-right 20px
max-width 160px
</style> </style>

@ -3,46 +3,54 @@
class="row csc-cf-destination-cont" class="row csc-cf-destination-cont"
:class="{ 'csc-cf-removed-destination': removeInProgress }" :class="{ 'csc-cf-removed-destination': removeInProgress }"
> >
<div class="col col-xs-12 col-md-4 text-right"> <div class="col-xs-4 col-md-4 text-right">
{{ labelTimeout }} {{ labelTimeout }}
<span <span
v-if="!allCallsFwd" v-if="!allCallsFwd"
class="csc-cf-timeout csc-cf-destination-link" class="csc-cf-timeout csc-cf-destination-link"
> >
{{ destinationTimeout }} {{ destinationTimeout }}
<q-popover <q-menu
ref="timeoutForm" ref="timeoutForm"
self="top left" class="csc-cf-timeout-menu"
class="csc-cf-timeout-form" @hide="saveTimeout()"
@close="saveTimeout()" >
<q-item
class="csc-cf-timeout-item"
> >
<q-slider <q-slider
ref="timeout"
v-model="destinationTimeout" v-model="destinationTimeout"
label label
label-always label-always
:step="5" :step="5"
:min="5" :min="5"
:max="60" :max="60"
label-text-color="secondary"
markers markers
snap snap
/> />
</q-popover> </q-item>
</q-menu>
</span> </span>
{{ labelFront }} {{ labelFront }}
</div> </div>
<div class="col text-left col-xs-12 col-md-2 csc-cf-dest-number-cont"> <div class="text-left col-xs-2 col-md-2 csc-cf-dest-number-cont">
<div <div
:class="{ 'csc-cf-destination-link': !isVoiceMail() }" :class="{ 'csc-cf-destination-link': !isVoiceMail() }"
class="csc-cf-destination" class="csc-cf-destination"
@click="toggleDestMenu()"
> >
{{ labelNumber }} {{ labelNumber }}
<q-popover <q-menu
v-if="!isVoiceMail()" v-if="!isVoiceMail()"
ref="destTypeForm" ref="destTypeForm"
class="csc-cf-dest-popover-bottom" class="csc-cf-dest-popover-bottom"
:class="{ 'csc-cf-popover-hide': disableDestType, 'csc-cf-popover-to-top': popoverToTop, 'csc-cf-popover-timeout-to-top': popoverTimeoutToTop }" :class="{ 'csc-cf-popover-hide': disableDestType, 'csc-cf-popover-to-top': popoverToTop, 'csc-cf-popover-timeout-to-top': popoverTimeoutToTop }"
@open="showDestTypeForm()" :auto-close="true"
@close="showNext()" :no-parent-event="true"
@show="showDestTypeForm()"
@hide="showNext()"
> >
<div <div
v-if="firstDestinationInCreation && (popoverToTop || popoverTimeoutToTop)" v-if="firstDestinationInCreation && (popoverToTop || popoverTimeoutToTop)"
@ -53,27 +61,29 @@
<csc-new-call-forward-destination-type-form <csc-new-call-forward-destination-type-form
ref="selectDestinationType" ref="selectDestinationType"
/> />
</q-popover> </q-menu>
<q-popover <q-menu
v-if="!isVoiceMail()" v-if="!isVoiceMail()"
ref="numberForm" ref="numberForm"
class="csc-cf-number-form csc-cf-dest-popover-bottom" :no-parent-event="true"
class="csc-cf-dest-popover-bottom"
:class="{ 'csc-cf-popover-hide': disableNumberPopover, 'csc-cf-popover-to-top': popoverToTop, 'csc-cf-popover-timeout-to-top': popoverTimeoutToTop }" :class="{ 'csc-cf-popover-hide': disableNumberPopover, 'csc-cf-popover-to-top': popoverToTop, 'csc-cf-popover-timeout-to-top': popoverTimeoutToTop }"
@open="showNumberForm()" @show="showNumberForm()"
@close="movePopoverToInitialPos(); movePopoverTimeoutToInitialPos()" @hide="movePopoverToInitialPos(); movePopoverTimeoutToInitialPos()"
> >
<csc-new-call-forward-add-destination-form <csc-new-call-forward-add-destination-form
ref="addDestinationForm" ref="addDestinationForm"
class="q-pa-md"
:index="destinationIndex" :index="destinationIndex"
:destination="destinationNumber" :destination="destinationNumber"
:group-name="groupName" :group-name="groupName"
:group-id="groupId" :group-id="groupId"
:first-destination-in-creation="firstDestinationInCreation" :first-destination-in-creation="firstDestinationInCreation"
/> />
</q-popover> </q-menu>
</div> </div>
</div> </div>
<div class="col col-xs-12 col-md-5 csc-cf-destination-actions"> <div class="col col-xs-5 col-md-5 csc-cf-destination-actions">
<q-icon <q-icon
name="delete" name="delete"
color="negative" color="negative"
@ -111,7 +121,7 @@ export default {
default: false default: false
}, },
groupId: { groupId: {
type: String, type: [String, Number],
default: null default: null
}, },
groupName: { groupName: {
@ -141,6 +151,7 @@ export default {
}, },
computed: { computed: {
...mapGetters('newCallForward', [ ...mapGetters('newCallForward', [
'getSelectedDestinationType',
'getOwnPhoneTimeout' 'getOwnPhoneTimeout'
]), ]),
disableDestType () { disableDestType () {
@ -187,10 +198,10 @@ export default {
this.destinationIndex = this.index this.destinationIndex = this.index
}, },
async showNext () { async showNext () {
switch (this.$refs.selectDestinationType.action) { switch (this.getSelectedDestinationType) {
case 'destination': case 'destination':
this.toggleNumberForm = false this.toggleNumberForm = false
this.$refs.numberForm.open() this.$refs.numberForm.show()
break break
case 'voicemail': case 'voicemail':
this.$store.dispatch('newCallForward/addGroupLoader', this.groupId) this.$store.dispatch('newCallForward/addGroupLoader', this.groupId)
@ -218,6 +229,16 @@ export default {
this.popoverTimeoutToTop = false this.popoverTimeoutToTop = false
} }
}, },
toggleDestMenu () {
if (this.destinationNumber === 'Voicemail') {
return
}
if (this.destinationNumber && this.destinationNumber !== ' ') {
this.$refs.numberForm.show()
} else {
this.$refs.destTypeForm.show()
}
},
showNumberForm () { showNumberForm () {
this.$refs.addDestinationForm.add() this.$refs.addDestinationForm.add()
}, },
@ -282,9 +303,6 @@ export default {
</script> </script>
<style lang="stylus" rel="stylesheet/stylus"> <style lang="stylus" rel="stylesheet/stylus">
.csc-cf-destination-cont
width 100%
padding 5px
.csc-cf-timeout, .csc-cf-timeout,
.csc-cf-destination .csc-cf-destination
width 100px width 100px
@ -295,13 +313,15 @@ export default {
.csc-cf-destination-link .csc-cf-destination-link
color $primary color $primary
cursor pointer cursor pointer
.csc-cf-timeout-form .csc-cf-timeout-menu
height 40px
.csc-cf-timeout-item
min-width 200px min-width 200px
padding 0 20px 20px 20px padding 30px 20px 20px 20px
.csc-cf-number-form
padding 0 20px 0 20px
.csc-cf-dest-number-cont .csc-cf-dest-number-cont
padding-left 30px padding-left 30px
.q-toggle__inner
top -8px
.csc-cf-destination-actions .csc-cf-destination-actions
text-align left text-align left
cursor pointer cursor pointer

@ -4,13 +4,13 @@
> >
<div <div
class="csc-cf-dest-type" class="csc-cf-dest-type"
@click="showNumberForm()" @click="setSelectedDestinationType('destination')"
> >
{{ $t('pages.newCallForward.numberLabel') }} {{ $t('pages.newCallForward.numberLabel') }}
</div> </div>
<div <div
class="csc-cf-dest-type" class="csc-cf-dest-type"
@click="addVoiceMail()" @click="setSelectedDestinationType('voicemail')"
> >
{{ $t('pages.newCallForward.voiceMailLabel') }} {{ $t('pages.newCallForward.voiceMailLabel') }}
</div> </div>
@ -18,23 +18,23 @@
</template> </template>
<script> <script>
import {
mapActions
} from 'vuex'
export default { export default {
name: 'CscNewCallForwardDestinationTypeForm', name: 'CscNewCallForwardDestinationTypeForm',
data () { data () {
return { return {
enabled: false, enabled: false
action: null
} }
}, },
methods: { mounted () {
showNumberForm () { this.setSelectedDestinationType(null)
this.action = 'destination'
this.$parent.close()
},
addVoiceMail () {
this.action = 'voicemail'
this.$parent.close()
}, },
methods: {
...mapActions('newCallForward', [
'setSelectedDestinationType'
]),
cancel () { cancel () {
this.enabled = false this.enabled = false
}, },

@ -47,19 +47,15 @@ export default {
methods: { methods: {
async addDestinationsetUnconditional () { async addDestinationsetUnconditional () {
await this.$store.dispatch('newCallForward/setSelectedDestType', 'unconditional') await this.$store.dispatch('newCallForward/setSelectedDestType', 'unconditional')
this.$parent.close()
}, },
async addDestinationsetUnconditionalFrom () { async addDestinationsetUnconditionalFrom () {
await this.$store.dispatch('newCallForward/setSelectedDestType', 'unconditional-from') await this.$store.dispatch('newCallForward/setSelectedDestType', 'unconditional-from')
this.$parent.close()
}, },
async addDestinationsetOffline () { async addDestinationsetOffline () {
await this.$store.dispatch('newCallForward/setSelectedDestType', 'offline') await this.$store.dispatch('newCallForward/setSelectedDestType', 'offline')
this.$parent.close()
}, },
async addDestinationsetBusy () { async addDestinationsetBusy () {
await this.$store.dispatch('newCallForward/setSelectedDestType', 'busy') await this.$store.dispatch('newCallForward/setSelectedDestType', 'busy')
this.$parent.close()
}, },
cancel () { cancel () {

@ -1,7 +1,7 @@
<template> <template>
<div <div
v-if="enabled" v-if="enabled"
class="csc-form" class="csc-form q-pa-lg"
:class="{ 'csc-cf-popover-hide': toggleFormVisibility}" :class="{ 'csc-cf-popover-hide': toggleFormVisibility}"
> >
<div class="col text-left col-xs-12 col-md-12 "> <div class="col text-left col-xs-12 col-md-12 ">
@ -40,7 +40,7 @@
<div <div
class="csc-cf-row row" class="csc-cf-row row"
> >
<csc-new-call-forward-input <csc-input
ref="sourceInputField" ref="sourceInputField"
v-model="number" v-model="number"
:label="$t('callBlocking.number')" :label="$t('callBlocking.number')"
@ -59,7 +59,7 @@
</div> </div>
<div <div
class="csc-form-actions row justify-center csc-actions-cont" class="row justify-center csc-actions-cont"
> >
<q-btn <q-btn
flat flat
@ -91,7 +91,7 @@
import { import {
mapGetters mapGetters
} from 'vuex' } from 'vuex'
import CscNewCallForwardInput from './CscNewCallForwardInput' import CscInput from '../../form/CscInput'
import CscNewCallForwardSource from './CscNewCallForwardSource' import CscNewCallForwardSource from './CscNewCallForwardSource'
import CscConfirmDialog from '../../CscConfirmationDialog' import CscConfirmDialog from '../../CscConfirmationDialog'
import CscSpinner from '../../CscSpinner' import CscSpinner from '../../CscSpinner'
@ -105,7 +105,7 @@ import {
export default { export default {
name: 'CscNewCallForwardEditSources', name: 'CscNewCallForwardEditSources',
components: { components: {
CscNewCallForwardInput, CscInput,
CscNewCallForwardSource, CscNewCallForwardSource,
CscConfirmDialog, CscConfirmDialog,
CscSpinner CscSpinner
@ -116,7 +116,7 @@ export default {
default: '' default: ''
}, },
groupId: { groupId: {
type: String, type: [String, Number],
default: '' default: ''
}, },
sourceSetName: { sourceSetName: {
@ -124,7 +124,7 @@ export default {
default: '' default: ''
}, },
sourceSetId: { sourceSetId: {
type: String, type: [String, Number],
default: '' default: ''
} }
}, },
@ -170,21 +170,18 @@ export default {
}, },
methods: { methods: {
async save () { async save () {
const sources = this.sources
if (this.numberError || this.saveDisabled) { if (this.numberError || this.saveDisabled) {
showGlobalError(this.$t('validationErrors.generic')) showGlobalError(this.$t('validationErrors.generic'))
} }
sources.push({
source: this.number
})
try { try {
this.$store.dispatch('newCallForward/addGroupLoader', this.groupId) this.$store.dispatch('newCallForward/addGroupLoader', this.groupId)
this.$refs.sourceInputField.reset()
await this.$store.dispatch('newCallForward/addSourceToSourceset', { await this.$store.dispatch('newCallForward/addSourceToSourceset', {
id: this.sourceSetId, id: this.sourceSetId,
sources: sources sources: [...this.sources, {
source: this.number
}]
}) })
this.$refs.sourceInputField.clear()
await this.$store.dispatch('newCallForward/loadSourcesets') await this.$store.dispatch('newCallForward/loadSourcesets')
} catch (err) { } catch (err) {
console.log(err) console.log(err)
@ -210,7 +207,7 @@ export default {
cancel () { cancel () {
this.number = '' this.number = ''
this.enabled = false this.enabled = false
this.$parent.close() this.$emit('close')
}, },
add () { add () {
this.number = '' this.number = ''
@ -218,7 +215,7 @@ export default {
}, },
close () { close () {
this.enabled = false this.enabled = false
this.$parent.close() this.$emit('close')
}, },
reset () { reset () {
this.cancel() this.cancel()
@ -242,6 +239,4 @@ export default {
.csc-cf-btn-reduced-size .csc-cf-btn-reduced-size
.on-left .on-left
margin-right 0px margin-right 0px
.csc-actions-cont
margin-bottom 15px
</style> </style>

@ -1,119 +0,0 @@
<template>
<q-field
:error-label="errorMessage"
>
<q-input
ref="inputField"
v-model="inputValue"
dark
clearable
type="text"
:float-label="label"
:error="$v.inputValue.$error"
:before="beforeButtons"
@keyup.enter="submit"
@keypress.space.prevent
@keydown.space.prevent
@keyup.space.prevent
@input="input"
@blur="blur"
/>
</q-field>
</template>
<script>
import {
userInfoAndEmpty
} from 'src/helpers/validation'
import {
maxLength,
required
} from 'vuelidate/lib/validators'
export default {
name: 'CscNewCallForwardInput',
props: {
label: {
type: String,
default: ''
},
prefilled: {
type: String,
default: ''
},
before: {
type: Array,
default () {
return []
}
}
},
data () {
return {
inputValue: '',
error: ''
}
},
validations: {
inputValue: {
userInfoAndEmpty,
maxLength: maxLength(64),
required
}
},
computed: {
errorMessage () {
if (!this.$v.inputValue.required) {
return this.$t('validationErrors.fieldRequired', {
field: this.label
})
} else if (!this.$v.inputValue.maxLength) {
return this.$t('validationErrors.maxLength', {
field: this.label,
maxLength: this.$v.inputValue.$params.maxLength.max
})
} else if (!this.$v.inputValue.userInfoAndEmpty) {
return this.$t('validationErrors.inputValidNumber')
} else {
return ''
}
},
beforeButtons () {
return this.before ? this.before : []
}
},
watch: {
error (state) {
this.$emit('error', state)
}
},
mounted () {
if (this.prefilled) {
this.inputValue = this.prefilled === ' ' ? '' : this.prefilled
this.$v.$reset()
}
},
methods: {
submit () {
this.$emit('submit')
},
input () {
this.$v.inputValue.$touch()
this.error = this.$v.inputValue.$error
this.$emit('input', this.inputValue)
},
blur () {
this.$v.inputValue.$touch()
this.error = this.$v.inputValue.$error
},
reset () {
this.$refs.inputField.clear()
this.$v.$reset()
}
}
}
</script>
<style lang="stylus" rel="stylesheet/stylus">
</style>

@ -1,113 +0,0 @@
<template>
<q-field
:error-label="errorMessage"
>
<q-input
v-model="inputValue"
dark
clearable
type="text"
:float-label="label"
:error="$v.inputValue.$error"
:before="beforeButtons"
@keyup.enter="submit"
@keypress.space.prevent
@keydown.space.prevent
@keyup.space.prevent
@input="input"
@blur="blur"
/>
</q-field>
</template>
<script>
import {
userInfoAndEmpty
} from 'src/helpers/validation'
import {
maxLength,
required
} from 'vuelidate/lib/validators'
export default {
name: 'CscNewCallForwardInputText',
props: {
label: {
type: String,
default: ''
},
prefilled: {
type: String,
default: ''
},
before: {
type: Array,
default () {
return []
}
}
},
data () {
return {
inputValue: '',
error: ''
}
},
validations: {
inputValue: {
userInfoAndEmpty,
maxLength: maxLength(64),
required
}
},
computed: {
errorMessage () {
if (!this.$v.inputValue.required) {
return this.$t('validationErrors.fieldRequired', {
field: this.label
})
} else if (!this.$v.inputValue.maxLength) {
return this.$t('validationErrors.maxLength', {
field: this.label,
maxLength: this.$v.inputValue.$params.maxLength.max
})
} else if (!this.$v.inputValue.userInfoAndEmpty) {
return this.$t('validationErrors.inputValidNumber')
} else {
return ''
}
},
beforeButtons () {
return this.before ? this.before : []
}
},
watch: {
error (state) {
this.$emit('error', state)
}
},
mounted () {
if (this.prefilled) {
this.inputValue = this.prefilled === ' ' ? '' : this.prefilled
}
},
methods: {
submit () {
this.$emit('submit')
},
input () {
this.$v.inputValue.$touch()
this.error = this.$v.inputValue.$error
this.$emit('input', this.inputValue)
},
blur () {
this.$v.inputValue.$touch()
this.error = this.$v.inputValue.$error
}
}
}
</script>
<style lang="stylus" rel="stylesheet/stylus">
</style>

@ -3,14 +3,14 @@
class="row csc-cf-source-cont" class="row csc-cf-source-cont"
:class="{ 'csc-cf-removed-source': removeInProgress }" :class="{ 'csc-cf-removed-source': removeInProgress }"
> >
<div class="col text-left col-xs-12 col-md-10 "> <div class="col text-left col-xs-10 col-md-10 ">
<div <div
class="csc-cf-source" class="csc-cf-source"
> >
{{ source }} {{ source }}
</div> </div>
</div> </div>
<div class="col col-xs-12 col-md-2 csc-cf-source-actions"> <div class="col col-xs-2 col-md-2 csc-cf-source-actions">
<q-icon <q-icon
name="delete" name="delete"
color="negative" color="negative"
@ -29,7 +29,7 @@ export default {
name: 'CscNewCallForwardSource', name: 'CscNewCallForwardSource',
props: { props: {
groupId: { groupId: {
type: String, type: [String, Number],
default: null default: null
}, },
groupName: { groupName: {
@ -45,7 +45,7 @@ export default {
default: '' default: ''
}, },
sourceSetId: { sourceSetId: {
type: String, type: [String, Number],
default: null default: null
} }
}, },
@ -92,9 +92,6 @@ export default {
white-space nowrap white-space nowrap
overflow hidden overflow hidden
text-overflow ellipsis text-overflow ellipsis
.csc-cf-number-form
padding 0 20px 0 20px
min-width 120px
.csc-cf-source-actions .csc-cf-source-actions
text-align left text-align left
cursor pointer cursor pointer

@ -1,39 +1,39 @@
<template> <template>
<csc-page <csc-page
class="csc-simple-page" class="q-pa-lg"
> >
<div <div
class="csc-cf-row row" class="row q-mb-lg"
> >
<div <div
v-if="groupsCount > 0" v-if="groupsCount > 0"
class="col col-xs-12 col-md-4 csc-cf-group-title" class="col-xs-4 col-md-4 text-right"
> >
{{ $t('pages.newCallForward.titles.mainTitle', {number: subscriberDisplayName}) }} {{ $t('pages.newCallForward.titles.mainTitle', {number: subscriberDisplayName}) }}
</div> </div>
<div <div
v-else v-else
class="col col-xs-12 col-md-4 csc-cf-group-title" class="col-xs-4 col-md-4 text-right"
> >
{{ $t('pages.newCallForward.primarNumberEnabled') }} {{ subscriberDisplayName }} {{ $t('pages.newCallForward.primarNumberEnabled') }} {{ subscriberDisplayName }}
</div> </div>
<div <div
class="col col-xs-12 col-md-2 text-left csc-cf-self-number-cont" class="col-xs-2 col-md-2 text-left csc-cf-self-number-cont"
> >
<q-toggle <q-toggle
v-if="forwardGroups.length > 0" v-if="groups.length > 0"
v-model="toggleDefaultNumber" v-model="toggleDefaultNumber"
@input="toggleChange" @input="toggleChange"
/> />
</div> </div>
<div <div
class="col col-xs-12 col-md-6" class="col-xs-6 col-md-6"
/> />
</div> </div>
<div <div
v-for="forwardGroup in forwardGroups" v-for="forwardGroup in groups"
:key="forwardGroup.id" :key="forwardGroup.id"
class="csc-cf-row row" class="row q-mb-lg"
> >
<csc-cf-group <csc-cf-group
v-if="!groupInCreation" v-if="!groupInCreation"
@ -41,49 +41,53 @@
:toggle-default-number="toggleDefaultNumber" :toggle-default-number="toggleDefaultNumber"
/> />
</div> </div>
<div class="csc-cf-row row"> <div class="row q-mb-md">
<div <div
class="column col col-xs-12 col-md-4" class="col-xs-4 col-md-4 text-right"
> >
<q-spinner-dots <q-spinner-dots
v-if="groupsLoading" v-if="groupsLoading"
class="csc-call-spinner" class="q-ml-auto"
color="primary" color="primary"
:size="24" :size="24"
/> />
</div> </div>
</div> </div>
<div class="csc-cf-row row">
<div <div
class="column col col-xs-12 col-md-4 items-end" v-if="!groupsLoading"
class="row q-mb-lg"
> >
<div <div
class="csc-text-action" v-if="!groupsLoading"
class="col-xs-4 col-md-4"
>
<q-btn
flat
color="primary"
class="csc-cf-add-forwarding-btn"
> >
<q-icon <q-icon
name="add" name="add"
color="primary"
size="24px" size="24px"
/> />
{{ $t('pages.newCallForward.forwardBtnLabel') }} {{ $t('pages.newCallForward.forwardBtnLabel') }}
<q-spinner-dots
v-if="groupInCreation"
color="primary"
:size="24"
/>
<q-menu <q-menu
ref="destsetTypeForm" ref="destsetTypeForm"
:auto-close="true"
class="cf-popover-bottom" class="cf-popover-bottom"
@open="resetSelectFwdGroup()" @show="resetSelectFwdGroup()"
@close="addForwardGroup()" @hide="addForwardGroup()"
> >
<csc-new-call-forward-destinationset-type-select <csc-new-call-forward-destinationset-type-select
ref="destsetTypeForm" ref="destsetTypeForm"
/> />
</q-menu> </q-menu>
</div> </q-btn>
<q-spinner-dots
v-if="groupInCreation"
color="primary"
:size="24"
/>
</div> </div>
</div> </div>
</csc-page> </csc-page>
@ -107,8 +111,11 @@ export default {
}, },
data () { data () {
return { return {
groups: [],
// TODO move to store
groupInCreation: false, groupInCreation: false,
groupsLoading: false, groupsLoading: false,
//
toggleDefaultNumber: true toggleDefaultNumber: true
} }
}, },
@ -119,13 +126,18 @@ export default {
'selectedDestType' 'selectedDestType'
]), ]),
groupsCount () { groupsCount () {
return this.forwardGroups.length return this.groups.length
}
},
watch: {
forwardGroups () {
this.groups = this.forwardGroups
} }
}, },
async mounted () { async mounted () {
this.groupsLoading = true this.groupsLoading = true
this.$store.dispatch('newCallForward/loadMappings') this.$store.dispatch('newCallForward/loadMappings')
// here we need to wait for the groups to be available in client // waits for the groups to be available
await this.$store.dispatch('newCallForward/loadForwardGroups') await this.$store.dispatch('newCallForward/loadForwardGroups')
const unconditionalGroups = await this.$store.dispatch('newCallForward/getForwardGroupByName', 'unconditional') const unconditionalGroups = await this.$store.dispatch('newCallForward/getForwardGroupByName', 'unconditional')
this.toggleDefaultNumber = !unconditionalGroups this.toggleDefaultNumber = !unconditionalGroups
@ -137,10 +149,9 @@ export default {
async addForwardGroup () { async addForwardGroup () {
this.groupInCreation = true this.groupInCreation = true
const selectedDestType = this.selectedDestType const selectedDestType = this.selectedDestType
const tempGroups = this.forwardGroups.filter(($group) => { const tempGroups = this.groups.filter(($group) => {
return $group.id.toString().indexOf('temp-') > -1 return $group.id.toString().indexOf('temp-') > -1
}) })
if (tempGroups.length > 0) { if (tempGroups.length > 0) {
showGlobalWarning(`${this.$t('pages.newCallForward.addDestinationAlert')}`, 5000) showGlobalWarning(`${this.$t('pages.newCallForward.addDestinationAlert')}`, 5000)
} else { } else {
@ -181,10 +192,6 @@ export default {
} }
this.groupInCreation = false this.groupInCreation = false
}, },
showForm () {
this.$refs.destinationType.close()
this.$refs.addDestinationForm.add()
},
toggleChange () { toggleChange () {
this.groupInCreation = true this.groupInCreation = true
this.$store.dispatch('newCallForward/forwardAllCalls', !this.toggleDefaultNumber) this.$store.dispatch('newCallForward/forwardAllCalls', !this.toggleDefaultNumber)
@ -198,17 +205,8 @@ export default {
</script> </script>
<style lang="stylus" rel="stylesheet/stylus"> <style lang="stylus" rel="stylesheet/stylus">
.csc-cf-flat-btn .csc-cf-add-forwarding-btn
color $primary
float right float right
.csc-cf-group-title
text-align right
.csc-cf-destinations-cont
margin-top 25px
.csc-cf-field-toggle
margin-top 0px
.csc-call-spinner
margin-left auto
.csc-cf-self-number-cont .csc-cf-self-number-cont
padding-left 30px padding-left 30px
width 150px width 150px
@ -218,5 +216,7 @@ export default {
.cf-popover-bottom .cf-popover-bottom
min-width 150px min-width 150px
margin-left 5px margin-left 5px
.csc-actions-cont
margin-top 10px
</style> </style>

@ -21,7 +21,9 @@ import {
deleteTimesetById deleteTimesetById
} from '../api/call-forward' } from '../api/call-forward'
import { getSubscriberId } from 'src/auth' import { getSubscriberId } from 'src/auth'
import {
randInRange
} from 'src/helpers/math-helper'
const ForwardGroup = { const ForwardGroup = {
unconditional: { unconditional: {
name: 'csc-unconditional', name: 'csc-unconditional',
@ -58,7 +60,8 @@ export default {
forwardGroups: [], forwardGroups: [],
groupsLoaders: [], groupsLoaders: [],
selectedDestType: null, selectedDestType: null,
firstDestinationInCreation: null firstDestinationInCreation: null,
selectedDestinationType: null
}, },
getters: { getters: {
getGroupsLoaders (state) { getGroupsLoaders (state) {
@ -141,9 +144,21 @@ export default {
}, },
getTimesets (state) { getTimesets (state) {
return state.timeSets return state.timeSets
},
getSelectedDestType (state) {
return state.selectedDestType
},
getSelectedDestinationType (state) {
return state.selectedDestinationType
} }
}, },
mutations: { mutations: {
addGroup (state, data) {
state.forwardGroups.push(data)
},
addFirstGroup (state, data) {
state.forwardGroups.unshift(data)
},
addDestination (state, forwardGroupId, destination) { addDestination (state, forwardGroupId, destination) {
const group = state.forwardGroups.find((group) => { const group = state.forwardGroups.find((group) => {
return group.id === forwardGroupId return group.id === forwardGroupId
@ -188,6 +203,9 @@ export default {
return group.id === data.groupId return group.id === data.groupId
}) })
group.destinations = data.destinations group.destinations = data.destinations
for (const destination of group.destinations) {
destination.display_id = randInRange(100000, 999999)
}
}, },
setMappings (state, mappings) { setMappings (state, mappings) {
state.mappings = mappings state.mappings = mappings
@ -195,6 +213,9 @@ export default {
setSelectedDestType (state, destType) { setSelectedDestType (state, destType) {
state.selectedDestType = destType state.selectedDestType = destType
}, },
setSelectedDestinationType (state, type) {
state.selectedDestinationType = type
},
setSourceSets (state, sourceSets) { setSourceSets (state, sourceSets) {
state.sourceSets = sourceSets state.sourceSets = sourceSets
}, },
@ -257,7 +278,7 @@ export default {
const subscriberId = getSubscriberId() const subscriberId = getSubscriberId()
const groupMappingId = ForwardGroup[data.name] ? ForwardGroup[data.name].mapping : await context.dispatch('getMappingIdByGroupName', data.name) const groupMappingId = ForwardGroup[data.name] ? ForwardGroup[data.name].mapping : await context.dispatch('getMappingIdByGroupName', data.name)
const allMappings = context.getters.getMappings const allMappings = context.getters.getMappings
const groupMappings = allMappings[groupMappingId] const groupMappings = _.cloneDeep(allMappings[groupMappingId])
if (data.replaceMapping) { if (data.replaceMapping) {
for (const mapping of groupMappings) { for (const mapping of groupMappings) {
if (mapping.destinationset_id === data.groupId) { if (mapping.destinationset_id === data.groupId) {
@ -286,7 +307,6 @@ export default {
async addForwardGroup (context, data) { async addForwardGroup (context, data) {
try { try {
const newForwardGroupId = await addNewDestinationsetWithName(ForwardGroup[data.name] ? ForwardGroup[data.name].name : data.name) const newForwardGroupId = await addNewDestinationsetWithName(ForwardGroup[data.name] ? ForwardGroup[data.name].name : data.name)
const destination = { const destination = {
announcement_id: null, announcement_id: null,
simple_destination: data.destination || ' ', simple_destination: data.destination || ' ',
@ -298,7 +318,6 @@ export default {
name: data.name, name: data.name,
groupId: newForwardGroupId groupId: newForwardGroupId
}) })
await addDestinationToDestinationset({ await addDestinationToDestinationset({
id: newForwardGroupId, id: newForwardGroupId,
data: [destination] data: [destination]
@ -350,9 +369,9 @@ export default {
}] }]
} }
if (groupName.includes('timeout') || groupName.includes('unconditional')) { if (groupName.includes('timeout') || groupName.includes('unconditional')) {
context.state.forwardGroups.unshift(data) context.commit('addFirstGroup', data)
} else { } else {
context.state.forwardGroups.push(data) context.commit('addGroup', data)
} }
}, },
async addDestination (context, data) { async addDestination (context, data) {
@ -589,13 +608,14 @@ export default {
const subscriberId = getSubscriberId() const subscriberId = getSubscriberId()
const mappingId = await context.dispatch('getMappingIdByGroupName', data.groupName) const mappingId = await context.dispatch('getMappingIdByGroupName', data.groupName)
const groupMappings = await context.state.mappings[mappingId] const groupMappings = await context.state.mappings[mappingId]
for (const group of groupMappings) { const clonedGroupMappings = _.cloneDeep(groupMappings)
for (const group of clonedGroupMappings) {
if (group.destinationset_id === data.id) { if (group.destinationset_id === data.id) {
group.enabled = data.enabled group.enabled = data.enabled
} }
} }
const updatedMappings = await addNewMapping({ const updatedMappings = await addNewMapping({
mappings: groupMappings, mappings: clonedGroupMappings,
group: mappingId, group: mappingId,
subscriberId: subscriberId subscriberId: subscriberId
}) })
@ -668,7 +688,6 @@ export default {
}, },
async createTimeSet (context, timesetName) { async createTimeSet (context, timesetName) {
try { try {
// const subscriberId = getSubscriberId();
const timesetId = await addNewTimeset(timesetName) const timesetId = await addNewTimeset(timesetName)
return timesetId return timesetId
} catch (err) { } catch (err) {
@ -716,6 +735,9 @@ export default {
} catch (err) { } catch (err) {
console.log(err) console.log(err)
} }
},
setSelectedDestinationType (context, type) {
context.commit('setSelectedDestinationType', type)
} }
} }
} }

Loading…
Cancel
Save