Merge branch '308-fix-end-datetime-before-begin-datetime' into 'master'
fix: end datetime can't be before begin datetime. Closes #308 See merge request framasoft/mobilizon!343
This commit is contained in:
commit
bf7720afc1
|
@ -22,8 +22,9 @@
|
||||||
:day-names="localeShortWeekDayNamesProxy"
|
:day-names="localeShortWeekDayNamesProxy"
|
||||||
:month-names="localeMonthNamesProxy"
|
:month-names="localeMonthNamesProxy"
|
||||||
:first-day-of-week="parseInt($t('firstDayOfWeek'), 10)"
|
:first-day-of-week="parseInt($t('firstDayOfWeek'), 10)"
|
||||||
:min-date="minDate"
|
:min-date="minDatetime"
|
||||||
v-model="dateWithoutTime"
|
:max-date="maxDatetime"
|
||||||
|
v-model="dateWithTime"
|
||||||
:placeholder="$t('Click to select')"
|
:placeholder="$t('Click to select')"
|
||||||
:years-range="[-2,10]"
|
:years-range="[-2,10]"
|
||||||
icon="calendar"
|
icon="calendar"
|
||||||
|
@ -33,6 +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"
|
||||||
|
:max-time="maxDatetime"
|
||||||
size="is-small"
|
size="is-small"
|
||||||
inline>
|
inline>
|
||||||
</b-timepicker>
|
</b-timepicker>
|
||||||
|
@ -65,23 +68,21 @@ export default class DateTimePicker extends Vue {
|
||||||
/**
|
/**
|
||||||
* Earliest date available for selection
|
* Earliest date available for selection
|
||||||
*/
|
*/
|
||||||
@Prop({ required: false, type: Date, default: null }) minDate!: Date;
|
@Prop({ required: false, type: Date, default: null }) minDatetime!: Date;
|
||||||
|
|
||||||
dateWithoutTime: Date = this.value;
|
/**
|
||||||
dateWithTime: Date = this.dateWithoutTime;
|
* Latest date available for selection
|
||||||
|
*/
|
||||||
|
@Prop({ required: false, type: Date, default: null }) maxDatetime!: Date;
|
||||||
|
|
||||||
|
dateWithTime: Date = this.value;
|
||||||
|
|
||||||
localeShortWeekDayNamesProxy = localeShortWeekDayNames();
|
localeShortWeekDayNamesProxy = localeShortWeekDayNames();
|
||||||
localeMonthNamesProxy = localeMonthNames();
|
localeMonthNamesProxy = localeMonthNames();
|
||||||
|
|
||||||
@Watch('value')
|
@Watch('value')
|
||||||
updateValue() {
|
updateValue() {
|
||||||
this.dateWithoutTime = this.value;
|
this.dateWithTime = this.value;
|
||||||
this.dateWithTime = this.dateWithoutTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Watch('dateWithoutTime')
|
|
||||||
updateDateWithoutTimeWatcher() {
|
|
||||||
this.updateDateTime();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Watch('dateWithTime')
|
@Watch('dateWithTime')
|
||||||
|
@ -95,9 +96,7 @@ export default class DateTimePicker extends Vue {
|
||||||
*
|
*
|
||||||
* @type {Date}
|
* @type {Date}
|
||||||
*/
|
*/
|
||||||
this.dateWithoutTime.setHours(this.dateWithTime.getHours());
|
this.$emit('input', this.dateWithTime);
|
||||||
this.dateWithoutTime.setMinutes(this.dateWithTime.getMinutes());
|
|
||||||
this.$emit('input', this.dateWithoutTime);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
<tag-input v-model="event.tags" :data="tags" path="title" />
|
<tag-input v-model="event.tags" :data="tags" path="title" />
|
||||||
|
|
||||||
<date-time-picker v-model="event.beginsOn" :label="$t('Starts on…')" />
|
<date-time-picker v-model="event.beginsOn" :label="$t('Starts on…')" />
|
||||||
<date-time-picker :min-date="minDateForEndsOn" v-model="event.endsOn" :label="$t('Ends on…')" />
|
<date-time-picker :min-datetime="event.beginsOn" v-model="event.endsOn" :label="$t('Ends on…')" />
|
||||||
<!-- <b-switch v-model="endsOnNull">{{ $t('No end date') }}</b-switch>-->
|
<!-- <b-switch v-model="endsOnNull">{{ $t('No end date') }}</b-switch>-->
|
||||||
<b-button type="is-text" @click="dateSettingsIsOpen = true">{{ $t('Date parameters')}}</b-button>
|
<b-button type="is-text" @click="dateSettingsIsOpen = true">{{ $t('Date parameters')}}</b-button>
|
||||||
|
|
||||||
|
@ -630,7 +630,7 @@ export default class EditEvent extends Vue {
|
||||||
return JSON.stringify(this.event.toEditJSON()) !== JSON.stringify(this.unmodifiedEvent);
|
return JSON.stringify(this.event.toEditJSON()) !== JSON.stringify(this.unmodifiedEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
get beginsOn() { return this.event.beginsOn; }
|
get beginsOn(): Date { return this.event.beginsOn; }
|
||||||
|
|
||||||
@Watch('beginsOn', { deep: true })
|
@Watch('beginsOn', { deep: true })
|
||||||
onBeginsOnChanged(beginsOn) {
|
onBeginsOnChanged(beginsOn) {
|
||||||
|
@ -639,7 +639,7 @@ export default class EditEvent extends Vue {
|
||||||
const dateEndsOn = new Date(this.event.endsOn);
|
const dateEndsOn = new Date(this.event.endsOn);
|
||||||
if (dateEndsOn < dateBeginsOn) {
|
if (dateEndsOn < dateBeginsOn) {
|
||||||
this.event.endsOn = dateBeginsOn;
|
this.event.endsOn = dateBeginsOn;
|
||||||
this.event.endsOn.setHours(dateEndsOn.getHours());
|
this.event.endsOn.setHours(dateBeginsOn.getHours() + 1);
|
||||||
}
|
}
|
||||||
if (dateEndsOn === dateBeginsOn) {
|
if (dateEndsOn === dateBeginsOn) {
|
||||||
this.event.endsOn.setHours(dateEndsOn.getHours() + 1);
|
this.event.endsOn.setHours(dateEndsOn.getHours() + 1);
|
||||||
|
|
Loading…
Reference in a new issue