diff --git a/api/js/etemplate/Et2Link/Et2LinkAppSelect.ts b/api/js/etemplate/Et2Link/Et2LinkAppSelect.ts index 5c7e363997..c11cf90ef2 100644 --- a/api/js/etemplate/Et2Link/Et2LinkAppSelect.ts +++ b/api/js/etemplate/Et2Link/Et2LinkAppSelect.ts @@ -108,10 +108,23 @@ export class Et2LinkAppSelect extends SlotMixin(Et2Select) // Set icon this.querySelector("[slot='prefix']").setAttribute("src", this.value + "/navbar"); + if(!this.value) + { + // use preference + let appname = ""; + if(typeof this.value != 'undefined' && this.parentNode && this.parentNode.to_app) + { + appname = this.parentNode.to_app; + } + this.value = this.egw().preference('link_app', appname || this.egw().app_name()); + } // Register to this.addEventListener("change", this._handleChange); - if (this.__only_app) this.style.display = 'none'; + if(this.__only_app) + { + this.style.display = 'none'; + } } disconnectedCallback() @@ -151,9 +164,9 @@ export class Et2LinkAppSelect extends SlotMixin(Et2Select) return this.__application_list; } - get value() + get value() : string { - return this.only_app ? this.only_app : super.value; + return this.only_app ? this.only_app : super.value; } set value(new_value) diff --git a/api/js/etemplate/Et2Link/Et2LinkEntry.ts b/api/js/etemplate/Et2Link/Et2LinkEntry.ts index efbb7b9090..f48d804875 100644 --- a/api/js/etemplate/Et2Link/Et2LinkEntry.ts +++ b/api/js/etemplate/Et2Link/Et2LinkEntry.ts @@ -63,7 +63,12 @@ export class Et2LinkEntry extends Et2InputWidget(FormControlMixin(ValidateMixin( /** * Callback when user selects an option. Must return true, or false to abort normal action. */ - select: {type: Function} + select: {type: Function}, + + /** + * Displayed in the search / select when no value is selected + */ + placeholder: {type: String} } } @@ -174,6 +179,10 @@ export class Et2LinkEntry extends Et2InputWidget(FormControlMixin(ValidateMixin( { this.app = app; } + if(this._appNode) + { + this._appNode.only_app = app; + } } get only_app() @@ -205,6 +214,15 @@ export class Et2LinkEntry extends Et2InputWidget(FormControlMixin(ValidateMixin( return this.querySelector("[slot='select']"); } + get placeholder() : string + { + return this._searchNode?.placeholder; + } + + set placeholder(new_value) + { + this._searchNode.placeholder = new_value; + } protected _bindListeners() { @@ -244,6 +262,7 @@ export class Et2LinkEntry extends Et2InputWidget(FormControlMixin(ValidateMixin( protected _handleEntrySelect(event) { this.classList.add("hideApp"); + this.dispatchEvent(new Event("change")); } @@ -256,6 +275,8 @@ export class Et2LinkEntry extends Et2InputWidget(FormControlMixin(ValidateMixin( { this.classList.remove("hideApp") this._searchNode.focus(); + + this.dispatchEvent(new Event("change")); } @@ -290,7 +311,7 @@ export class Et2LinkEntry extends Et2InputWidget(FormControlMixin(ValidateMixin( { if(this.only_app) { - return this._searchNode?.value; + return this._searchNode?.value; } return this._searchNode ? { id: this._searchNode.value, @@ -301,7 +322,7 @@ export class Et2LinkEntry extends Et2InputWidget(FormControlMixin(ValidateMixin( set value(val : LinkInfo | string | number) { - let value : LinkInfo = {app: this.only_app, id: ""}; + let value : LinkInfo = {app: this.only_app || this.app, id: ""}; if(typeof val === 'string' && val.length > 0) {