Module: check_mk
Branch: master
Commit: bdf6fbc3373095ee9bbe3f8d9d6f71730311320d
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=bdf6fbc3373095…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Mon Nov 27 14:07:44 2017 +0100
5545 FIX Editing rules: Fixed adding date+user to rule comments
When editing a rule in WATO, there is the comment field available, which can e.g.
be used to write down information about the history of this rule. The icon on
the right of the text area is meant to add a new history entry to the beginning
of the comment. The way this text was added to existing comments was not really
working as intended.
It has now been changed to add a new line to the beginning, setting the cursor
on this field and position it at the end of the just added line.
Change-Id: Ic992f023b87be39512cc1afce155cc9874bad209
---
.werks/5545 | 18 ++++++++++++++++++
web/htdocs/js/checkmk.js | 20 ++++++++++++--------
web/htdocs/wato.py | 2 +-
3 files changed, 31 insertions(+), 9 deletions(-)
diff --git a/.werks/5545 b/.werks/5545
new file mode 100644
index 0000000..0c09142
--- /dev/null
+++ b/.werks/5545
@@ -0,0 +1,18 @@
+Title: Editing rules: Fixed adding date+user to rule comments
+Level: 1
+Component: wato
+Class: fix
+Compatible: compat
+Edition: cre
+State: unknown
+Version: 1.5.0i2
+Date: 1511787872
+
+When editing a rule in WATO, there is the comment field available, which can e.g.
+be used to write down information about the history of this rule. The icon on
+the right of the text area is meant to add a new history entry to the beginning
+of the comment. The way this text was added to existing comments was not really
+working as intended.
+
+It has now been changed to add a new line to the beginning, setting the cursor
+on this field and position it at the end of the just added line.
diff --git a/web/htdocs/js/checkmk.js b/web/htdocs/js/checkmk.js
index 76e6617..64b5b8c 100644
--- a/web/htdocs/js/checkmk.js
+++ b/web/htdocs/js/checkmk.js
@@ -2267,14 +2267,18 @@ function vs_list_choice_toggle_all(varprefix) {
}
}
-function vs_textascii_button(img, text, how) {
- var oInput = img.previousElementSibling;
- while (oInput.tagName == "A")
- oInput = oInput.previousElementSibling;
- if (oInput.tagName != "INPUT" && oInput.tagName !=
"TEXTAREA")
- oInput = oInput.children[0]; // complain mode
- oInput.value = text + oInput.value; // TODO: how
- oInput.focus();
+function vs_rule_comment_prefix_date_and_user(img, text) {
+ var container = img.parentNode.parentNode;
+ var textarea = container.getElementsByTagName("textarea")[0];
+
+ if (!textarea) {
+ console.log("Failed to find textarea object");
+ return;
+ }
+
+ textarea.value = text + "\n" + textarea.value;
+ textarea.focus();
+ textarea.setSelectionRange(text.length, text.length);
}
diff --git a/web/htdocs/wato.py b/web/htdocs/wato.py
index 4628f3a..3a9cc60 100644
--- a/web/htdocs/wato.py
+++ b/web/htdocs/wato.py
@@ -17157,7 +17157,7 @@ class RuleComment(TextAreaUnicode):
html.icon_button(None,
help=_("Prefix date and your name to the comment"),
icon="insertdate",
- onclick="vs_textascii_button(this, '%s',
'prefix');" % date_and_user
+ onclick="vs_rule_comment_prefix_date_and_user(this, '%s');"
% date_and_user
)
html.close_div()