forked from potsda.mn/mobilizon
Merge branch 'improve-event-edit-timepicker' into 'master'
Only restrict event time picker times when same day See merge request framasoft/mobilizon!511
This commit is contained in:
commit
744c040d0d
|
@ -34,8 +34,8 @@
|
||||||
placeholder="Type or select a time..."
|
placeholder="Type or select a time..."
|
||||||
icon="clock"
|
icon="clock"
|
||||||
v-model="dateWithTime"
|
v-model="dateWithTime"
|
||||||
:min-time="minDatetime"
|
:min-time="minTime"
|
||||||
:max-time="maxDatetime"
|
:max-time="maxTime"
|
||||||
size="is-small"
|
size="is-small"
|
||||||
inline
|
inline
|
||||||
>
|
>
|
||||||
|
@ -100,6 +100,28 @@ export default class DateTimePicker extends Vue {
|
||||||
*/
|
*/
|
||||||
this.$emit("input", this.dateWithTime);
|
this.$emit("input", this.dateWithTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get minTime(): Date | null {
|
||||||
|
if (this.minDatetime && this.datesAreOnSameDay(this.dateWithTime, this.minDatetime)) {
|
||||||
|
return this.minDatetime;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
get maxTime(): Date | null {
|
||||||
|
if (this.maxDatetime && this.datesAreOnSameDay(this.dateWithTime, this.maxDatetime)) {
|
||||||
|
return this.maxDatetime;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private datesAreOnSameDay(first: Date, second: Date): boolean {
|
||||||
|
return (
|
||||||
|
first.getFullYear() === second.getFullYear() &&
|
||||||
|
first.getMonth() === second.getMonth() &&
|
||||||
|
first.getDate() === second.getDate()
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue