commit 6c9bfdc: [WebUI] Fix config editor read-only mode attribute

moisseev moiseev at mezonplus.ru
Tue Oct 27 17:14:07 UTC 2020


Author: moisseev
Date: 2020-10-27 18:18:00 +0300
URL: https://github.com/rspamd/rspamd/commit/6c9bfdc2c2e4ab952d7a48764a15c89c9a186513 (refs/pull/3532/head)

[WebUI] Fix config editor read-only mode attribute

---
 interface/js/app/config.js | 29 ++++++++++++++---------------
 1 file changed, 14 insertions(+), 15 deletions(-)

diff --git a/interface/js/app/config.js b/interface/js/app/config.js
index 101935c35..f6a54d65a 100644
--- a/interface/js/app/config.js
+++ b/interface/js/app/config.js
@@ -152,11 +152,13 @@ define(["jquery", "codejar", "linenumbers", "prism"],
                     codejar: true,
                     elt: "div",
                     class: "editor language-clike",
+                    readonly_attr: {contenteditable: false},
                 }
                 // Fallback to textarea if the browser does not support ES6
                 : {
                     elt: "textarea",
                     class: "form-control map-textarea",
+                    readonly_attr: {readonly: true},
                 };
 
             // Modal form for maps
@@ -168,11 +170,20 @@ define(["jquery", "codejar", "linenumbers", "prism"],
                         Map: item.map
                     },
                     success: function (data) {
-                        var readonly = "";
+                        $("<" + editor.elt + ' id="editor" class="' + editor.class + '" data-id="' + item.map + '">' +
+                            rspamd.escapeHTML(data[0].data) +
+                            "</" + editor.elt + ">").appendTo("#modalBody");
+
+                        if (editor.codejar) {
+                            jar = new CodeJar(
+                                document.querySelector("#editor"),
+                                withLineNumbers(Prism.highlightElement)
+                            );
+                        }
+
                         var icon = "fa-edit";
-                        var text = rspamd.escapeHTML(data[0].data);
                         if (item.editable === false || rspamd.read_only) {
-                            readonly = " readonly";
+                            $("#editor").attr(editor.readonly_attr);
                             icon = "fa-eye";
                             $("#modalSaveGroup").hide();
                         } else {
@@ -181,18 +192,6 @@ define(["jquery", "codejar", "linenumbers", "prism"],
                         $("#modalDialog .modal-header").find("[data-fa-i2svg]").addClass(icon);
                         $("#modalTitle").html(item.uri);
 
-                        $("<" + editor.elt + ' id="editor" class="' + editor.class + '"' + readonly +
-                            ' data-id="' + item.map + '">' +
-                            text +
-                            "</" + editor.elt + ">").appendTo("#modalBody");
-
-                        if (editor.codejar) {
-                            jar = new CodeJar(
-                                document.querySelector("#editor"),
-                                withLineNumbers(Prism.highlightElement)
-                            );
-                        }
-
                         $("#modalDialog").modal("show");
                     },
                     errorMessage: "Cannot receive maps data",


More information about the Commits mailing list