Module: check_mk
Branch: master
Commit: d7756dfcf4297e835f4b1348805a0bbfb21ec4a7
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=d7756dfcf4297e…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Tue Oct 7 18:36:52 2014 +0200
Better styling of context/filter editor
---
web/htdocs/valuespec.py | 35 +++++++++++++++++++++++++++++------
web/htdocs/views.css | 24 ++++++++++++++++++++++++
web/htdocs/visuals.py | 2 +-
3 files changed, 54 insertions(+), 7 deletions(-)
diff --git a/web/htdocs/valuespec.py b/web/htdocs/valuespec.py
index cd6d6fb..95eea18 100644
--- a/web/htdocs/valuespec.py
+++ b/web/htdocs/valuespec.py
@@ -908,6 +908,7 @@ class ListOfMultiple(ValueSpec):
self._choice_dict = dict(choices)
self._size = kwargs.get("size")
self._add_label = kwargs.get("add_label", _("Add element"))
+ self._delete_style = kwargs.get("delete_style", "default") #
or "filter"
def del_button(self, varprefix, ident):
js = "vs_listofmultiple_del('%s', '%s')" % (varprefix,
ident)
@@ -921,6 +922,12 @@ class ListOfMultiple(ValueSpec):
# here is *not* an option since this might not work in case of
# a wrong user input.
+ # Special styling for filters
+ if self._delete_style == "filter":
+ extra_css=" filter"
+ else:
+ extra_css=""
+
# In the 'complain' phase, where the user already saved the
# form but the validation failed, we must not display the
# original 'value' but take the value from the HTML variables.
@@ -933,15 +940,29 @@ class ListOfMultiple(ValueSpec):
id = '%s_active' % varprefix, add_var = True)
# Actual table of currently existing entries
- html.write('<table class="valuespec_listof"
id="%s_table">' % varprefix)
+ html.write('<table class="valuespec_listof%s"
id="%s_table">' % (extra_css, varprefix))
+
+ def render_content():
+ html.write('<td class="vlof_content%s">' %
extra_css)
+ vs.render_input(prefix, value.get(ident))
+ html.write("</td>")
+
+ def render_del():
+ html.write('<td class="vlof_buttons%s">' %
extra_css)
+ self.del_button(varprefix, ident)
+ html.write('</td>')
+
for ident, vs in self._choices:
cls = ident not in value and 'unused' or ''
prefix = varprefix + '_' + ident
- html.write('<tr id="%s_row" class="%s"><td
class=vlof_buttons>' % (prefix, cls))
- self.del_button(varprefix, ident)
- html.write("</td><td class=vlof_content>")
- vs.render_input(prefix, value.get(ident))
- html.write("</td></tr>")
+ html.write('<tr id="%s_row" class="%s">' %
(prefix, cls))
+ if self._delete_style == "filter":
+ render_content()
+ render_del()
+ else:
+ render_del()
+ render_content()
+ html.write("</tr>")
html.write("</table>")
html.write("<br>")
@@ -949,6 +970,8 @@ class ListOfMultiple(ValueSpec):
attrs = {}
if self._size != None:
attrs["style"] = "width: %dex" % self._size
+ if self._delete_style == "filter":
+ attrs["class"] = "vlof_filter"
html.select(varprefix + '_choice', choosable, attrs=attrs)
html.javascript('vs_listofmultiple_init(\'%s\');' % varprefix)
html.jsbutton(varprefix + '_add', self._add_label,
"vs_listofmultiple_add('%s')" % varprefix)
diff --git a/web/htdocs/views.css b/web/htdocs/views.css
index d3d0a67..f238ccd 100644
--- a/web/htdocs/views.css
+++ b/web/htdocs/views.css
@@ -124,6 +124,30 @@ div.floatfilter .content .filtertime select {
width: 136px;
}
+/* Improving styling of floatfilters that are contained in a ListOf() */
+table.valuespec_listof.filter {
+ width: 300px;
+ border-spacing: 0px;
+}
+select.vlof_filter {
+ width: 312px;
+}
+table.valuespec_listof td.vlof_content.filter {
+ width: 1px;
+ border-style: none;
+}
+table.valuespec_listof td.vlof_buttons.filter {
+ width: 1px;
+ border-style: none;
+}
+table.valuespec_listof td.vlof_buttons.filter img {
+ position: relative;
+ top: -18px;
+ left: -28px;
+ width: 16px;
+ height: 16px;
+}
+
table.filtertime td {
vertical-align: middle;
}
diff --git a/web/htdocs/visuals.py b/web/htdocs/visuals.py
index fed8282..693c527 100644
--- a/web/htdocs/visuals.py
+++ b/web/htdocs/visuals.py
@@ -943,7 +943,7 @@ class VisualFilterList(ListOfMultiple):
kwargs.setdefault('title', _('Filters'))
kwargs.setdefault('add_label', _('Add filter'))
- kwargs.setdefault("size", 50)
+ kwargs["delete_style"] = "filter"
ListOfMultiple.__init__(self, fspecs, **kwargs)