Et2LinkTo: Fix paste from clipboard button was always disabled

This commit is contained in:
nathan 2024-07-16 08:54:03 -06:00
parent 4537362830
commit 485d6a7f40

View File

@ -98,7 +98,7 @@ export class Et2LinkTo extends Et2InputWidget(LitElement)
}; };
} }
private get pasteButton() { return this.shadowRoot?.querySelector("#paste"); } private get pasteButton() : Et2VfsSelectButton { return this.shadowRoot?.querySelector("#paste"); }
private get pasteDialog() { return this.pasteButton?.querySelector("et2-link-paste-dialog"); } private get pasteDialog() { return this.pasteButton?.querySelector("et2-link-paste-dialog"); }
@ -148,8 +148,10 @@ export class Et2LinkTo extends Et2InputWidget(LitElement)
method = 'EGroupware\\Api\\Etemplate\\Widget\\Link::ajax_link_existing'; method = 'EGroupware\\Api\\Etemplate\\Widget\\Link::ajax_link_existing';
method_id = this.value.to_app + ':' + this.value.to_id; method_id = this.value.to_app + ':' + this.value.to_id;
let clipboard_files = getClipboardFiles(); getClipboardFiles().then((files) =>
pasteEnabled = clipboard_files.length > 0; {
this.pasteButton.disabled = files.length == 0;
});
} }
return html` return html`
@ -177,7 +179,7 @@ export class Et2LinkTo extends Et2InputWidget(LitElement)
image="linkpaste" aria-label=${this.egw().lang("clipboard contents")} noSubmit="true" image="linkpaste" aria-label=${this.egw().lang("clipboard contents")} noSubmit="true"
title=${this.egw().lang("Clipboard contents")} title=${this.egw().lang("Clipboard contents")}
?readonly=${this.readonly} ?readonly=${this.readonly}
?disabled=${!pasteEnabled} disabled
multiple multiple
@click=${async(e) => @click=${async(e) =>
{ {