diff --git a/src/api/call-forwarding.js b/src/api/call-forwarding.js
index d0836dfb..6abe9550 100644
--- a/src/api/call-forwarding.js
+++ b/src/api/call-forwarding.js
@@ -162,41 +162,23 @@ export async function cfDeleteTimeSet (timesetId) {
})
}
-export async function cfCreateTimeSetDateRange (subscriberId, date) {
+export async function cfCreateTimeSetDateRange (subscriberId, times) {
return post({
resource: 'cftimesets',
body: {
subscriber_id: subscriberId,
name: 'csc-date-range-' + v4(),
- times: [
- {
- minute: null,
- month: date.from.month + '-' + date.to.month,
- hour: null,
- mday: date.from.date + '-' + date.to.date,
- year: date.from.year + '-' + date.to.year,
- wday: null
- }
- ]
+ times: times
}
})
}
-export async function cfUpdateTimeSetDateRange (timeSetId, date) {
+export async function cfUpdateTimeSetDateRange (timeSetId, times) {
return patchReplace({
resource: 'cftimesets',
resourceId: timeSetId,
fieldPath: 'times',
- value: [
- {
- minute: null,
- month: date.from.month + '-' + date.to.month,
- hour: null,
- mday: date.from.date + '-' + date.to.date,
- year: date.from.year + '-' + date.to.year,
- wday: null
- }
- ]
+ value: times
})
}
diff --git a/src/components/call-forwarding/CscCfGroupConditionDateRange.vue b/src/components/call-forwarding/CscCfGroupConditionDateRange.vue
index 910115db..d33fa9db 100644
--- a/src/components/call-forwarding/CscCfGroupConditionDateRange.vue
+++ b/src/components/call-forwarding/CscCfGroupConditionDateRange.vue
@@ -6,14 +6,32 @@
v-bind="$attrs"
v-on="$listeners"
>
-
+
+
+
+
+
+ {{ $t('The "{timeset}" timeset contains incompatible values. You can resolve this by deleting it and recreating from the scratch.', { timeset: timeSet.name }) }}
+
+
+
+
+
@@ -26,6 +44,7 @@
@click="deleteSourceSetEvent"
/>
import CscCfGroupCondition from 'components/call-forwarding/CscCfGroupCondition'
import { mapActions } from 'vuex'
-import { timeSetDateRange } from 'src/filters/time-set'
+import { humanDatesetToKamailio, kamailioDatesetToHuman } from 'src/helpers/kamailio-timesets-converter'
export default {
name: 'CscCfGroupConditionDateRange',
components: {
@@ -69,30 +88,12 @@ export default {
},
data () {
return {
- selectedDate: this.transformedDate
- }
- },
- computed: {
- formattedDate () {
- if (this.timeSet) {
- return timeSetDateRange(this.timeSet.times)
- }
- return null
- },
- transformedDate () {
- if (this.timeSet) {
- const dateRangeParts = timeSetDateRange(this.timeSet.times).split('-')
- return {
- from: dateRangeParts[0],
- to: dateRangeParts[1]
- }
- } else {
- return null
- }
+ invalidDateset: false,
+ selectedDate: null
}
},
mounted () {
- this.selectedDate = this.transformedDate
+ this.transformDateset()
},
methods: {
...mapActions('callForwarding', [
@@ -100,23 +101,32 @@ export default {
'updateTimeSetDateRange',
'deleteTimeSet'
]),
+ transformDateset () {
+ if (this.timeSet) {
+ let hDateset
+ try {
+ hDateset = kamailioDatesetToHuman(this.timeSet.times)
+ } catch (e) {
+ this.invalidDateset = true
+ console.info(e)
+ return
+ }
+ if (hDateset.length === 0) {
+ this.selectedDate = null
+ } else {
+ this.selectedDate = (hDateset[0].from === hDateset[0].to) ? hDateset[0].from : hDateset[0]
+ }
+ } else {
+ this.selectedDate = null
+ }
+ },
async createTimeSetEvent () {
- const datePartsFrom = this.selectedDate.from.split('/')
- const datePartsTo = this.selectedDate.to.split('/')
+ const dateFrom = this.selectedDate.from ? this.selectedDate.from : this.selectedDate
+ const dateTo = this.selectedDate.to ? this.selectedDate.to : this.selectedDate
+ const kamilioTimesets = humanDatesetToKamailio([{ from: dateFrom, to: dateTo }])
const payload = {
mapping: this.mapping,
- date: {
- from: {
- date: datePartsFrom[2],
- month: datePartsFrom[1],
- year: datePartsFrom[0]
- },
- to: {
- date: datePartsTo[2],
- month: datePartsTo[1],
- year: datePartsTo[0]
- }
- }
+ date: kamilioTimesets
}
if (this.timeSet) {
payload.id = this.timeSet.id
diff --git a/src/components/call-forwarding/CscCfGroupConditionOfficeHours.vue b/src/components/call-forwarding/CscCfGroupConditionOfficeHours.vue
index 6479b49b..34a683ea 100644
--- a/src/components/call-forwarding/CscCfGroupConditionOfficeHours.vue
+++ b/src/components/call-forwarding/CscCfGroupConditionOfficeHours.vue
@@ -467,8 +467,6 @@ export default {