From ae0fb66e4be86ffff3aa9eb0bdfb55e4f659893d Mon Sep 17 00:00:00 2001 From: xieqiyu Date: Tue, 29 Apr 2025 10:04:19 +0800 Subject: [PATCH] * [bug#61285] Set the button of create template when has no template in list. --- module/doc/js/browsetemplate.ui.js | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/module/doc/js/browsetemplate.ui.js b/module/doc/js/browsetemplate.ui.js index 1852d5aea9..a153599213 100644 --- a/module/doc/js/browsetemplate.ui.js +++ b/module/doc/js/browsetemplate.ui.js @@ -499,7 +499,26 @@ $.extend(window.docAppActions, {text: lang.cancel, size: 'md', className: 'btn-wide', type: 'primary-outline', command: 'cancelEditDoc'}, {text: lang.settings, size: 'md', type: 'ghost', command: `showDocSettingModal/${doc.id}/template/1`, icon: 'cog-outline'}, ]; - } + }, + /** + * 定义模板列表的操作按钮。 + * Define the actions on the template list. + */ + 'doc-list': function(info) + { + const lang = getLang(); + const canCreateDoc = hasPriv('create'); + + /* 文档列表没有文档时的按钮。Actions for empty doc list. */ + if(info.ui === 'doc-list-empty') + { + return canCreateDoc ? [{icon: 'plus', text: lang.createTemplate, btnType: 'primary', command: 'startCreateTemplate'}] : null; + } + + const items = []; + if(canCreateDoc) items.push({text: lang.createTemplate, icon: 'plus', btnType: 'primary', command: 'startCreateTemplate'}); + return items.length ? {component: 'toolbar', props: {items: items}} : null; + }, }); /**