Api: Fix browser cached VFS customfield icon, so it looked like it wasn't changing when you choose a different file

This commit is contained in:
nathan 2024-10-25 11:42:07 -06:00
parent b32b4338ed
commit e3c7831bc5

View File

@ -960,18 +960,32 @@ export class et2_customfields_list extends et2_valueWidget implements et2_IDetac
document.querySelectorAll('et2-link-list').forEach(l => {l.get_links();});
// Show file(s)
const list = e.target.getParent().getWidgetById(attrs.id);
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;
info.path = "/apps/" + e.target.methodId.replaceAll(":", "/");
// Clear list here, _addFile won't replace with the cachebuster
list.list.empty();
list._children.forEach((c) =>
{
if(typeof c.remove == "function")
{
c.remove();
}
e.target.getParent().getWidgetById(attrs.id)?._addFile(info);
c.getParent().removeChild(c);
c.destroy();
});
e.target.getParent().getWidgetById(attrs.id).getDOMNode().classList.remove("hideme");
info.name = field.name;
// Use a cache buster since file has the same name
info.path = "/apps/" + e.target.methodId.replaceAll(":", "/") + "#" + new Date().getTime();
}
list?._addFile(info);
});
list.getDOMNode().classList.remove("hideme");
});
jQuery(widget.getDOMNode(widget)).css('vertical-align','top').prependTo(cf);
}