Api: Fix doubled link on open and missing link app select

This commit is contained in:
nathan 2023-07-25 10:26:22 -06:00
parent a89b69528e
commit b44ea1b2b0
2 changed files with 13 additions and 6 deletions

View File

@ -284,7 +284,7 @@ export class Et2LinkEntry extends Et2InputWidget(FormControlMixin(SlotMixin(LitE
protected _handleEntrySelect(event) protected _handleEntrySelect(event)
{ {
event.stopPropagation(); event.stopPropagation();
this.classList.add("hideApp"); this.classList.toggle("hideApp", Boolean(typeof this.value == "object" ? this.value?.id : this.value));
this.dispatchEvent(new Event("change")); this.dispatchEvent(new Event("change"));
this.requestUpdate('value'); this.requestUpdate('value');
@ -390,10 +390,7 @@ export class Et2LinkEntry extends Et2InputWidget(FormControlMixin(SlotMixin(LitE
this.app = value.app; this.app = value.app;
this._searchNode.value = value.id; this._searchNode.value = value.id;
} }
if(value.id) this.classList.toggle("hideApp", Boolean(value.id));
{
this.classList.add("hideApp");
}
} }
/** /**

View File

@ -300,7 +300,17 @@ export class Et2LinkString extends Et2Widget(LitElement) implements et2_IDetache
this._loadingPromise = <Promise<LinkInfo[]>>(this.egw().jsonq('EGroupware\\Api\\Etemplate\\Widget\\Link::ajax_link_list', [_value])) this._loadingPromise = <Promise<LinkInfo[]>>(this.egw().jsonq('EGroupware\\Api\\Etemplate\\Widget\\Link::ajax_link_list', [_value]))
.then(_value => .then(_value =>
{ {
this._addLinks(not_saved_links.concat(_value)); if(_value && Array.isArray(_value))
{
for(let link of <LinkInfo[]>_value)
{
if(!not_saved_links.some(l => l.app == link.app && l.id == link.id))
{
not_saved_links.push(link);
}
}
}
this._addLinks(not_saved_links);
this._loadingPromise = null; this._loadingPromise = null;
}) })
} }