Module: check_mk
Branch: master
Commit: 43612798b708abb968eec4bc05eb22b9f9e22661
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=43612798b708ab…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Thu Nov 21 11:08:15 2013 +0100
Added optional "toggle all" link to ListChoices
---
web/htdocs/valuespec.py | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/web/htdocs/valuespec.py b/web/htdocs/valuespec.py
index 5435948..1e0458d 100644
--- a/web/htdocs/valuespec.py
+++ b/web/htdocs/valuespec.py
@@ -1206,6 +1206,7 @@ class ListChoice(ValueSpec):
self._loaded_at = None
self._render_function = kwargs.get("render_function",
lambda id, val: val)
+ self._toggle_all = kwargs.get("toggle_all", False)
# In case of overloaded functions with dynamic elements
def load_elements(self):
@@ -1225,7 +1226,10 @@ class ListChoice(ValueSpec):
def render_input(self, varprefix, value):
self.load_elements()
- html.write("<table class=listchoice>")
+ if self._toggle_all:
+ html.write("<a
href=\"javascript:vs_list_choice_toggle_all('%s')\">%s</a>"
%
+ (varprefix, _("Check / Uncheck all")))
+ html.write("<table id=\"%s_tbl\" class=listchoice>" %
varprefix)
for nr, (key, title) in enumerate(self._elements):
if nr % self._columns == 0:
if nr > 0:
@@ -1264,7 +1268,6 @@ class ListChoice(ValueSpec):
raise MKUserError(varprefix, _('You have to select at least one
element.'))
ValueSpec.custom_validate(self, value, varprefix)
-
# A alternative way of editing list choices
class MultiSelect(ListChoice):
def __init__(self, **kwargs):