|
@@ -34,13 +34,14 @@ func (this *Modules) template_GetThemeFiles(wrap *wrapper.Wrapper) []string {
|
|
|
|
|
|
func (this *Modules) RegisterModule_Template() *Module {
|
|
|
return this.newModule(MInfo{
|
|
|
- Mount: "template",
|
|
|
- Name: "Template",
|
|
|
+ Mount: "templates",
|
|
|
+ Name: "Templates",
|
|
|
Order: 802,
|
|
|
System: true,
|
|
|
Icon: assets.SysSvgIconView,
|
|
|
Sub: &[]MISub{
|
|
|
- {Mount: "default", Name: "Editor", Show: true, Icon: assets.SysSvgIconEdit},
|
|
|
+ {Mount: "default", Name: "Template editor", Show: true, Icon: assets.SysSvgIconEdit},
|
|
|
+ {Mount: "create", Name: "Add new template", Show: true, Icon: assets.SysSvgIconPlus},
|
|
|
{Mount: "restore", Name: "Restore", Show: true, Icon: assets.SysSvgIconRestore},
|
|
|
},
|
|
|
}, nil, func(wrap *wrapper.Wrapper) (string, string, string) {
|
|
@@ -48,7 +49,7 @@ func (this *Modules) RegisterModule_Template() *Module {
|
|
|
sidebar := ""
|
|
|
if wrap.CurrSubModule == "" || wrap.CurrSubModule == "default" {
|
|
|
content += this.getBreadCrumbs(wrap, &[]consts.BreadCrumb{
|
|
|
- {Name: "Editor"},
|
|
|
+ {Name: "Template editor"},
|
|
|
})
|
|
|
|
|
|
files := this.template_GetThemeFiles(wrap)
|
|
@@ -80,7 +81,7 @@ func (this *Modules) RegisterModule_Template() *Module {
|
|
|
{
|
|
|
Kind: builder.DFKHidden,
|
|
|
Name: "action",
|
|
|
- Value: "template-edit-theme-file",
|
|
|
+ Value: "templates-edit-theme-file",
|
|
|
},
|
|
|
{
|
|
|
Kind: builder.DFKText,
|
|
@@ -92,7 +93,7 @@ func (this *Modules) RegisterModule_Template() *Module {
|
|
|
`<div class="row">` +
|
|
|
`<div class="col-12">` +
|
|
|
`<div style="position:relative;">` +
|
|
|
- `<button type="button" class="btn btn-success" onclick="return fave.ActionRestoreThemeFile('template-restore-file','` + selected_file + `','Are you sure want to restore theme file?');" style="position:absolute;right:0;">Restore</button>` +
|
|
|
+ `<button type="button" class="btn btn-success" onclick="return fave.ActionRestoreThemeFile('templates-restore-file','` + selected_file + `','Are you sure want to restore theme file?');" style="position:absolute;right:0;">Restore</button>` +
|
|
|
`<select class="form-control ignore-lost-data" id="lbl_file" name="file" onchange="setTimeout(function(){$('#lbl_file').val('` + selected_file + `')},500);document.location='/cp/` + wrap.CurrModule + `/?file='+encodeURI(this.value);">` +
|
|
|
list_of_files +
|
|
|
`</select>` +
|
|
@@ -124,6 +125,49 @@ func (this *Modules) RegisterModule_Template() *Module {
|
|
|
</div>
|
|
|
</div>`
|
|
|
}
|
|
|
+ } else if wrap.CurrSubModule == "create" {
|
|
|
+ content += this.getBreadCrumbs(wrap, &[]consts.BreadCrumb{
|
|
|
+ {Name: "Add new template"},
|
|
|
+ })
|
|
|
+
|
|
|
+ content += builder.DataForm(wrap, []builder.DataFormField{
|
|
|
+ {
|
|
|
+ Kind: builder.DFKHidden,
|
|
|
+ Name: "action",
|
|
|
+ Value: "templates-create-theme-file",
|
|
|
+ },
|
|
|
+ {
|
|
|
+ Kind: builder.DFKText,
|
|
|
+ Caption: "Theme file",
|
|
|
+ Name: "file",
|
|
|
+ Value: "0",
|
|
|
+ CallBack: func(field *builder.DataFormField) string {
|
|
|
+ return `<div class="form-group n1">` +
|
|
|
+ `<div class="row">` +
|
|
|
+ `<div class="col-12">` +
|
|
|
+ `<div style="position:relative;">` +
|
|
|
+ `<input class="form-control ignore-lost-data" type="text" id="lbl_name" name="name" value="" minlength="1" maxlength="250" placeholder="New template file name without extension" autocomplete="off" required>` +
|
|
|
+ `</div>` +
|
|
|
+ `</div>` +
|
|
|
+ `</div>` +
|
|
|
+ `</div>`
|
|
|
+ },
|
|
|
+ },
|
|
|
+ {
|
|
|
+ Kind: builder.DFKText,
|
|
|
+ CallBack: func(field *builder.DataFormField) string {
|
|
|
+ return `<div class="form-group last"><div class="row"><div class="col-12"><textarea class="form-control tmpl-editor" name="content" data-emode="html" placeholder="" autocomplete="off"></textarea></div></div></div>`
|
|
|
+ },
|
|
|
+ },
|
|
|
+ {
|
|
|
+ Kind: builder.DFKSubmit,
|
|
|
+ CallBack: func(field *builder.DataFormField) string {
|
|
|
+ return `<div class="row d-lg-none"><div class="col-12"><div class="pt-3"><button type="submit" class="btn btn-primary" data-target="add-edit-button">Save</button></div></div></div>`
|
|
|
+ },
|
|
|
+ },
|
|
|
+ })
|
|
|
+
|
|
|
+ sidebar += `<button class="btn btn-primary btn-sidebar" id="add-edit-button">Add</button>`
|
|
|
} else if wrap.CurrSubModule == "restore" {
|
|
|
content += this.getBreadCrumbs(wrap, &[]consts.BreadCrumb{
|
|
|
{Name: "Restore"},
|
|
@@ -139,12 +183,12 @@ func (this *Modules) RegisterModule_Template() *Module {
|
|
|
{
|
|
|
Kind: builder.DFKSubmit,
|
|
|
CallBack: func(field *builder.DataFormField) string {
|
|
|
- return `<div class="row d-lg-none"><div class="col-12"><div class="pt-3"><button type="button" class="btn btn-danger" onclick="return fave.ActionRestoreThemeFile('template-restore-file-all','all','WARNING! Are you sure want to restore all theme files?');">Restore</button></div></div></div>`
|
|
|
+ return `<div class="row d-lg-none"><div class="col-12"><div class="pt-3"><button type="button" class="btn btn-danger" onclick="return fave.ActionRestoreThemeFile('templates-restore-file-all','all','WARNING! Are you sure want to restore all theme files?');">Restore</button></div></div></div>`
|
|
|
},
|
|
|
},
|
|
|
})
|
|
|
|
|
|
- sidebar += `<button class="btn btn-danger btn-sidebar" onclick="return fave.ActionRestoreThemeFile('template-restore-file-all','all','WARNING! Are you sure want to restore all theme files?');" id="add-edit-button">Restore</button>`
|
|
|
+ sidebar += `<button class="btn btn-danger btn-sidebar" onclick="return fave.ActionRestoreThemeFile('templates-restore-file-all','all','WARNING! Are you sure want to restore all theme files?');" id="add-edit-button">Restore</button>`
|
|
|
}
|
|
|
return this.getSidebarModules(wrap), content, sidebar
|
|
|
})
|