From 4448d39bfab01689cf04deb3b4246d396bca4f2d Mon Sep 17 00:00:00 2001 From: nathan Date: Wed, 23 Oct 2024 10:42:55 -0600 Subject: [PATCH] Et2Link fixes - fix Vfs customfield with multiple didn't update UI after linking files - fix Vfs customfield without multiple didn't link, broken by 65caab5 --- api/js/etemplate/et2_extension_customfields.ts | 15 +++++++++++++-- api/src/Etemplate/Widget/Link.php | 2 +- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/api/js/etemplate/et2_extension_customfields.ts b/api/js/etemplate/et2_extension_customfields.ts index bf030601d5..1b70b9174c 100644 --- a/api/js/etemplate/et2_extension_customfields.ts +++ b/api/js/etemplate/et2_extension_customfields.ts @@ -956,9 +956,20 @@ export class et2_customfields_list extends et2_valueWidget implements et2_IDetac // Update link list & show file in upload widget.addEventListener("change", (e) => { + // Update lists document.querySelectorAll('et2-link-list').forEach(l => {l.get_links();}); - const info = e.target._dialog.fileInfo(e.target.value); - e.target.getParent().getWidgetById(attrs.id)?._addFile(info); + + // Show file(s) + const value = typeof e.target.value == "string" ? [e.target.value] : e.target.value; + value.forEach(v => + { + const info = e.target._dialog.fileInfo(v); + if(!e.target.multiple) + { + info.name = field.name; + } + e.target.getParent().getWidgetById(attrs.id)?._addFile(info); + }); e.target.getParent().getWidgetById(attrs.id).getDOMNode().classList.remove("hideme"); }); jQuery(widget.getDOMNode(widget)).css('vertical-align','top').prependTo(cf); diff --git a/api/src/Etemplate/Widget/Link.php b/api/src/Etemplate/Widget/Link.php index 85b3bb1f90..c303084718 100644 --- a/api/src/Etemplate/Widget/Link.php +++ b/api/src/Etemplate/Widget/Link.php @@ -314,7 +314,7 @@ class Link extends Etemplate\Widget } else { - if(!str_ends_with($dest_file, '/') && count($files) == 1 && is_int($id)) + if(!str_ends_with($dest_file, '/') && count($files) == 1) { // 1 file to a specific filename Api\Vfs::symlink($files[0], Api\Link::vfs_path($app, $id));