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
This commit is contained in:
nathan 2024-10-23 10:42:55 -06:00
parent 15f405bd9c
commit 4448d39bfa
2 changed files with 14 additions and 3 deletions

View File

@ -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);
// 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);

View File

@ -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));