[IMP] make sortable columns look sortable (and sorted) a bit
bzr revid: xmo@openerp.com-20110504144753-zemygt44re3o8z0m
This commit is contained in:
parent
ff691a34b5
commit
075902f5c2
|
@ -591,6 +591,16 @@ class ListView(View):
|
|||
domain=domain, sort=sort)
|
||||
eval_context = request.session.evaluation_context(
|
||||
request.context)
|
||||
|
||||
if sort:
|
||||
sort_criteria = sort.split(',')[0].split(' ')
|
||||
print sort, sort_criteria
|
||||
view['sorted'] = {
|
||||
'field': sort_criteria[0],
|
||||
'reversed': sort_criteria[1] == 'DESC'
|
||||
}
|
||||
else:
|
||||
view['sorted'] = {}
|
||||
return {
|
||||
'view': view,
|
||||
'records': [
|
||||
|
|
|
@ -485,6 +485,11 @@ body.openerp {
|
|||
.openerp .oe-listview td,
|
||||
.openerp .oe-listview th {
|
||||
vertical-align: middle;
|
||||
text-align: left;
|
||||
}
|
||||
.openerp .oe-listview th.oe-sortable,
|
||||
.openerp .oe-listview th.oe-sortable .ui-icon {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.openerp .oe-listview .oe-field-cell {
|
||||
|
|
|
@ -197,7 +197,7 @@ openerp.base.DataSetSearch = openerp.base.DataSet.extend({
|
|||
if (criteria[0] === '-') {
|
||||
return criteria.slice(1) + ' DESC';
|
||||
}
|
||||
return criteria;
|
||||
return criteria + ' ASC';
|
||||
}).join(', ');
|
||||
}
|
||||
|
||||
|
|
|
@ -123,6 +123,8 @@ openerp.base.ListView = openerp.base.Controller.extend(
|
|||
this.visible_columns = _.filter(this.columns, function (column) {
|
||||
return column.invisible !== '1';
|
||||
});
|
||||
|
||||
if (!this.fields_view.sorted) { this.fields_view.sorted = {}; }
|
||||
this.$element.html(QWeb.render("ListView", this));
|
||||
|
||||
// Head hook
|
||||
|
@ -135,6 +137,7 @@ openerp.base.ListView = openerp.base.Controller.extend(
|
|||
|
||||
self.dataset.sort($(this).data('id'));
|
||||
|
||||
// TODO: should only reload content (and set the right column to a sorted display state)
|
||||
self.do_reload();
|
||||
});
|
||||
|
||||
|
|
|
@ -181,9 +181,11 @@
|
|||
<tr t-if="options.header">
|
||||
<th t-if="options.selectable"/>
|
||||
<t t-foreach="columns" t-as="column">
|
||||
<th t-if="column.invisible !== '1'" t-att-data-id="column.id">
|
||||
<th t-if="column.invisible !== '1'" t-att-data-id="column.id"
|
||||
t-att-class="((options.sortable and column.tag !== 'button') ? 'oe-sortable' : null)">
|
||||
<t t-if="column.tag !== 'button'">
|
||||
<t t-esc="column.string"/>
|
||||
<span t-att-class="(fields_view.sorted.field === column.id) ? ('ui-icon' + (fields_view.sorted.reversed ? ' ui-icon-triangle-1-n' : ' ui-icon-triangle-1-s')) : ''"/>
|
||||
</t>
|
||||
</th>
|
||||
</t>
|
||||
|
|
Loading…
Reference in New Issue