Provide help-text capability for server-side filter choices

We have server-side filtering available for Project/Admin Instances,
and we have more to come (see bp). Some of these filters should provide
help text for what format user needs to input to filter.
For example, 'changed-since' filter is very vague. Need to provide
date format to user.

This patch adds a tooltip to the select option upon hovering.

How to use: add help text to the filter_choice in
/dashboards/admin/instances/table.py.

filter_choices = (
('name', _("Name ="), True),
('date_created', _("Date Created="), True, _("ISO 8601 format")),
...)

Change-Id: I436a3de51aa8182200cf56ad5502a85d1cd1b11c
Partially-implements: blueprint server-side-filtering
This commit is contained in:
Cindy Lu 2016-06-24 11:34:06 -07:00
parent fbb6f64114
commit e6cbcd3cb1
2 changed files with 7 additions and 4 deletions
horizon
tables
templates/horizon/common/fields

@ -528,10 +528,11 @@ class FilterAction(BaseAction):
return False
def get_select_options(self):
"""Provide the value and string for the template to render.
"""Provide the value, string, and help_text (if applicable)
for the template to render.
"""
if self.filter_choices:
return [x[:2] for x in self.filter_choices]
return [x[:4] for x in self.filter_choices]
class NameFilterAction(FilterAction):

@ -23,8 +23,10 @@
</button>
<ul class="dropdown-menu">
{% for option in options %}
<li data-original-index="{{ forloop.counter0 }}">
<a data-select-value="{{ option.0 }}"
<li data-original-index="{{ forloop.counter0 }}"
data-toggle="tooltip" data-placement="top"
{% if option.3 %} title="{{ option.3 }}" {% endif %}>
<a data-select-value="{{ option.0 }}"
{% if option.2 %}
{{ option.2|safe|default:'' }}
{% endif %}>{{ option.1 }}</a>