From 1e5578d87fba057b78600e4ec46ebb4ee754f462 Mon Sep 17 00:00:00 2001 From: liumengyi Date: Wed, 3 Jan 2024 17:14:45 +0800 Subject: [PATCH] * Fix bug of file template deletion. --- module/file/ui/export.html.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/module/file/ui/export.html.php b/module/file/ui/export.html.php index 558c9535f0..a5bbf801e0 100644 --- a/module/file/ui/export.html.php +++ b/module/file/ui/export.html.php @@ -280,7 +280,7 @@ window.saveTemplate = function() if(!title || !content) return; const saveTemplateLink = $.createLink('file', 'ajaxSaveTemplate', 'module={$this->moduleName}'); - $.post(saveTemplateLink, {title:title, content:content, public:isPublic}, function(data) + $.post(saveTemplateLink, {title:title, content:content.join(','), public:isPublic}, function(data) { if(data.indexOf('alert') == -1) { @@ -301,11 +301,13 @@ window.deleteTemplate = function() var templateID = template.val(); if(templateID == 0) return; - deleteLink = $.createLink('file', 'ajaxDeleteTemplate', 'templateID=' + templateID); + const deleteLink = $.createLink('file', 'ajaxDeleteTemplate', 'templateID=' + templateID); $.get(deleteLink, function() { - template.find('option[value="'+ templateID +'"]').remove(); - setTemplate(template); + const templatePicker = template.zui('picker'); + const newItems = templatePicker.options.items.filter(item => item.value != templateID); + templatePicker.render({items: newItems, value: ''}); + templatePicker.$.setValue('').ready(setTemplate(template)); }); };