Skip to content

Fix missing watcher on the CalendarTime component #304

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions src/components/CalendarTime.vue
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
},
},
props: {
miniuteIncrement: {
minuteIncrement: {
type: Number,
default: 5,
},
Expand All @@ -52,14 +52,17 @@
readonly: {
type: Boolean,
default: false
},
timeUpdate: {
type: Object,
}
},
data() {
let current = this.currentTime ? this.currentTime : new Date()
let hours = current.getHours();
return {
hour: this.hour24 ? hours : hours % 12 || 12,
minute: current.getMinutes() - (current.getMinutes() % this.miniuteIncrement),
minute: current.getMinutes() - (current.getMinutes() % this.minuteIncrement),
second: current.getSeconds(),
ampm: hours < 12 ? 'AM' : 'PM',
};
Expand All @@ -76,7 +79,7 @@
minutes () {
let values = [];
let max = 60;
for(let i=0; i< max; i=i+this.miniuteIncrement) {
for(let i=0; i< max; i=i+this.minuteIncrement) {
values.push(i);
}
return values;
Expand All @@ -95,6 +98,9 @@
ampm () {
this.onChange();
},
currentTime() {
this.prepareTime();
}
},
methods: {
getHour() {
Expand All @@ -114,6 +120,12 @@
minutes: this.minute,
seconds: this.second,
});
},
prepareTime() {
let date = new Date(this.currentTime);
this.hour = date.getHours();
this.minute = date.getMinutes() - ( date.getMinutes() % this.minuteIncrement);
this.second = date.getSeconds();
}
},
}
Expand Down
4 changes: 2 additions & 2 deletions src/components/DateRangePicker.vue
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@
</div>
<calendar-time v-if="timePicker && start"
@update="onUpdateStartTime"
:miniute-increment="timePickerIncrement"
:minute-increment="timePickerIncrement"
:hour24="timePicker24Hour"
:second-picker="timePickerSeconds"
:current-time="start"
Expand Down Expand Up @@ -136,7 +136,7 @@
</div>
<calendar-time v-if="timePicker && end"
@update="onUpdateEndTime"
:miniute-increment="timePickerIncrement"
:minute-increment="timePickerIncrement"
:hour24="timePicker24Hour"
:second-picker="timePickerSeconds"
:current-time="end"
Expand Down