Skip to content

Commit

Permalink
v.2.1.1
Browse files Browse the repository at this point in the history
[fix] emit value on timestamp mode
  • Loading branch information
scarry1992 committed Sep 22, 2020
1 parent caaff2c commit 041cd73
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ The component accepts these props:
| Event | Payload | Description |
| :--- | :---: | :--- |
| input | `Array` | Selected dates timestamps array |
| error | `Boolean` | Error in time range. |
| change:mode | `Number` | New component mode |

## Flatpickr wrapper
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "datetimerangepicker",
"version": "2.1.0",
"version": "2.1.1",
"description": "Date-time-range picker based on Quasar Framework",
"productName": "DateTimeRangePicker",
"cordovaId": "org.cordova.quasar.app",
Expand Down
12 changes: 11 additions & 1 deletion src/components/DateRangePicker.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
<q-input v-model.number="timestampFrom" type="number" label="From" outlined :bg-color="currentTheme.color" :color="currentTheme.bgColor" dense :key="2" :rules="[val => val <= 9999999999 || 'Wrong timestamp']"/>
<q-input v-model.number="timestampTo" type="number" label="To" outlined :bg-color="currentTheme.color" :color="currentTheme.bgColor" dense :key="3" :rules="[val => val <= 9999999999 || 'Wrong timestamp']"/>
</template>
<q-btn :color="currentTheme.color" flat class="q-mb-sm full-width" icon="check" label="Apply" @click="update" :disable="currentDateRangeModel[1] <= currentDateRangeModel[0] || (manualFormat === MANUAL_TIMESTAMP && (timestampFrom > 9999999999 || timestampTo > 9999999999))" />
</div>
<template v-else>
<div class="time-range-input__wrapper q-mb-sm">
Expand Down Expand Up @@ -148,6 +147,7 @@ export default {
},
set (from) {
this.$set(this.currentDateRangeModel, 0, this.manualToDate(from))
this.update()
}
},
manualTo: {
Expand All @@ -156,6 +156,7 @@ export default {
},
set (to) {
this.$set(this.currentDateRangeModel, 1, this.manualToDate(to))
this.update()
}
},
timestampFrom: {
Expand All @@ -164,6 +165,7 @@ export default {
},
set (from) {
this.$set(this.currentDateRangeModel, 0, new Date(from * 1000))
this.update()
}
},
timestampTo: {
Expand All @@ -172,7 +174,11 @@ export default {
},
set (to) {
this.$set(this.currentDateRangeModel, 1, new Date(to * 1000))
this.update()
}
},
hasError () {
return this.currentDateRangeModel[1] <= this.currentDateRangeModel[0] || (this.manualFormat === MANUAL_TIMESTAMP && (this.timestampFrom > 9999999999 || this.timestampTo > 9999999999))
}
},
methods: {
Expand Down Expand Up @@ -202,6 +208,10 @@ export default {
this.update()
},
update () {
if (this.hasError) {
return this.$emit('error', true)
}
this.$emit('error', false)
let value = this.getValue(this.currentDateRangeModel, this.dateRangeMode)
if (!value) { return }
value = value.map(date => date.valueOf())
Expand Down

0 comments on commit 041cd73

Please sign in to comment.