Module: check_mk
Branch: master
Commit: 34948e0a6771713f19d9cb1070b0423353547d5f
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=34948e0a677171…
Author: Andreas Boesl <ab(a)mathias-kettner.de>
Date: Mon Aug 26 17:51:15 2013 +0200
new alternative vs option: show_alternative_title
---
web/htdocs/valuespec.py | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/web/htdocs/valuespec.py b/web/htdocs/valuespec.py
index 1a02992..25886fa 100644
--- a/web/htdocs/valuespec.py
+++ b/web/htdocs/valuespec.py
@@ -1849,6 +1849,7 @@ class Alternative(ValueSpec):
self._elements = kwargs["elements"]
self._match = kwargs.get("match") # custom match function
self._style = kwargs.get("style", "radio") # alternative:
"dropdown"
+ self._show_alternative_title = kwargs.get("show_alternative_title")
# Return the alternative (i.e. valuespec)
# that matches the datatype of a given value. We assume
@@ -1933,7 +1934,10 @@ class Alternative(ValueSpec):
def value_to_text(self, value):
vs = self.matching_alternative(value)
if vs:
- return vs.value_to_text(value)
+ output = ""
+ if self._show_alternative_title and vs.title():
+ output = "%s<br>" % vs.title()
+ return output + vs.value_to_text(value)
else:
return _("invalid:") + " " + str(value)