mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-29 10:09:10 +01:00
Work on LinkEntry
- fix title missing on load when we didn't have it client side
This commit is contained in:
parent
9579fc0caf
commit
850f6effeb
@ -110,7 +110,7 @@ export class Et2Link extends ExposeMixin<Et2Widget>(Et2Widget(LitElement)) imple
|
||||
}
|
||||
}
|
||||
|
||||
private static MISSING_TITLE = "??";
|
||||
static MISSING_TITLE = "??";
|
||||
|
||||
// Title is read-only inside
|
||||
private _title : string;
|
||||
|
@ -82,7 +82,6 @@ export class Et2LinkEntry extends Et2InputWidget(FormControlMixin(ValidateMixin(
|
||||
if (this.__value && typeof this.__value === 'object')
|
||||
{
|
||||
select.app = this.__value.app;
|
||||
select.select_options = [{value: this.__value.id, label: this.__value.title}];
|
||||
select.value = this.__value.id;
|
||||
}
|
||||
else
|
||||
|
@ -10,6 +10,7 @@
|
||||
import {css} from "@lion/core";
|
||||
import {Et2Select} from "../Et2Select/Et2Select";
|
||||
import {Et2LinkAppSelect} from "./Et2LinkAppSelect";
|
||||
import {Et2Link} from "./Et2Link";
|
||||
|
||||
export class Et2LinkSearch extends Et2Select
|
||||
{
|
||||
@ -67,6 +68,45 @@ export class Et2LinkSearch extends Et2Select
|
||||
this.processRemoteResults(result);
|
||||
});
|
||||
}
|
||||
|
||||
updated(changedProperties)
|
||||
{
|
||||
super.updated(changedProperties);
|
||||
|
||||
// Set a value we don't have as an option? That's OK, we'll just add it
|
||||
if(changedProperties.has("value") && this.value && (
|
||||
this.menuItems && this.menuItems.length == 0 ||
|
||||
this.menuItems?.filter && this.menuItems.filter(item => this.value.includes(item.value)).length == 0
|
||||
))
|
||||
{
|
||||
this._missingOption(this.value)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The set value requires an option we don't have.
|
||||
* Add it in, asking server for title if needed
|
||||
*
|
||||
* @param value
|
||||
* @protected
|
||||
*/
|
||||
protected _missingOption(value : string)
|
||||
{
|
||||
let option = {
|
||||
value: value,
|
||||
label: Et2Link.MISSING_TITLE,
|
||||
class: "loading"
|
||||
}
|
||||
// Weird call instead of just unshift() to make sure to trigger setter
|
||||
this.select_options = Object.assign([option], this.__select_options);
|
||||
this.egw()?.link_title(this.app, option.value, true).then(title =>
|
||||
{
|
||||
option.label = title;
|
||||
option.class = "";
|
||||
// It's probably already been rendered
|
||||
this.requestUpdate();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// @ts-ignore TypeScript is not recognizing that this widget is a LitElement
|
||||
|
Loading…
Reference in New Issue
Block a user