From 2051daa1f41edd371f13844a08ee1e8463c03fe8 Mon Sep 17 00:00:00 2001 From: dlimyy Date: Wed, 6 Sep 2023 21:32:58 +0800 Subject: [PATCH] Fix submission opening time bug --- .../session-edit-form.component.html | 2 +- .../session-edit-form.component.ts | 29 +++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/src/web/app/components/session-edit-form/session-edit-form.component.html b/src/web/app/components/session-edit-form/session-edit-form.component.html index ea8d26cf803..7f7a7f9e435 100644 --- a/src/web/app/components/session-edit-form/session-edit-form.component.html +++ b/src/web/app/components/session-edit-form/session-edit-form.component.html @@ -135,7 +135,7 @@
Or
-
diff --git a/src/web/app/components/session-edit-form/session-edit-form.component.ts b/src/web/app/components/session-edit-form/session-edit-form.component.ts index 1a90937b16e..19362f13041 100644 --- a/src/web/app/components/session-edit-form/session-edit-form.component.ts +++ b/src/web/app/components/session-edit-form/session-edit-form.component.ts @@ -134,6 +134,35 @@ export class SessionEditFormComponent { }); } + /** + * Triggers the change of the model when the submission opening date changes. + */ + triggerSubmissionOpeningDateModelChange(field: string, date: DateFormat): void { + const minDate: DateFormat = this.minDateForSubmissionStart; + if (JSON.stringify(minDate) === JSON.stringify(date)) { + const minTime: TimeFormat = this.minTimeForSubmissionStart; + this.configureSubmissionOpeningTime(minTime); + this.model.submissionStartTime = minTime; + } + this.modelChange.emit({ + ...this.model, + [field]: date, + }); + } + + /** + * Configures the time for the submission opening time. + */ + configureSubmissionOpeningTime(time : TimeFormat) : void { + if (time.hour < 24 && time.minute > 0) { + // Case where minutes is not 0 since the earliest time with 0 minutes is the hour before + time.hour += 1; + time.minute = 0; + } else if (time.hour === 23 && time.minute > 0) { + time.minute = 59; + } + } + /** * Handles course Id change event. *