option for WATO attributes
User-Agent: Heirloom mailx 12.4 7/29/08
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Module: check_mk
Branch: master
Commit: af01810580ecb9d279974bcf6601c7e4e967e7ef
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=af01810580ecb9…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Fri Jul 27 14:48:37 2012 +0200
Fixed problems with new "editable" option for WATO attributes
---
web/htdocs/wato.py | 74 ++++++++++++++++++++++++++++------------------------
1 files changed, 40 insertions(+), 34 deletions(-)
diff --git a/web/htdocs/wato.py b/web/htdocs/wato.py
index 1050e3f..d8a9519 100644
--- a/web/htdocs/wato.py
+++ b/web/htdocs/wato.py
@@ -4742,6 +4742,7 @@ def configure_attributes(new, hosts, for_what, parent, myself=None,
without_attr
checkbox_name = "_change_%s" % attrname
cb = html.get_checkbox(checkbox_name)
force_entry = False
+ disabled = False
# first handle mandatory cases
if for_what == "folder" and attr.is_mandatory() \
@@ -4750,11 +4751,9 @@ def configure_attributes(new, hosts, for_what, parent, myself=None,
without_attr
and not has_inherited:
force_entry = True
active = True
- elif not new and not attr.editable():
- force_entry = True
elif for_what == "host" and attr.is_mandatory() and not
has_inherited:
- force_entry = True
- active = True
+ force_entry = True
+ active = True
elif cb != None:
active = cb # get previous state of checkbox
elif for_what == "search":
@@ -4766,13 +4765,19 @@ def configure_attributes(new, hosts, for_what, parent,
myself=None, without_attr
else: # "host"
active = attrname in host
+ if not new and not attr.editable():
+ if active:
+ force_entry = True
+ else:
+ disabled = True
+
if 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
else:
onclick = "wato_fix_visibility(); wato_toggle_attribute(this,
'%s');" % attrname
- checkbox_code = '<input type=checkbox name="%s" %s
onclick="%s">' % (
- checkbox_name, active and "CHECKED" or "",
onclick)
+ checkbox_code = '<input type=checkbox name="%s" %s %s
onclick="%s">' % (
+ checkbox_name, active and "CHECKED" or "",
disabled and "DISABLED" or "", onclick)
forms.section(attr.title(), checkbox=checkbox_code, id="attr_" +
attrname)
html.help(attr.help())
@@ -4784,18 +4789,13 @@ def configure_attributes(new, hosts, for_what, parent,
myself=None, without_attr
if not new and not attr.editable():
# In edit mode only display non editable values, don't show the
# input fields
- html.write('<div id="attr_hidden_%s"
style="display:none">')
+ html.write('<div id="attr_hidden_%s"
style="display:none">' % attrname)
attr.render_input(defvalue)
html.write('</div>')
- tdclass, content = attr.paint(defvalue, "")
- if not content:
- content = _("empty")
- html.write(content)
+ html.write('<div class="inherited"
id="attr_visible_%s">' % (attrname))
else:
- # Regular rendering
-
# Now comes the input fields and the inherited / default values
# as two DIV elements, one of which is visible at one time.
@@ -4806,33 +4806,39 @@ def configure_attributes(new, hosts, for_what, parent,
myself=None, without_attr
attr.render_input(defvalue)
html.write("</div>")
- # DIV with actual / inherited / default value
html.write('<div class="inherited"
id="attr_default_%s" style="%s">'
- % (attrname, active and "display: none" or ""))
-
- # in bulk mode we show inheritance only if *all* hosts inherit
- explanation = ""
- if for_what == "bulk":
- if num_haveit == 0:
- explanation = " (" + inherited_from + ")"
- value = inherited_value
- elif not unique:
- explanation = _("This value differs between the selected
hosts.")
- else:
- value = values[0]
+ % (attrname, active and "display: none" or ""))
- elif for_what in [ "host", "folder" ]:
+ #
+ # DIV with actual / inherited / default value
+ #
+
+ # in bulk mode we show inheritance only if *all* hosts inherit
+ explanation = ""
+ if for_what == "bulk":
+ if num_haveit == 0:
+ explanation = " (" + inherited_from + ")"
+ value = inherited_value
+ elif not unique:
+ explanation = _("This value differs between the selected
hosts.")
+ else:
+ value = values[0]
+
+ elif for_what in [ "host", "folder" ]:
+ if not new and not attr.editable() and active:
+ value = values[0]
+ else:
explanation = " (" + inherited_from + ")"
value = inherited_value
- if for_what != "search" and not (for_what == "bulk"
and not unique):
- tdclass, content = attr.paint(value, "")
- if not content:
- content = _("empty")
- html.write("<b>" + content + "</b>")
+ if for_what != "search" and not (for_what == "bulk" and
not unique):
+ tdclass, content = attr.paint(value, "")
+ if not content:
+ content = _("empty")
+ html.write("<b>" + content + "</b>")
- html.write(explanation)
- html.write("</div>")
+ html.write(explanation)
+ html.write("</div>")
if len(topics) > 1: