From 2cfab31d19bd758ee634720bddb710ed2b9acda1 Mon Sep 17 00:00:00 2001 From: nathan Date: Thu, 12 Sep 2024 14:13:47 -0600 Subject: [PATCH] Et2DateDuration: Fix disabled was not disabling inputs, reflect change event --- api/js/etemplate/Et2Date/Et2Date.ts | 5 ++++- api/js/etemplate/Et2Date/Et2DateRange.ts | 25 +++++++++++++++++++----- 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/api/js/etemplate/Et2Date/Et2Date.ts b/api/js/etemplate/Et2Date/Et2Date.ts index aef36b4376..2a16376145 100644 --- a/api/js/etemplate/Et2Date/Et2Date.ts +++ b/api/js/etemplate/Et2Date/Et2Date.ts @@ -1036,7 +1036,10 @@ export class Et2Date extends Et2InputWidget(LitFlatpickr) // This element gets hidden and used for value, but copied by flatpickr and used for input return html` - + ${this._incrementButtonTemplate()} diff --git a/api/js/etemplate/Et2Date/Et2DateRange.ts b/api/js/etemplate/Et2Date/Et2DateRange.ts index 83e94534d8..088ab94f44 100644 --- a/api/js/etemplate/Et2Date/Et2DateRange.ts +++ b/api/js/etemplate/Et2Date/Et2DateRange.ts @@ -54,6 +54,14 @@ export class Et2DateRange extends Et2InputWidget(LitElement) super(); } + _handleChange(event) + { + this.updateComplete.then(() => + { + this.dispatchEvent(new Event("change", {bubbles: true})); + }); + } + render() { const hasLabel = this.label ? true : false @@ -74,7 +82,10 @@ export class Et2DateRange extends Et2InputWidget(LitElement) ${this.label} -
${this._inputGroupTemplate()}
+
+ ${this._inputGroupTemplate()} +
`; + .select_options=${Et2DateRange.relative_dates} + @change=${this._handleChange} + >`; } /** @@ -131,6 +144,7 @@ export class Et2DateRange extends Et2InputWidget(LitElement) ?required=${this.required} placeholder=${ifDefined(this.placeholder || this.egw().lang("From"))} defaultDate=${ifDefined(this.value?.from)} + @change=${this._handleChange} > `; } @@ -193,14 +208,14 @@ export class Et2DateRange extends Et2InputWidget(LitElement) new_value = Et2DateRange.relativeToAbsolute(new_value); } - if(this.fromElement._instance) + if(this.fromElement._instance?.config?.mode == "range") { this.fromElement._instance.setDate([new_value?.from, new_value?.to], true); } else { - this.fromElement.value = new_value?.from.toJSON() || ""; - this.toElement.value = new_value?.to.toJSON() || ""; + this.fromElement.value = new_value?.from?.toJSON() || ""; + this.toElement.value = new_value?.to?.toJSON() || ""; } } }