Module: check_mk
Branch: master
Commit: 3456ed621505929a61feea1d971017da164129ea
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=3456ed62150592…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Tue May 3 07:43:16 2016 +0200
3458 FIX Bulk edit: Fixed broken unchecking of attributes after complain
---
.werks/3458 | 10 ++++++++++
ChangeLog | 1 +
web/htdocs/htmllib.py | 48 +++++++++++++++++++++++++++++++++---------------
web/htdocs/wato.py | 9 +++++----
4 files changed, 49 insertions(+), 19 deletions(-)
diff --git a/.werks/3458 b/.werks/3458
new file mode 100644
index 0000000..7132521
--- /dev/null
+++ b/.werks/3458
@@ -0,0 +1,10 @@
+Title: Bulk edit: Fixed broken unchecking of attributes after complain
+Level: 1
+Component: wato
+Class: fix
+Compatible: compat
+State: unknown
+Version: 1.2.9i1
+Date: 1462254179
+
+
diff --git a/ChangeLog b/ChangeLog
index b024b9d..aaaf86c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -337,6 +337,7 @@
* 3450 FIX: Site properties: It was not possible to switch a site back to "local
site" connection
* 3451 FIX: Fixed exception in host list when no local site configured
* 3457 FIX: Bulk edit: Prevent browser auto completion of stored credentials
+ * 3458 FIX: Bulk edit: Fixed broken unchecking of attributes after complain
Notifications:
* 3263 Notifications: allow users to restrict by their contact groups...
diff --git a/web/htdocs/htmllib.py b/web/htdocs/htmllib.py
index 40aaf60..7125e4a 100644
--- a/web/htdocs/htmllib.py
+++ b/web/htdocs/htmllib.py
@@ -335,13 +335,21 @@ class html(GUITester):
self.write('<br>'.join(self.user_errors.values()))
self.write('</div>\n')
- def hidden_field(self, var, value, id = None, add_var = False):
- if value != None:
- id = id and ' id="%s"' % self.attrencode(id) or ''
- self.write("<input type=\"hidden\" name=\"%s\"
value=\"%s\"%s />" %
- (self.attrencode(var), self.attrencode(value), id))
- if add_var:
- self.add_form_var(var)
+
+ def hidden_field(self, *args, **kwargs):
+ self.write(self.render_hidden_field(*args, **kwargs))
+
+
+ def render_hidden_field(self, var, value, id=None, add_var=False):
+ if value == None:
+ return ""
+
+ if add_var:
+ self.add_form_var(var)
+
+ id = id and ' id="%s"' % self.attrencode(id) or ''
+ return "<input type=\"hidden\" name=\"%s\"
value=\"%s\"%s />" % \
+ (self.attrencode(var), self.attrencode(value), id)
# Beware: call this method just before end_form(). It will
# add all current non-underscored HTML variables as hiddedn
@@ -737,14 +745,21 @@ class html(GUITester):
def end_checkbox_group(self):
self.end_radio_group()
- def checkbox(self, varname, deflt=False, cssclass = '', onclick = None,
label=None, id=None, add_attr = None):
+
+ def checkbox(self, *args, **kwargs):
+ self.write(self.render_checkbox(*args, **kwargs))
+
+
+ def render_checkbox(self, varname, deflt=False, cssclass = '', onclick =
None, label=None,
+ id=None, add_attr = None):
if add_attr == None:
add_attr = [] # do not use [] as default element, it will be a global
variable!
+ code = ""
error = self.user_errors.get(varname)
if error:
- self.write("<x class=inputerror>")
+ code += "<x class=inputerror>"
- self.write("<span class=checkbox>")
+ code += "<span class=checkbox>"
# Problem with checkboxes: The browser will add the variable
# only to the URL if the box is checked. So in order to detect
# wether we should add the default value, we need to detect
@@ -765,14 +780,17 @@ class html(GUITester):
add_attr_code = ''
if add_attr:
add_attr_code = ' ' + ' '.join(add_attr)
- self.write("<input type=checkbox
name=\"%s\"%s%s%s%s>\n" %
- (varname, checked, cssclass, onclick_code, add_attr_code))
+ code += "<input type=checkbox name=\"%s\"%s%s%s%s>\n" %
\
+ (varname, checked, cssclass, onclick_code, add_attr_code)
self.form_vars.append(varname)
if label:
- self.write('<label for="%s">%s</label>\n' %
(id, label))
- self.write("</span>")
+ code += '<label for="%s">%s</label>\n' % (id,
label)
+ code += "</span>"
if error:
- self.write("</x>")
+ code += "</x>"
+
+ return code
+
# Check if the current form is currently filled in (i.e. we display
# the form a second time while showing value typed in at the first
diff --git a/web/htdocs/wato.py b/web/htdocs/wato.py
index 653c022..0c15682 100644
--- a/web/htdocs/wato.py
+++ b/web/htdocs/wato.py
@@ -15805,12 +15805,13 @@ def configure_attributes(new, hosts, for_what, parent,
myself=None, without_attr
if (for_what == "host" and parent.locked_hosts()) or (for_what ==
"folder" and myself and myself.locked()):
checkbox_code = None
elif force_entry:
- checkbox_code = '<input type=checkbox name="ignored_%s"
CHECKED DISABLED>' % checkbox_name
- checkbox_code += '<input type=hidden name="%s"
value="on">' % checkbox_name
+ checkbox_code = html.render_checkbox("ignored_" +
checkbox_name, add_attr=["disabled"])
+ checkbox_code += html.render_hidden_field(checkbox_name, "on")
else:
+ add_attr = disabled and ["disabled"] or []
onclick = "wato_fix_visibility(); wato_toggle_attribute(this,
'%s');" % attrname
- checkbox_code = '<input type=checkbox name="%s" %s %s
onclick="%s">' % (
- checkbox_name, active and "CHECKED" or "",
disabled and "DISABLED" or "", onclick)
+ checkbox_code = html.render_checkbox(checkbox_name, active,
+ onclick=onclick, add_attr=add_attr)
forms.section(_u(attr.title()), checkbox=checkbox_code, id="attr_"
+ attrname)
html.help(attr.help())