[IMP] move list-wise aggregation results in the corresponding table columns, move labels to popover titles
bzr revid: xmo@openerp.com-20110607113629-0jexwkti3bsiebxb
This commit is contained in:
parent
9ef70d841f
commit
16fcca94a3
|
@ -201,10 +201,11 @@ openerp.base.ListView = openerp.base.View.extend( /** @lends openerp.base.ListVi
|
|||
return column.invisible !== '1';
|
||||
});
|
||||
|
||||
this.aggregate_columns = _(this.columns).chain()
|
||||
.filter(function (column) {
|
||||
return column['sum'] || column['avg'];})
|
||||
this.aggregate_columns = _(this.visible_columns)
|
||||
.map(function (column) {
|
||||
if (!(column['sum'] || column['avg'])) {
|
||||
return {};
|
||||
}
|
||||
var func = column['sum'] ? 'sum' : 'avg';
|
||||
return {
|
||||
field: column.id,
|
||||
|
@ -212,7 +213,7 @@ openerp.base.ListView = openerp.base.View.extend( /** @lends openerp.base.ListVi
|
|||
'function': func,
|
||||
label: column[func]
|
||||
};
|
||||
}).value();
|
||||
});
|
||||
},
|
||||
/**
|
||||
* Used to handle a click on a table row, if no other handler caught the
|
||||
|
@ -493,12 +494,14 @@ openerp.base.ListView = openerp.base.View.extend( /** @lends openerp.base.ListVi
|
|||
return aggregator;
|
||||
},
|
||||
display_aggregates: function (aggregation) {
|
||||
var $footer = this.$element.find('.oe-list-footer').empty();
|
||||
var $footer_cells = this.$element.find('.oe-list-footer');
|
||||
_(this.aggregate_columns).each(function (column) {
|
||||
$(_.sprintf(
|
||||
"<span>%s: %.2f</span>",
|
||||
column.label, aggregation[column.field]))
|
||||
.appendTo($footer);
|
||||
if (!column['function']) {
|
||||
return;
|
||||
}
|
||||
var pattern = (column.type == 'integer') ? '%d' : '%.2f';
|
||||
$footer_cells.filter(_.sprintf('[data-field=%s]', column.field))
|
||||
.text(_.sprintf(pattern, aggregation[column.field]));
|
||||
});
|
||||
}
|
||||
// TODO: implement reorder (drag and drop rows)
|
||||
|
|
|
@ -272,11 +272,13 @@
|
|||
<th t-if="options.deletable"/>
|
||||
</tr>
|
||||
</thead>
|
||||
<tfoot class="ui-widget-header" t-if="aggregate_columns.length">
|
||||
<tfoot class="ui-widget-header">
|
||||
<tr>
|
||||
<td t-att-colspan="columns_count" class='oe-list-footer'>
|
||||
|
||||
<td t-if="options.selectable"/>
|
||||
<td t-foreach="aggregate_columns" t-as="column" class="oe-list-footer oe-number"
|
||||
t-att-data-field="column.field" t-att-title="column.label">
|
||||
</td>
|
||||
<td t-if="options.deletable"/>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
|
|
Loading…
Reference in New Issue