From a4eb996f22786a562b1a47985267aeeab2c032cb Mon Sep 17 00:00:00 2001 From: adisposkofh Date: Tue, 21 Jul 2026 19:30:22 +0200 Subject: [PATCH] replaced coodle calendar timeslot card date and time inputs with vuedatepicker --- .../CoodleSurveyCalendarTimeslotCard.js | 87 ++++++++++++++++--- 1 file changed, 74 insertions(+), 13 deletions(-) diff --git a/public/js/components/Cis/Coodle/Components/CoodleSurvey/CoodleSurveyCalendar/CoodleSurveyCalendarTimeslotCard.js b/public/js/components/Cis/Coodle/Components/CoodleSurvey/CoodleSurveyCalendar/CoodleSurveyCalendarTimeslotCard.js index d9e8abbb5..c05028491 100644 --- a/public/js/components/Cis/Coodle/Components/CoodleSurvey/CoodleSurveyCalendar/CoodleSurveyCalendarTimeslotCard.js +++ b/public/js/components/Cis/Coodle/Components/CoodleSurvey/CoodleSurveyCalendar/CoodleSurveyCalendarTimeslotCard.js @@ -2,6 +2,9 @@ import { numberPadding } from "../../../../../../helpers/DateHelpers.js"; export default { name: "CoodleSurveyCalendarTimeslotCard", + components: { + VueDatePicker, + }, props: { timeslot: Object | null, isTimeslotCardEditInProgress: Boolean, @@ -16,8 +19,6 @@ export default { isEditInProgress: false, dateInput: null, startTimeInput: null, - minStartTimeInput: "07:00", - maxStartTimeInput: "22:55", }; }, computed: { @@ -50,8 +51,14 @@ export default { }, methods: { setInputs() { - this.dateInput = this.$props.timeslot?.datum; - this.startTimeInput = this.$props.timeslot?.beginn?.slice(0, 5); + const tomorrow = new Date( + new Date().getTime() + 24 * 60 * 60 * 1000, + ); + this.dateInput = + this.$props.timeslot?.datum ?? + tomorrow.toISOString().slice(0, 10); + this.startTimeInput = + this.$props.timeslot?.beginn?.slice(0, 5) ?? "12:00"; }, async startEdit() { if (this.$props.isTimeslotCardEditInProgress) { @@ -107,6 +114,44 @@ export default { this.$emit("createTimeslot", { startDate }); } }, + updateDateInput(value) { + let date = new Date(value); + this.dateInput = date.toISOString().slice(0, 10); + }, + getDateInputPreview() { + if (!this.dateInput?.length) return ""; + + const day = this.dateInput.slice(8); + const month = this.dateInput.slice(5, 7); + const year = this.dateInput.slice(0, 4); + + return day + "." + month + "." + year; + }, + updateStartTimeInput(value) { + this.startTimeInput = + numberPadding(value.hours) + ":" + numberPadding(value.minutes); + }, + getStartTimeInputPreview() { + if (!this.startTimeInput?.length) return ""; + + const hours = this.startTimeInput.slice(0, 2); + const minutes = this.startTimeInput.slice(3, 5); + + return hours + ":" + minutes; + }, + getInitialStartTimeValue() { + if (!this.startTimeInput?.length) { + return { + hours: 12, + minutes: 0, + }; + } + + return { + hours: parseInt(this.startTimeInput.split(":")[0]), + minutes: parseInt(this.startTimeInput.split(":")[1]), + }; + }, }, created() { this.setInputs(); @@ -123,19 +168,35 @@ export default { {{ formattedStartEnd }}
-
+
- +
-