Link fixes

- Fix links added to not yet saved entries were not displayed in link lists
- Adjust LinkList column sizes
This commit is contained in:
nathan 2022-05-12 10:54:29 -06:00
parent 485fa5e857
commit 9942ec9f08
4 changed files with 15 additions and 5 deletions

View File

@ -285,6 +285,11 @@ export class Et2Link extends ExposeMixin<Et2Widget>(Et2Widget(LitElement)) imple
_handleClick(_ev : MouseEvent) : boolean _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 didn't handle it (returns false), just use egw.open()
if(super._handleClick(_ev)) if(super._handleClick(_ev))
{ {

View File

@ -226,10 +226,14 @@ export class Et2LinkString extends Et2Widget(LitElement) implements et2_IDetache
* Starts the request for link list to the server * 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. * 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 = { let _value = {
to_app: this.application, to_app: this.application,
to_id: this.entry_id, to_id: this.entry_id,
@ -245,7 +249,7 @@ 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(_value); this._addLinks(not_saved_links.concat(_value));
this._loadingPromise = null; this._loadingPromise = null;
}) })
} }

View File

@ -446,8 +446,6 @@ export class et2_link_to extends et2_inputWidget
}, },
this, et2_link_list this, et2_link_list
); );
// Update any neighbouring link lists
(<Et2LinkList><unknown>(<et2_DOMWidget>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 // If there's an array of data (entry is not yet saved), updating the list will
// not work, so add them in explicitly. // not work, so add them in explicitly.
@ -476,6 +474,8 @@ export class et2_link_to extends et2_inputWidget
} }
} }
} }
// Update any neighbouring link lists
(<Et2LinkList><unknown>(<et2_DOMWidget>this.getParent()).getDOMNode().querySelector('et2-link-list'))?.get_links(Object.values(success));
} }
else else
{ {

View File

@ -1290,6 +1290,7 @@ ul.et2_link_string {
et2-link-list et2-link { et2-link-list et2-link {
color: initial; color: initial;
width: 30%;
} }
et2-link-list et2-link:hover { et2-link-list et2-link:hover {