From c707af32b63b65213ac6b31ab7086671001816be Mon Sep 17 00:00:00 2001 From: Hadi Nategh Date: Fri, 29 Apr 2022 14:28:32 +0200 Subject: [PATCH] Add hideOnEscape and noCloseButton options into ET2Dialog --- api/js/etemplate/Et2Dialog/Et2Dialog.ts | 19 ++++++++++-- .../etemplate/Et2Dialog/Et2DialogOverlay.ts | 29 +++++++++++++------ 2 files changed, 37 insertions(+), 11 deletions(-) diff --git a/api/js/etemplate/Et2Dialog/Et2Dialog.ts b/api/js/etemplate/Et2Dialog/Et2Dialog.ts index 20135aed23..faac1295a5 100644 --- a/api/js/etemplate/Et2Dialog/Et2Dialog.ts +++ b/api/js/etemplate/Et2Dialog/Et2Dialog.ts @@ -220,7 +220,21 @@ export class Et2Dialog extends Et2Widget(ScopedElementsMixin(SlotMixin(LionDialo * Automatically destroy the dialog when it closes. Set to false to keep the dialog around. */ destroy_on_close: Boolean, - appendTo: String + + /** + * Legacy-option for appending dialog into a specific dom node + */ + appendTo: String, + + /** + * When it's set to false dialog won't get closed by hitting Esc + */ + hideOnEscape: Boolean, + + /** + * When set to true it removes the close button from dialog's header + */ + noCloseButton: Boolean } } @@ -303,6 +317,7 @@ export class Et2Dialog extends Et2Widget(ScopedElementsMixin(SlotMixin(LionDialo this.modal = true; this.dialog_type = Et2Dialog.PLAIN_MESSAGE; this.destroy_on_close = true; + this.hideOnEscape = this.hideOnEscape === false ? false : true; this.__value = {}; this._onOpen = this._onOpen.bind(this); @@ -677,7 +692,7 @@ export class Et2Dialog extends Et2Widget(ScopedElementsMixin(SlotMixin(LionDialo } return { ...super._defineOverlayConfig(), - hidesOnEscape: true, + hidesOnEscape: this.hideOnEscape, ...(this.modal ? {} : not_modal) } diff --git a/api/js/etemplate/Et2Dialog/Et2DialogOverlay.ts b/api/js/etemplate/Et2Dialog/Et2DialogOverlay.ts index b30afcae78..ee60a37e86 100644 --- a/api/js/etemplate/Et2Dialog/Et2DialogOverlay.ts +++ b/api/js/etemplate/Et2Dialog/Et2DialogOverlay.ts @@ -209,15 +209,7 @@ export class Et2DialogOverlay extends SlotMixin(LitElement) - + ${this._closeButtonTemplate()}
@@ -229,6 +221,25 @@ export class Et2DialogOverlay extends SlotMixin(LitElement) `; } + _closeButtonTemplate() + { + if (this._dialog.noCloseButton) + { + return; + } + + return html` + `; + } + _buttonsTemplate() { if(!this.buttons)