Browse Source

Prevent data lost in template editor

Vova Tkach 5 years ago
parent
commit
01c4db20e4
3 changed files with 8 additions and 1 deletions
  1. 7 0
      assets/cp.scripts.js
  2. 0 0
      assets/cp.scripts.js.go
  3. 1 1
      modules/module_template.go

+ 7 - 0
assets/cp.scripts.js

@@ -3639,6 +3639,7 @@
 		};
 
 		function MakeTextAreasTmplEditor() {
+			var IgnoreDataLost = true;
 			$('textarea.tmpl-editor').each(function() {
 				var targetTextArea = $(this)[0];
 				var targetFileExt = $(this).data('emode');
@@ -3655,8 +3656,14 @@
 					mode: targetEditorMode,
 				}).on('change', function(editor){
 					targetTextArea.value = editor.getValue();
+					if(!IgnoreDataLost) {
+						if(!FormDataWasChanged) {
+							FormDataWasChanged = true;
+						}
+					}
 				});
 			});
+			IgnoreDataLost = false;
 		};
 
 		function MakeTextAreasNotReactOnTab() {

File diff suppressed because it is too large
+ 0 - 0
assets/cp.scripts.js.go


+ 1 - 1
modules/module_template.go

@@ -107,7 +107,7 @@ func (this *Modules) RegisterModule_Template() *Module {
 					{
 						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" id="lbl_content" name="content" data-emode="` + fext + `" placeholder="" autocomplete="off">` + html.EscapeString(string(fcont)) + `</textarea></div></div></div>`
+							return `<div class="form-group last"><div class="row"><div class="col-12"><textarea class="form-control tmpl-editor" name="content" data-emode="` + fext + `" placeholder="" autocomplete="off">` + html.EscapeString(string(fcont)) + `</textarea></div></div></div>`
 						},
 					},
 					{

Some files were not shown because too many files changed in this diff