diff --git a/src/components/date/datepickerWithRange.vue b/src/components/date/datepickerWithRange.vue
index 1a406340..98cde3a8 100644
--- a/src/components/date/datepickerWithRange.vue
+++ b/src/components/date/datepickerWithRange.vue
@@ -1,17 +1,24 @@
-
Today
-
Next Week
-
Next Month
-
Custom
+
+
+
+
- {{ dateRange }}
@@ -48,12 +55,16 @@ const dateRange = ref('')
watch(
() => dateRange.value,
newVal => {
+ if (newVal === null) {
+ return
+ }
+
const [fromDate, toDate] = newVal.split(' to ')
-
+
if (typeof fromDate === 'undefined' || typeof toDate === 'undefined') {
return
}
-
+
emit('dateChanged', {
dateFrom: new Date(fromDate),
dateTo: new Date(toDate),
@@ -65,23 +76,33 @@ function formatDate(date) {
return format(date, 'yyyy-MM-dd HH:mm')
}
-function setDatesToToday() {
+const datesToday = computed(() => {
const startDate = new Date()
const endDate = new Date((new Date()).setDate((new Date()).getDate() + 1))
- dateRange.value = `${formatDate(startDate)} to ${formatDate(endDate)}`
-}
+ return `${formatDate(startDate)} to ${formatDate(endDate)}`
+})
-function setDatesToNextWeek() {
+const datesNextWeek = computed(() => {
const startDate = new Date()
const endDate = new Date((new Date()).getTime() + 7 * 24 * 60 * 60 * 1000)
- dateRange.value = `${formatDate(startDate)} to ${formatDate(endDate)}`
-}
+ return `${formatDate(startDate)} to ${formatDate(endDate)}`
+})
-function setDatesToNextMonth() {
+const datesNextMonth = computed(() => {
const startDate = new Date()
const endDate = new Date((new Date()).setMonth((new Date()).getMonth() + 1))
- dateRange.value = `${formatDate(startDate)} to ${formatDate(endDate)}`
+ return `${formatDate(startDate)} to ${formatDate(endDate)}`
+})
+
+function setDateRange(range) {
+ dateRange.value = range
}
+
+const customRangeActive = computed(() => {
+ return dateRange.value !== datesToday.value &&
+ dateRange.value !== datesNextWeek.value &&
+ dateRange.value !== datesNextMonth.value
+})