Skip to content

Commit 14b6456

Browse files
fix: date range filter value
1 parent 95f54b8 commit 14b6456

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

frontend/src/global.d.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
declare module 'frappe-ui'
21
declare module '@/utils/dayjs'
32
declare module 'dom-to-image'
43

frontend/src2/dashboard/Filter.vue

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,21 @@ function clearFilter() {
5151
filterValue.value = undefined
5252
emit('close')
5353
}
54+
55+
// For a bried period, the value of a date filter with 'between' operator is stored as `from_date,to_date` string. This computed property helps to convert it to array and vice versa for the DateRangePicker component.
56+
const dateRangeVal = computed({
57+
get() {
58+
let val = state.value
59+
if (typeof val === 'string') {
60+
const [from_date, to_date] = val.split(',')
61+
return [from_date, to_date]
62+
}
63+
return val
64+
},
65+
set(val: string) {
66+
state.value = val.split(',')
67+
},
68+
})
5469
</script>
5570

5671
<template>
@@ -79,7 +94,7 @@ function clearFilter() {
7994
/>
8095
<DateRangePicker
8196
v-else-if="valueSelectorType === 'date_range'"
82-
v-model="state.value as string[]"
97+
v-model="dateRangeVal as string[]"
8398
/>
8499
<RelativeDatePicker
85100
v-else-if="valueSelectorType === 'relative_date'"

0 commit comments

Comments
 (0)