Module: check_mk
Branch: master
Commit: aaeb82959ae74a17bb093817044dc3603890f3dc
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=aaeb82959ae74a…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Tue Oct 28 15:27:44 2014 +0100
Another extension of duallist choice
---
web/htdocs/js/checkmk.js | 22 ++++++++++++++++++++++
web/htdocs/valuespec.py | 5 +++++
web/htdocs/views.css | 8 ++++++++
web/plugins/visuals/filters.py | 2 +-
4 files changed, 36 insertions(+), 1 deletion(-)
diff --git a/web/htdocs/js/checkmk.js b/web/htdocs/js/checkmk.js
index 56e9e16..a5e2359 100644
--- a/web/htdocs/js/checkmk.js
+++ b/web/htdocs/js/checkmk.js
@@ -1704,6 +1704,28 @@ function vs_passwordspec_randomize(img) {
oInput.value = password;
}
+function vs_duallist_enlarge(field_suffix, varprefix) {
+ var field = document.getElementById(varprefix + '_' + field_suffix);
+ if (field.id != varprefix + '_selected') {
+ // The other field is the one without "_unselected" suffix
+ var other_id = varprefix + '_selected';
+ var positive = true;
+ } else {
+ // The other field is the one with "_unselected" suffix
+ var other_id = varprefix + '_unselected';
+ var positive = false;
+ }
+
+ var other_field = document.getElementById(other_id);
+ if (!other_field)
+ return;
+
+ remove_class(other_field, 'large');
+ add_class(other_field, 'small');
+ remove_class(field, 'small');
+ add_class(field, 'large');
+}
+
function vs_duallist_switch(field_suffix, varprefix, keeporder) {
var field = document.getElementById(varprefix + '_' + field_suffix);
if (field.id != varprefix + '_selected') {
diff --git a/web/htdocs/valuespec.py b/web/htdocs/valuespec.py
index 13d1155..0203330 100644
--- a/web/htdocs/valuespec.py
+++ b/web/htdocs/valuespec.py
@@ -1540,6 +1540,7 @@ class DualListChoice(ListChoice):
self._autoheight = kwargs.get("autoheight", True)
self._custom_order = kwargs.get("custom_order", False)
self._instant_add = kwargs.get("instant_add", False)
+ self._enlarge_active = kwargs.get("enlarge_active", False)
def render_input(self, varprefix, value):
self.load_elements()
@@ -1585,6 +1586,10 @@ class DualListChoice(ListChoice):
onchange_unselected = ''
onchange_selected = ''
+ if self._enlarge_active:
+ onchange_selected += ';vs_duallist_enlarge(\'selected\',
\'%s\')' % varprefix
+ onchange_unselected += ';vs_duallist_enlarge(\'unselected\',
\'%s\')' % varprefix
+
html.sorted_select(varprefix + '_unselected', unselected,
attrs = {'size': 5, 'style': self._autoheight
and 'height:auto' or ''},
onchange = onchange_unselected)
diff --git a/web/htdocs/views.css b/web/htdocs/views.css
index f0f1074..ab0406d 100644
--- a/web/htdocs/views.css
+++ b/web/htdocs/views.css
@@ -120,6 +120,14 @@ div.floatfilter .content .multigroup select {
height: 66px;
}
+div.floatfilter .content .multigroup select.large {
+ width: 228px;
+}
+
+div.floatfilter .content .multigroup select.small {
+ width: 68px;
+}
+
div.floatfilter .content .filtertime select {
width: 136px;
}
diff --git a/web/plugins/visuals/filters.py b/web/plugins/visuals/filters.py
index a006712..ee505fa 100644
--- a/web/plugins/visuals/filters.py
+++ b/web/plugins/visuals/filters.py
@@ -155,7 +155,7 @@ class FilterMultigroup(Filter):
return True
def valuespec(self):
- return DualListChoice(choices = all_groups(self.what), autoheight=False)
+ return DualListChoice(choices = all_groups(self.what), autoheight=False,
enlarge_active=True)
def selection(self):
current = html.var(self.htmlvar, "").strip().split("|")