Module: check_mk
Branch: master
Commit: eaa72595d563e55ea95678b1aaa388cf44d29d90
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=eaa72595d563e5…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Tue Feb 10 15:31:34 2015 +0100
Started rewrite of icon selector
---
web/htdocs/valuespec.py | 21 ++++++++++++---------
web/htdocs/views.py | 18 ++++++++++++++++++
web/plugins/icons/builtin.py | 19 +++++++++++++++++++
web/plugins/pages/shipped.py | 3 +++
web/plugins/views/painters.py | 6 +++++-
5 files changed, 57 insertions(+), 10 deletions(-)
diff --git a/web/htdocs/valuespec.py b/web/htdocs/valuespec.py
index ba7e31e..03373a9 100644
--- a/web/htdocs/valuespec.py
+++ b/web/htdocs/valuespec.py
@@ -3241,14 +3241,19 @@ class IconSelector(ValueSpec):
if not value:
value = self._empty_img
- html.write('<div class="popup_container">')
html.hidden_field(varprefix + "_value", value or '', varprefix
+ "_value", add_var = True)
- self.render_icon(value, 'toggle_popup(event, \'%s\')' %
varprefix,
- _('Choose another Icon'), id = varprefix +
'_img')
- if not value:
- html.write('<a href="javascript:void(0)"
onclick="toggle_popup(event, \'%s\')">%s</a>' %
- (varprefix, _('Select an Icon')))
- html.write('<div id="%s_popup" class="popup"
style="display:none">' % varprefix)
+
+ html.begin_popup_trigger('icon_selector',
+ params=html.urlencode_vars([('value', value),
+ ('varprefix', varprefix),
+ ('allow_empty', self._allow_empty and
'1' or '0')]))
+ if value:
+ self.render_icon(value, '', _('Choose another Icon'), id =
varprefix + '_img')
+ else:
+ html.write(_('Select an Icon'))
+ html.end_popup_trigger()
+
+ def render_popup_input(self, varprefix, value):
html.write('<table>')
empty = self._allow_empty and ['empty'] or []
for nr, icon in enumerate(empty + self.available_icons()):
@@ -3264,8 +3269,6 @@ class IconSelector(ValueSpec):
html.write('</td>')
html.write('</tr>')
html.write('</table>')
- html.write('</div>')
- html.write('</div>')
def from_html_vars(self, varprefix):
icon = html.var(varprefix + '_value')
diff --git a/web/htdocs/views.py b/web/htdocs/views.py
index aa617d0..bfbbe93 100644
--- a/web/htdocs/views.py
+++ b/web/htdocs/views.py
@@ -2409,4 +2409,22 @@ def ajax_inv_render_tree():
else:
render_inv_subtree_container(hostname, tree_id, invpath, node)
+#.
+# .--Icon Selector-------------------------------------------------------.
+# | ___ ____ _ _ |
+# | |_ _|___ ___ _ __ / ___| ___| | ___ ___| |_ ___ _ __ |
+# | | |/ __/ _ \| '_ \ \___ \ / _ \ |/ _ \/ __| __/ _ \| '__| |
+# | | | (_| (_) | | | | ___) | __/ | __/ (__| || (_) | | |
+# | |___\___\___/|_| |_| |____/ \___|_|\___|\___|\__\___/|_| |
+# | |
+# +----------------------------------------------------------------------+
+# | AJAX API call for rendering the icon selector |
+# '----------------------------------------------------------------------'
+
+def ajax_popup_icon_selector():
+ varprefix = html.var('varprefix')
+ value = html.var('value')
+ allow_empty = html.var('allow_empty') == '1'
+ vs = IconSelector(allow_empty=allow_empty)
+ vs.render_popup_input(varprefix, value)
diff --git a/web/plugins/icons/builtin.py b/web/plugins/icons/builtin.py
index 721bcee..8ad6d68 100644
--- a/web/plugins/icons/builtin.py
+++ b/web/plugins/icons/builtin.py
@@ -57,6 +57,25 @@
# 'paint': paint_icon_image,
#})
+# .--Action Menu---------------------------------------------------------.
+# | _ _ _ __ __ |
+# | / \ ___| |_(_) ___ _ __ | \/ | ___ _ __ _ _ |
+# | / _ \ / __| __| |/ _ \| '_ \ | |\/| |/ _ \ '_ \| | | | |
+# | / ___ \ (__| |_| | (_) | | | | | | | | __/ | | | |_| | |
+# | /_/ \_\___|\__|_|\___/|_| |_| |_| |_|\___|_| |_|\__,_| |
+# | |
+# +----------------------------------------------------------------------+
+# | |
+# '----------------------------------------------------------------------'
+
+def paint_action_menu():
+ pass
+ return 'open_menu', 'onclick:'
+
+multisite_icons.append({
+ 'columns': [],
+ 'paint': paint_action_menu,
+})
# +----------------------------------------------------------------------+
# | ____ _ _ _ |
diff --git a/web/plugins/pages/shipped.py b/web/plugins/pages/shipped.py
index f50e3d2..9c187ed 100644
--- a/web/plugins/pages/shipped.py
+++ b/web/plugins/pages/shipped.py
@@ -103,6 +103,9 @@ pagehandlers.update({
"ajax_userdb_sync" : userdb.ajax_sync,
"notify" : notify.page_notify,
+ "ajax_inv_render_tree" : views.ajax_inv_render_tree,
+ "ajax_popup_icon_selector" : views.ajax_popup_icon_selector,
+
"webapi" : webapi.page_api,
"crashed_check" : crashed_check.page_crashed_check,
diff --git a/web/plugins/views/painters.py b/web/plugins/views/painters.py
index 2f3c5ff..dd65b9d 100644
--- a/web/plugins/views/painters.py
+++ b/web/plugins/views/painters.py
@@ -189,7 +189,11 @@ def paint_icons(what, row):
if html.output_format == "html":
if link:
- output += '<a href="%s">' % link
+ onclick = ''
+ if link.startswith('onclick:'):
+ onclick = ' onclick="%s"' % link[8:]
+ link = 'javascript:void(0)'
+ output += '<a href="%s"%s>' % (link,
onclick)
output += html.render_icon(icon_name, title)
if link:
output += '</a>'