diff --git a/api/js/etemplate/Et2Link/Et2LinkString.ts b/api/js/etemplate/Et2Link/Et2LinkString.ts index 76aedcd06d..7a99d9a31b 100644 --- a/api/js/etemplate/Et2Link/Et2LinkString.ts +++ b/api/js/etemplate/Et2Link/Et2LinkString.ts @@ -10,7 +10,7 @@ */ -import {css, html, LitElement, render, TemplateResult, until} from "@lion/core"; +import {css, html, LitElement, PropertyValues, render, TemplateResult, until} from "@lion/core"; import {Et2Widget} from "../Et2Widget/Et2Widget"; import {Et2Link, LinkInfo} from "./Et2Link"; import {et2_IDetachedDOM} from "../et2_core_interfaces"; @@ -158,6 +158,19 @@ export class Et2LinkString extends Et2Widget(LitElement) implements et2_IDetache super.requestUpdate(); } + public updated(changedProperties : PropertyValues) + { + super.updated(changedProperties); + + if((changedProperties.has("application") || changedProperties.has("entryId") || changedProperties.has("onlyApp") || changedProperties.has("linkType")) && + this.application && this.entryId + ) + { + // Something changed, and we have the information needed to get the matching links + this.get_links(); + } + } + public render() : TemplateResult { // This shows loading template until loadingPromise resolves, then shows _listTemplate @@ -253,8 +266,8 @@ export class Et2LinkString extends Et2Widget(LitElement) implements et2_IDetache let _value = { to_app: this.application, to_id: this.entryId, - onlyApp: this.onlyApp, - showDeleted: this.showDeleted + only_app: this.onlyApp, + show_deleted: this.showDeleted }; if(this._loadingPromise) { diff --git a/api/src/Etemplate/Widget/Link.php b/api/src/Etemplate/Widget/Link.php index cd78fd124a..4e3938310b 100644 --- a/api/src/Etemplate/Widget/Link.php +++ b/api/src/Etemplate/Widget/Link.php @@ -186,18 +186,31 @@ class Link extends Etemplate\Widget public static function ajax_link_list($value) { $app = $value['to_app']; - $id = $value['to_id']; + $id = $value['to_id']; - $links = Api\Link::get_links($app,$id,$value['only_app'],'link_lastmod DESC',true, $value['show_deleted']); - foreach($links as &$link) + $links = Api\Link::get_links($app, $id, $value['only_app'], 'link_lastmod DESC', true, $value['show_deleted']); + $only_links = []; + if($value['only_app']) { - $link['title'] = Api\Link::title($link['app'],$link['id'],$link); - if ($link['app'] == Api\Link::VFS_APPNAME) + $only_links = Api\Link::get_links_multiple($value['only_app'], $links); + } + foreach($links as $link_id => &$link) + { + if(!is_array($link) && array_key_exists($link, $only_links)) + { + $only_id = $link; + $link = array_merge( + $only_links[$link][$link_id], + ['id' => $only_id, 'app' => $value['only_app']] + ); + } + $link['title'] = Api\Link::title($link['app'], $link['id'], $link); + if($link['app'] == Api\Link::VFS_APPNAME) { $link['target'] = '_blank'; $link['help'] = lang('Delete this file'); $link['title'] = Api\Vfs::decodePath($link['title']); - $link['icon'] = Api\Link::vfs_path($link['app2'],$link['id2'],$link['id'],true); + $link['icon'] = Api\Link::vfs_path($link['app2'], $link['id2'], $link['id'], true); $link['download_url'] = Api\Vfs::download_url($link['icon']); // Make links to directories load in filemanager diff --git a/api/src/Link.php b/api/src/Link.php index 9773a71fac..20eb657b15 100644 --- a/api/src/Link.php +++ b/api/src/Link.php @@ -536,7 +536,7 @@ class Link extends Link\Storage $app_ids = array(); foreach($ids as $link) { - $app_ids[$link['app']][] = $link['id']; + $app_ids[$only_app ? $only_app : $link['app']][] = is_array($link) ? $link['id'] : $link; } foreach($app_ids as $appname => $a_ids) { @@ -545,7 +545,7 @@ class Link extends Link\Storage // remove links, current user has no access, from result foreach($ids as $key => $link) { - if (!self::title($link['app'],$link['id'])) + if(!self::title(is_array($link) ? $link['app'] : $only_app, is_array($link) ? $link['id'] : $link)) { unset($ids[$key]); }