From 068e3feff09e54f176d99fc5defbae0c7e439b81 Mon Sep 17 00:00:00 2001 From: nathan Date: Tue, 19 Oct 2021 14:15:37 -0600 Subject: [PATCH] Api: Fix setting the date min attribute to a number did not work jQueryUI timepicker checks the type of variable --- api/js/etemplate/et2_widget_date.ts | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/api/js/etemplate/et2_widget_date.ts b/api/js/etemplate/et2_widget_date.ts index 7e2b8b36a2..3519e9f11a 100644 --- a/api/js/etemplate/et2_widget_date.ts +++ b/api/js/etemplate/et2_widget_date.ts @@ -397,9 +397,15 @@ String: A string in the user\'s date format, or a relative date. Relative dates */ set_min(_value) { + // minDate option checks the type, so make sure we're passing numbers as numbers (0, not "0") + // @ts-ignore + if(typeof _value === "string" && !isNaN(_value) && "" + parseInt(_value) == _value) + { + _value = parseInt(_value); + } if(this.input_date) { - if (this.is_mobile) + if(this.is_mobile) { this.input_date.attr('min', this._relativeDate(_value)); } @@ -452,9 +458,15 @@ String: A string in the user\'s date format, or a relative date. Relative dates */ set_max(_value) { + // maxDate option checks the type, so make sure we're passing numbers as numbers (0, not "0") + // @ts-ignore + if(typeof _value === "string" && !isNaN(_value) && "" + parseInt(_value) == _value) + { + _value = parseInt(_value); + } if(this.input_date) { - if (this.is_mobile) + if(this.is_mobile) { this.input_date.attr('max', this._relativeDate(_value)); }