fixes sorting of nodes in BI rule edit dialog)
Message-ID: <589b2f07.V00tONXwar6Jczt5%lm(a)mathias-kettner.de>
User-Agent: Heirloom mailx 12.5 6/20/10
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Module: check_mk
Branch: master
Commit: 5049e79150bb67c9f5266d747fc1d9344863867d
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=5049e79150bb67…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Wed Feb 8 15:21:00 2017 +0100
Improved fragile (and recently broke) list of arrow rendering (fixes sorting of nodes in
BI rule edit dialog)
Change-Id: I97996209fea12c4e32212842292eaf8ffe3cf9fc
---
web/htdocs/htmllib.py | 8 ++++----
web/htdocs/js/checkmk.js | 17 +++++++++++------
web/htdocs/valuespec.py | 3 ++-
3 files changed, 17 insertions(+), 11 deletions(-)
diff --git a/web/htdocs/htmllib.py b/web/htdocs/htmllib.py
index a059dc4..9ffdc8a 100644
--- a/web/htdocs/htmllib.py
+++ b/web/htdocs/htmllib.py
@@ -1896,18 +1896,18 @@ class html(DeprecationWrapper, RequestHandler):
self.hidden_field(var, self.get_unicode_input(var))
- def hidden_field(self, var, value, id=None, add_var=False):
- self.write_html(self.render_hidden_field(var=var, value=value, id=id,
add_var=add_var))
+ def hidden_field(self, var, value, id=None, add_var=False, class_=None):
+ self.write_html(self.render_hidden_field(var=var, value=value, id=id,
add_var=add_var, class_=class_))
- def render_hidden_field(self, var, value, id=None, add_var=False):
+ def render_hidden_field(self, var, value, id=None, add_var=False, class_=None):
# TODO: Refactor
id_ = id
if value == None:
return ""
if add_var:
self.add_form_var(var)
- return self.render_input(name=var, type_="hidden", id_=id_, value =
value)
+ return self.render_input(name=var, type_="hidden", id_=id_,
value=value, class_=class_)
def button(self, varname, title, cssclass = None, style=None, help=None):
diff --git a/web/htdocs/js/checkmk.js b/web/htdocs/js/checkmk.js
index 1297202..b037639 100644
--- a/web/htdocs/js/checkmk.js
+++ b/web/htdocs/js/checkmk.js
@@ -2080,14 +2080,19 @@ function valuespec_listof_fixarrows(oTbody) {
for(var i = 0, row; row = oTbody.rows[i]; i++) {
if(row.cells.length == 0)
continue;
+
var oTd = row.cells[0]; /* TD with buttons */
- if(row.cells[0].childNodes.length == 0)
+ if(oTd.childNodes.length == 0)
continue;
- var oIndex = oTd.childNodes[0];
+
+ var oIndex = oTd.getElementsByClassName("index")[0];
oIndex.value = "" + (parseInt(i) + 1);
+
if (oTd.childNodes.length > 4) { /* movable */
- var oUpTrans = oTd.childNodes[2];
- var oUp = oTd.childNodes[3];
+ var buttons = oTd.getElementsByClassName("iconbutton");
+
+ var oUpTrans = buttons[1];
+ var oUp = buttons[2];
if (i == 0) {
oUpTrans.style.display = "";
oUp.style.display = "none";
@@ -2096,8 +2101,8 @@ function valuespec_listof_fixarrows(oTbody) {
oUpTrans.style.display = "none";
oUp.style.display = "";
}
- var oDownTrans = oTd.childNodes[4];
- var oDown = oTd.childNodes[5];
+ var oDownTrans = buttons[3];
+ var oDown = buttons[4];
if (i >= oTbody.rows.length - 1) {
oDownTrans.style.display = "";
oDown.style.display = "none";
diff --git a/web/htdocs/valuespec.py b/web/htdocs/valuespec.py
index 4fb5517..b22f70f 100644
--- a/web/htdocs/valuespec.py
+++ b/web/htdocs/valuespec.py
@@ -1280,7 +1280,8 @@ class ListOf(ValueSpec):
for nr, v in enumerate(value):
html.open_tr()
html.open_td(class_="vlof_buttons")
- html.hidden_field(varprefix + "_indexof_%d" % (nr+1), "",
add_var=True) # reconstruct order after moving stuff
+ html.hidden_field(varprefix + "_indexof_%d" % (nr+1),
"",
+ add_var=True, class_="index") # reconstruct order
after moving stuff
self.del_button(varprefix, nr+1)
if self._movable:
self.move_button(varprefix, nr+1, "up") # visibility fixed by
javascript