From bb4c3ae6ff456137544a4a817a8225ddb3156e7d Mon Sep 17 00:00:00 2001 From: Panagiotis Papadopoulos Date: Tue, 18 Feb 2025 22:18:11 +0100 Subject: [PATCH] feat(time_selector): add minimumSeconds handling --- .../widgets/type_widgets/options/time_selector.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/public/app/widgets/type_widgets/options/time_selector.ts b/src/public/app/widgets/type_widgets/options/time_selector.ts index 63275bc93..705cc7f75 100644 --- a/src/public/app/widgets/type_widgets/options/time_selector.ts +++ b/src/public/app/widgets/type_widgets/options/time_selector.ts @@ -74,7 +74,8 @@ export default class TimeSelector extends OptionsWidget { if (!this.handleTimeValidation() || typeof timeScale !== "string" || !time) return; - this.internalTimeInSeconds = this.convertTime(time, timeScale).toOption(); + this.setInternalTimeInSeconds(this.convertTime(time, timeScale).toOption()); + this.updateOption(this.optionValueId, this.internalTimeInSeconds); }); @@ -122,4 +123,13 @@ export default class TimeSelector extends OptionsWidget { } return true; } + + private setInternalTimeInSeconds(time: number) { + if (time < this.minimumSeconds) { + toastService.showError(`Entered time needs to be at least ${this.minimumSeconds} seconds.`); + return this.internalTimeInSeconds = this.minimumSeconds; + } + return this.internalTimeInSeconds = time; + } + }