[ADD] icons instead of category names for filters (and groupby filters)

bzr revid: xmo@openerp.com-20120504095717-va123l3gz3wvhjd1
This commit is contained in:
Xavier Morel 2012-05-04 11:57:17 +02:00
parent 7e0bd0103b
commit 84cae313d2
3 changed files with 20 additions and 1 deletions

View File

@ -869,6 +869,7 @@ instance.web.search.Input = instance.web.search.Widget.extend( /** @lends instan
});
instance.web.search.FilterGroup = instance.web.search.Input.extend(/** @lends instance.web.search.FilterGroup# */{
template: 'SearchView.filters',
icon: 'q',
/**
* Inclusive group of filters, creates a continuous "button" with clickable
* sections (the normal display for filters is to be a self-contained button)
@ -897,6 +898,7 @@ instance.web.search.FilterGroup = instance.web.search.Input.extend(/** @lends in
make_facet: function (values) {
return {
category: _t("Filter"),
icon: this.icon,
values: values,
field: this
}
@ -974,6 +976,7 @@ instance.web.search.FilterGroup = instance.web.search.Input.extend(/** @lends in
}
});
instance.web.search.GroupbyGroup = instance.web.search.FilterGroup.extend({
icon: 'w',
init: function (filters, view) {
this._super(filters, view);
// Not flanders: facet unicity is handled through the
@ -995,6 +998,7 @@ instance.web.search.GroupbyGroup = instance.web.search.FilterGroup.extend({
make_facet: function (values) {
return {
category: _t("GroupBy"),
icon: this.icon,
values: values,
field: this.getParent()._s_groupby
};

View File

@ -1303,7 +1303,11 @@
type="button"
class="oe_searchview_facet">
<span class="oe_facet_remove"></span>
<span class="oe_facet_category">
<span class="oe_facet_category oe_i" t-if="widget.model.has('icon')">
<t t-esc="widget.model.get('icon')"/>
</span
><span class="oe_facet_category" t-if="!widget.model.has('icon')">
<t t-esc="widget.model.get('category')"/>
</span ><span/>
</button>

View File

@ -218,6 +218,17 @@ with directly by external objects or search view controls
it serializes to and deserializes from javascript arrays (via
``Collection#toJSON`` and ``Collection#reset``).
.. js:attribute:: [icon]
optional, a single ASCII letter (a-z or A-Z) mapping to the
bundled mnmliconsRegular icon font.
When a facet with an ``icon`` attribute is rendered, the icon
is displayed (in the icon font) in the first section of the
facet instead of the ``category``.
By default, only filters make use of this facility.
.. js:class:: openerp.web.search.FacetValues
`Backbone collection`_ of