From 9942ec9f089edfb51af5471a9967528774e4d7bf Mon Sep 17 00:00:00 2001 From: nathan Date: Thu, 12 May 2022 10:54:29 -0600 Subject: [PATCH] Link fixes - Fix links added to not yet saved entries were not displayed in link lists - Adjust LinkList column sizes --- api/js/etemplate/Et2Link/Et2Link.ts | 5 +++++ api/js/etemplate/Et2Link/Et2LinkString.ts | 10 +++++++--- api/js/etemplate/et2_widget_link.ts | 4 ++-- api/templates/default/etemplate2.css | 1 + 4 files changed, 15 insertions(+), 5 deletions(-) diff --git a/api/js/etemplate/Et2Link/Et2Link.ts b/api/js/etemplate/Et2Link/Et2Link.ts index 76d543e6fa..78e608ceb1 100644 --- a/api/js/etemplate/Et2Link/Et2Link.ts +++ b/api/js/etemplate/Et2Link/Et2Link.ts @@ -285,6 +285,11 @@ export class Et2Link extends ExposeMixin(Et2Widget(LitElement)) imple _handleClick(_ev : MouseEvent) : boolean { + // If we don't have app & entry_id, nothing we can do + if(!this.app || !this.entry_id || typeof this.entry_id !== "string") + { + return false; + } // If super didn't handle it (returns false), just use egw.open() if(super._handleClick(_ev)) { diff --git a/api/js/etemplate/Et2Link/Et2LinkString.ts b/api/js/etemplate/Et2Link/Et2LinkString.ts index e9bd4b725e..14bdea6959 100644 --- a/api/js/etemplate/Et2Link/Et2LinkString.ts +++ b/api/js/etemplate/Et2Link/Et2LinkString.ts @@ -226,10 +226,14 @@ export class Et2LinkString extends Et2Widget(LitElement) implements et2_IDetache * Starts the request for link list to the server * * Called internally to fetch the list. May be called externally to trigger a refresh if a link is added. - * @protected + * */ - public get_links() + public get_links(not_saved_links? : LinkInfo[]) { + if(typeof not_saved_links === "undefined") + { + not_saved_links = []; + } let _value = { to_app: this.application, to_id: this.entry_id, @@ -245,7 +249,7 @@ export class Et2LinkString extends Et2Widget(LitElement) implements et2_IDetache this._loadingPromise = >(this.egw().jsonq('EGroupware\\Api\\Etemplate\\Widget\\Link::ajax_link_list', [_value])) .then(_value => { - this._addLinks(_value); + this._addLinks(not_saved_links.concat(_value)); this._loadingPromise = null; }) } diff --git a/api/js/etemplate/et2_widget_link.ts b/api/js/etemplate/et2_widget_link.ts index 208891743a..096a35288b 100644 --- a/api/js/etemplate/et2_widget_link.ts +++ b/api/js/etemplate/et2_widget_link.ts @@ -446,8 +446,6 @@ export class et2_link_to extends et2_inputWidget }, this, et2_link_list ); - // Update any neighbouring link lists - ((this.getParent()).getDOMNode().querySelector('et2-link-list'))?.get_links(); // If there's an array of data (entry is not yet saved), updating the list will // not work, so add them in explicitly. @@ -476,6 +474,8 @@ export class et2_link_to extends et2_inputWidget } } } + // Update any neighbouring link lists + ((this.getParent()).getDOMNode().querySelector('et2-link-list'))?.get_links(Object.values(success)); } else { diff --git a/api/templates/default/etemplate2.css b/api/templates/default/etemplate2.css index 241242cd95..88d474ce89 100644 --- a/api/templates/default/etemplate2.css +++ b/api/templates/default/etemplate2.css @@ -1290,6 +1290,7 @@ ul.et2_link_string { et2-link-list et2-link { color: initial; + width: 30%; } et2-link-list et2-link:hover {