From 5f2aba2af93ff8ff9428af5ebb674483b7b90397 Mon Sep 17 00:00:00 2001 From: nathan Date: Thu, 1 Aug 2024 10:36:17 -0600 Subject: [PATCH] Fix context menu "Copy ..." of text contents --- api/js/egw_action/EgwPopupActionImplementation.ts | 2 +- api/js/etemplate/Et2Date/Et2DateDurationReadonly.ts | 5 +++++ api/js/etemplate/Et2Date/Et2DateReadonly.ts | 6 ++++++ api/js/etemplate/Et2Link/Et2Link.ts | 4 ++++ api/js/etemplate/Et2Select/Select/Et2SelectReadonly.ts | 9 +++++++++ 5 files changed, 25 insertions(+), 1 deletion(-) diff --git a/api/js/egw_action/EgwPopupActionImplementation.ts b/api/js/egw_action/EgwPopupActionImplementation.ts index 16a9bdbb0c..049d7e6e24 100644 --- a/api/js/egw_action/EgwPopupActionImplementation.ts +++ b/api/js/egw_action/EgwPopupActionImplementation.ts @@ -662,7 +662,7 @@ export class EgwPopupActionImplementation implements EgwActionImplementation { } let os_clipboard_caption = ""; if (this._context.event) { - os_clipboard_caption = this._context.innerText.trim(); + os_clipboard_caption = this._context.event.target.innerText.trim() clipboard_action.set_caption(window.egw.lang('Copy "%1"', os_clipboard_caption.length > 20 ? os_clipboard_caption.substring(0, 20) + '...' : os_clipboard_caption)); clipboard_action.data.target = this._context.target; } diff --git a/api/js/etemplate/Et2Date/Et2DateDurationReadonly.ts b/api/js/etemplate/Et2Date/Et2DateDurationReadonly.ts index 9463b00b44..333e9e2bd8 100644 --- a/api/js/etemplate/Et2Date/Et2DateDurationReadonly.ts +++ b/api/js/etemplate/Et2Date/Et2DateDurationReadonly.ts @@ -52,6 +52,11 @@ export class Et2DateDurationReadonly extends Et2DateDuration this.requestUpdate("value", old_value); } + get innerText() : string + { + return this.shadowRoot.querySelector('span').innerText; + } + render() { let parsed = this.__value; diff --git a/api/js/etemplate/Et2Date/Et2DateReadonly.ts b/api/js/etemplate/Et2Date/Et2DateReadonly.ts index e9c60b7ba6..5128cfcb22 100644 --- a/api/js/etemplate/Et2Date/Et2DateReadonly.ts +++ b/api/js/etemplate/Et2Date/Et2DateReadonly.ts @@ -50,6 +50,12 @@ export class Et2DateReadonly extends Et2Widget(LitElement) implements et2_IDetac this.value = value; } + get innerText() : string + { + let parsed : Date | Boolean = this.value ? this.parser(this.value, this.dataFormat) : false + return this.value ? this.formatter(parsed) : ''; + } + render() { let parsed : Date | Boolean = this.value ? this.parser(this.value, this.dataFormat) : false diff --git a/api/js/etemplate/Et2Link/Et2Link.ts b/api/js/etemplate/Et2Link/Et2Link.ts index 08c82ca081..41fcb0b87f 100644 --- a/api/js/etemplate/Et2Link/Et2Link.ts +++ b/api/js/etemplate/Et2Link/Et2Link.ts @@ -426,6 +426,10 @@ export class Et2Link extends ExposeMixin(Et2Widget(LitElement)) imple return false; } + get innerText() : string + { + return this.title; + } getDetachedAttributes(_attrs : string[]) { _attrs.push("app", "entryId", "statustext"); diff --git a/api/js/etemplate/Et2Select/Select/Et2SelectReadonly.ts b/api/js/etemplate/Et2Select/Select/Et2SelectReadonly.ts index 16fd244bbf..e37baceeb3 100644 --- a/api/js/etemplate/Et2Select/Select/Et2SelectReadonly.ts +++ b/api/js/etemplate/Et2Select/Select/Et2SelectReadonly.ts @@ -227,6 +227,15 @@ li { return this.__select_options; } + get innerText() : string + { + return typeof this.value == "string" ? this.select_options.find(o => o.value == this.value) : + this.select_options + .filter(o => this.value.includes("" + o.value)) + .map(o => o.label) + .join(", "); + } + render() { const value = this.getValueAsArray();