Module: check_mk
Branch: master
Commit: 082fcff265bd0ce81da87d2734d806d0663f0842
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=082fcff265bd0c…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Fri May 25 10:31:42 2012 +0200
FIX: Fixed handling of validation errors in cascading dropdown fields
---
ChangeLog | 1 +
web/htdocs/valuespec.py | 19 ++++++++++++-------
2 files changed, 13 insertions(+), 7 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 55fba84..b726bad 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -18,6 +18,7 @@
is valid on the replication slaves
* FIX: implement locking in order to prevent data corruption on
concurrent changes
+ * FIX: Fixed handling of validation errors in cascading dropdown fields
Multisite:
* New display type 'boxes-omit-root' for BI views
diff --git a/web/htdocs/valuespec.py b/web/htdocs/valuespec.py
index 3898041..2d90ff5 100644
--- a/web/htdocs/valuespec.py
+++ b/web/htdocs/valuespec.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+
# -*- encoding: utf-8; py-indent-offset: 4 -*-
# +------------------------------------------------------------------+
# | ____ _ _ __ __ _ __ |
@@ -812,25 +812,30 @@ class CascadingDropdown(ValueSpec):
def_val = str(nr)
vp = varprefix + "_sel"
- onchange="valuespec_cascading_change(this, '%s', %d);" %
(varprefix, len(self._choices))
+ onchange="valuespec_cascading_change(this, '%s', %d);" %
(varprefix, len(self._choices))
if self._sorted:
html.select(vp, options, def_val, onchange=onchange)
else:
html.sorted_select(vp, options, def_val, onchange=onchange)
+ cur_val = html.var(vp)
+
html.write(self._html_separator)
for nr, (val, title, vs) in enumerate(self._choices):
if vs:
vp = varprefix + "_%d" % nr
- if value == val or (
- type(value) == tuple and value[0] == val):
- def_val = value[1]
+ if value == val \
+ or (type(value) == tuple and value[0] == val):
+ def_val_2 = value[1]
+ disp = ""
+ elif cur_val == str(nr):
+ def_val_2 = vs.default_value()
disp = ""
else:
- def_val = vs.default_value()
+ def_val_2 = vs.default_value()
disp = "none"
html.write('<span id="%s_%s_sub" style="display:
%s">' % (varprefix, nr, disp))
- vs.render_input(vp, def_val)
+ vs.render_input(vp, def_val_2)
html.write('</span>')
def value_to_text(self, value):