VfsSelectDialog bugfixes:

- Fix passing mimeList via loadWebComponent() did not preserve objects but stringified them
- Fix initial search fired before attributes got set when loaded via loadWebComponent()
- Fix show() did not always wait for dialog
This commit is contained in:
nathan 2024-03-06 14:25:48 -07:00
parent 46a5581d2b
commit 78810e9653

View File

@ -100,7 +100,7 @@ export class Et2VfsSelectDialog
@property() mime : string | string[] | RegExp = ""; @property() mime : string | string[] | RegExp = "";
/** List of mimetypes to allow user to filter. */ /** List of mimetypes to allow user to filter. */
@property() mimeList : SelectOption[] = [ @property({type: Array}) mimeList : SelectOption[] = [
{ {
value: "/(application\\/vnd.oasis.opendocument.text|application\\/vnd.openxmlformats-officedocument.wordprocessingml.document)/i", value: "/(application\\/vnd.oasis.opendocument.text|application\\/vnd.openxmlformats-officedocument.wordprocessingml.document)/i",
label: "Documents" label: "Documents"
@ -209,8 +209,6 @@ export class Et2VfsSelectDialog
{ {
this.path = <string>this.egw()?.preference("startfolder", "filemanager") || "~"; this.path = <string>this.egw()?.preference("startfolder", "filemanager") || "~";
} }
// Get file list
this.startSearch();
} }
async getUpdateComplete() async getUpdateComplete()
@ -230,6 +228,8 @@ export class Et2VfsSelectDialog
this._dialog.panel.style.width = "60em"; this._dialog.panel.style.width = "60em";
this._dialog.panel.style.height = "40em"; this._dialog.panel.style.height = "40em";
}); });
// Get file list
this.startSearch();
} }
protected willUpdate(changedProperties : PropertyValues) protected willUpdate(changedProperties : PropertyValues)
@ -297,9 +297,11 @@ export class Et2VfsSelectDialog
} }
return Promise.all([ return Promise.all([
this.updateComplete, this.updateComplete,
this._searchPromise, this._searchPromise
this._dialog.show()
]).then(() => ]).then(() =>
{
return this._dialog.show();
}).then(() =>
{ {
// Set current file to first value // Set current file to first value
if(this.value && this.value[0]) if(this.value && this.value[0])
@ -320,6 +322,7 @@ export class Et2VfsSelectDialog
async getComplete() : Promise<[number, Object]> async getComplete() : Promise<[number, Object]>
{ {
await this.updateComplete;
const value = await this._dialog.getComplete(); const value = await this._dialog.getComplete();
await this.handleClose(); await this.handleClose();
value[1] = this.value; value[1] = this.value;