Module: check_mk
Branch: master
Commit: 784031475a86b36a5ff44f0614891e2a6f32e70a
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=784031475a86b3…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Fri Aug 24 18:11:12 2018 +0200
html.dropdown() and CascadingDropdown now support labels
CMK-856
Change-Id: Ie723b109cff83167932502049379ea2251ac5d00
---
cmk/gui/htmllib.py | 3 +++
cmk/gui/valuespec.py | 3 ++-
2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/cmk/gui/htmllib.py b/cmk/gui/htmllib.py
index f07702f..a3c585f 100644
--- a/cmk/gui/htmllib.py
+++ b/cmk/gui/htmllib.py
@@ -2417,6 +2417,9 @@ class html(HTMLGenerator):
attrs["disabled"] = "disabled"
self.hidden_field(varname, current, add_var=False)
+ if attrs.get("label"):
+ self.label(attrs["label"], for_=varname)
+
self.open_select(name=varname, id_=varname, **attrs)
for value, text in chs:
# if both the default in choices and current was '' then selected
depended on the order in choices
diff --git a/cmk/gui/valuespec.py b/cmk/gui/valuespec.py
index d4a4c7d..4402d90 100644
--- a/cmk/gui/valuespec.py
+++ b/cmk/gui/valuespec.py
@@ -1767,6 +1767,7 @@ class CascadingDropdown(ValueSpec):
else:
self._choices = kwargs["choices"] # function, store for later
+ self._label = kwargs.get("label")
self._separator = kwargs.get("separator", ", ")
self._sorted = kwargs.get("sorted", True)
self._orientation = kwargs.get("orientation", "vertical") #
or horizontal
@@ -1851,7 +1852,7 @@ class CascadingDropdown(ValueSpec):
vp = varprefix + "_sel"
onchange="valuespec_cascading_change(this, '%s', %d);" %
(varprefix, len(choices))
- html.dropdown(vp, options, deflt=def_val, onchange=onchange,
sorted=self._sorted)
+ html.dropdown(vp, options, deflt=def_val, onchange=onchange, sorted=self._sorted,
label=self._label)
# make sure, that the visibility is done correctly, in both
# cases: