diff --git a/api/js/etemplate/Et2Link/Et2LinkList.ts b/api/js/etemplate/Et2Link/Et2LinkList.ts index 4e2667d19e..371c811d02 100644 --- a/api/js/etemplate/Et2Link/Et2LinkList.ts +++ b/api/js/etemplate/Et2Link/Et2LinkList.ts @@ -113,7 +113,6 @@ export class Et2LinkList extends Et2LinkString this._handleRowContext = this._handleRowContext.bind(this); this._handleChange = this._handleChange.bind(this); - this._handleLinkToChange = this._handleLinkToChange.bind(this); } connectedCallback() @@ -122,28 +121,19 @@ export class Et2LinkList extends Et2LinkString this._createContextMenu(); // Look for LinkTo and listen for change so we can update - if(this.getInstanceManager()) + this.getInstanceManager().DOMContainer.querySelectorAll("et2-link-to").forEach(link => { - this.getInstanceManager().DOMContainer.querySelectorAll("et2-link-to").forEach(link => - { - link.addEventListener("et2-change", this._handleLinkToChange); - }) - } - - this.addEventListener("change", this._handleChange); + link.addEventListener("et2-change", this._handleChange); + }) } disconnectedCallback() { super.disconnectedCallback(); - if(this.getInstanceManager()) + this.getInstanceManager().DOMContainer.querySelectorAll("et2-link-to").forEach(link => { - this.getInstanceManager().DOMContainer.querySelectorAll("et2-link-to").forEach(link => - { - link.removeEventListener("et2-change", this._handleLinkToChange); - }) - } - this.removeEventListener("change", this._handleChange); + link.removeEventListener("et2-change", this._handleChange); + }) } protected _listTemplate() @@ -257,27 +247,13 @@ export class Et2LinkList extends Et2LinkString } } - /** - * Handle & pass on an internal change - * @param {ChangeEvent} _event - * @protected - */ - protected _handleChange(_event : Event) - { - if(!this.onchange) - { - return; - } - this.onchange(this, _event.data, _event) - } - /** * We listen to LinkTo widgets so we can update * * @param _ev * @protected */ - protected _handleLinkToChange(_ev) + protected _handleChange(_ev) { if(_ev && typeof _ev.currentTarget) { @@ -325,9 +301,7 @@ export class Et2LinkList extends Et2LinkString return html``; } return html` - { this._delete_link(link); @@ -367,9 +341,6 @@ export class Et2LinkList extends Et2LinkString this._link_list.splice(this._link_list.indexOf(link), 1); } this.dispatchEvent(new CustomEvent("et2-delete", {bubbles: true, detail: link})); - let change = new Event("change", {bubbles: true}); - change['data'] = link; - this.dispatchEvent(change); }; // Unsaved entry, had no ID yet @@ -420,12 +391,7 @@ export class Et2LinkList extends Et2LinkString for(let id in list) { let link = list[id]; - if(!link.app && typeof list.splice !== "undefined") - { - list.splice(parseInt(id), 1); - continue; - } - else if(link.app) + if(link.app) { // Temp IDs can cause problems since the ID includes the file name or : if(link.link_id && typeof link.link_id != 'number') @@ -449,9 +415,9 @@ export class Et2LinkList extends Et2LinkString { link.title = link.id.name || ''; } + (this._link_list).push(link); } } - this._addLinks(list); } else { diff --git a/api/js/etemplate/Et2Link/Et2LinkString.ts b/api/js/etemplate/Et2Link/Et2LinkString.ts index c96721064d..7a99d9a31b 100644 --- a/api/js/etemplate/Et2Link/Et2LinkString.ts +++ b/api/js/etemplate/Et2Link/Et2LinkString.ts @@ -248,7 +248,7 @@ export class Et2LinkString extends Et2Widget(LitElement) implements et2_IDetache ); */ - this.dispatchEvent(new Event("change", {bubbles: true})); + } /**