Skip to content

Commit 1adfa1d

Browse files
committed
fix: Datetime input does not auto updates when min/max changes quasarframework#300
1 parent 3f4676a commit 1adfa1d

File tree

4 files changed

+44
-2
lines changed

4 files changed

+44
-2
lines changed

src/vue-components/datetime/Datetime.vue

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,14 @@ export default {
132132
return this.value ? moment(this.value).format(format) : ''
133133
}
134134
},
135+
watch: {
136+
min () {
137+
this.__normalizeAndEmit()
138+
},
139+
max () {
140+
this.__normalizeAndEmit()
141+
}
142+
},
135143
methods: {
136144
open () {
137145
if (!this.disable && !this.readonly) {
@@ -165,6 +173,13 @@ export default {
165173
},
166174
__update () {
167175
this.$emit('input', this.model)
176+
},
177+
__normalizeAndEmit () {
178+
if (this.value) {
179+
this.$nextTick(() => {
180+
this.$emit('input', this.__normalizeValue(moment(this.value)).format(this.format))
181+
})
182+
}
168183
}
169184
}
170185
}

src/vue-components/datetime/DatetimeRange.vue

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<template>
2-
<div>
2+
<div class="q-datetime-range">
33
<q-datetime
44
v-model="model.from"
55
:type="type"
@@ -15,6 +15,8 @@
1515
:static-label="staticLabel"
1616
:readonly="readonly"
1717
:disable="disable"
18+
:class="className"
19+
:style="css"
1820
></q-datetime>
1921

2022
<q-datetime
@@ -32,6 +34,8 @@
3234
:static-label="staticLabel"
3335
:readonly="readonly"
3436
:disable="disable"
37+
:class="className"
38+
:style="css"
3539
></q-datetime>
3640
</div>
3741
</template>
@@ -50,6 +54,8 @@ export default {
5054
},
5155
required: true
5256
},
57+
className: [String, Object],
58+
css: [String, Object],
5359
type: {
5460
type: String,
5561
default: 'date'

src/vue-components/datetime/datetime.ios.styl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
$datetime-range-space ?= 10px
2+
13
.q-datetime
24
max-width 100vw
35
border 1px solid $grey-4
@@ -116,3 +118,12 @@ body.desktop .q-datetime-col-wrapper
116118
> div
117119
padding 0 6px
118120
text-align center
121+
122+
.q-datetime-range
123+
&.space-between
124+
> div + div
125+
margin-left $datetime-range-space
126+
&.full-width
127+
display flex
128+
> div
129+
flex 1 1 auto

src/vue-components/datetime/datetime.mat.styl

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
$datetime-color ?= $primary
1+
$datetime-color ?= $primary
2+
$datetime-range-space ?= 10px
23

34
.q-datetime
45
color rgba(0, 0, 0, .87)
@@ -165,6 +166,15 @@ for $pos in 0..12
165166
top (((1 + sin($degree * 1deg)) * 100%) / 2)
166167
left (((1 + cos($degree * 1deg)) * 100%) / 2)
167168

169+
.q-datetime-range
170+
&.space-between
171+
> div + div
172+
margin-left $datetime-range-space
173+
&.full-width
174+
display flex
175+
> div
176+
flex 1 1 auto
177+
168178
@media (max-width $layout-medium-max)
169179
.q-datetime-ampm
170180
margin-left 1.5rem

0 commit comments

Comments
 (0)