* [task#133857,doing,0.5h] add btn and bind event to apply template.

This commit is contained in:
zhouxin
2024-12-09 14:30:01 +08:00
committed by 綦新志
parent 969e7b8d07
commit ebe4db5881
2 changed files with 27 additions and 0 deletions
+13
View File
@@ -0,0 +1,13 @@
window.applyTemplate = function()
{
const docApp = getDocApp();
const editor = docApp.editor.$;
const templateID = $('#template').find('.picker-box').zui('picker').$.value;
const url = $.createLink('doc', 'ajaxGetTemplateContent', `id=${templateID}`);
$.get(url, function(data)
{
data = JSON.parse(data);
editor.updateDoc(data.content, data.type != 'doc' ? data.type : undefined);
});
}
+14
View File
@@ -14,10 +14,24 @@ formPanel
set::title($lang->doc->template),
formGroup
(
setID('template'),
set::label($lang->doc->selectTemplate),
set::name('template'),
set::required(true),
set::width('5/6'),
set::items($templatePairs)
),
set::actions(array()),
formGroup
(
setClass('form-actions'),
btn
(
$lang->save,
set::btnType('button'),
set::type('primary'),
setData('dismiss', 'modal'),
on::click('applyTemplate')
)
)
);