From 312bf62adc5ade3a2d80c9a19aa0e2dd57c64a3b Mon Sep 17 00:00:00 2001 From: nathan Date: Mon, 1 Nov 2021 10:21:08 -0600 Subject: [PATCH] Implement readonly for date widget --- api/js/etemplate/Et2Date/Et2Date.ts | 28 +++++++++++++++++++ api/js/etemplate/Et2Date/test/Et2Date.test.ts | 15 ++++++++++ 2 files changed, 43 insertions(+) diff --git a/api/js/etemplate/Et2Date/Et2Date.ts b/api/js/etemplate/Et2Date/Et2Date.ts index 06d7a4ca6e..c1288da6ef 100644 --- a/api/js/etemplate/Et2Date/Et2Date.ts +++ b/api/js/etemplate/Et2Date/Et2Date.ts @@ -186,6 +186,11 @@ export class Et2Date extends Et2InputWidget(LionInputDatepicker) getValue() { + if(this.readOnly) + { + return null; + } + // The supplied value was not understandable, return null if(this.modelValue instanceof Unparseable || !this.modelValue) { @@ -236,12 +241,35 @@ export class Et2Date extends Et2InputWidget(LionInputDatepicker) return new Date(modelValue.getTime() + offset); } + /** + * Overriding from parent for read-only + * + * @return {TemplateResult} + * @protected + */ + // eslint-disable-next-line class-methods-use-this + _inputGroupInputTemplate() + { + if(this.readOnly) + { + return this.formattedValue; + } + else + { + return super._inputGroupInputTemplate(); + } + } + /** * Overriding parent to add class to button, and use an image instead of unicode emoji */ // eslint-disable-next-line class-methods-use-this _invokerTemplate() { + if(this.readOnly) + { + return ''; + } let img = this.egw() ? this.egw().image("calendar") || '' : ''; return html`