Module: check_mk
Branch: master
Commit: 14dea711a14fd97c6be58517953f5e2cef5c54c4
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=14dea711a14fd9…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Tue Sep 18 17:00:50 2012 +0200
ValueSpec Foldable: allow dynamic title function
---
web/htdocs/valuespec.py | 7 ++++++-
1 files changed, 6 insertions(+), 1 deletions(-)
diff --git a/web/htdocs/valuespec.py b/web/htdocs/valuespec.py
index 650f3ee..78ef4b4 100644
--- a/web/htdocs/valuespec.py
+++ b/web/htdocs/valuespec.py
@@ -1953,10 +1953,15 @@ class Foldable(ValueSpec):
ValueSpec.__init__(self, **kwargs)
self._valuespec = valuespec
self._open = kwargs.get("open", False)
+ self._title_function = kwargs.get("title_function", None)
def render_input(self, varprefix, value):
+ if self._title_function:
+ title = self._title_function(value)
+ else:
+ title = self._valuespec.title()
html.begin_foldable_container("valuespec_foldable", varprefix,
self._open,
- self._valuespec.title(), False)
+ title, False)
html.help(self._valuespec.help())
self._valuespec.render_input(varprefix, value)
html.end_foldable_container()