[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:
Xavier Morel 2011-06-07 13:36:29 +02:00
parent 9ef70d841f
commit 16fcca94a3
2 changed files with 17 additions and 12 deletions

View File

@ -201,10 +201,11 @@ openerp.base.ListView = openerp.base.View.extend( /** @lends openerp.base.ListVi
return column.invisible !== '1'; return column.invisible !== '1';
}); });
this.aggregate_columns = _(this.columns).chain() this.aggregate_columns = _(this.visible_columns)
.filter(function (column) {
return column['sum'] || column['avg'];})
.map(function (column) { .map(function (column) {
if (!(column['sum'] || column['avg'])) {
return {};
}
var func = column['sum'] ? 'sum' : 'avg'; var func = column['sum'] ? 'sum' : 'avg';
return { return {
field: column.id, field: column.id,
@ -212,7 +213,7 @@ openerp.base.ListView = openerp.base.View.extend( /** @lends openerp.base.ListVi
'function': func, 'function': func,
label: column[func] label: column[func]
}; };
}).value(); });
}, },
/** /**
* Used to handle a click on a table row, if no other handler caught the * 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; return aggregator;
}, },
display_aggregates: function (aggregation) { 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) { _(this.aggregate_columns).each(function (column) {
$(_.sprintf( if (!column['function']) {
"<span>%s: %.2f</span>", return;
column.label, aggregation[column.field])) }
.appendTo($footer); 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) // TODO: implement reorder (drag and drop rows)

View File

@ -272,11 +272,13 @@
<th t-if="options.deletable"/> <th t-if="options.deletable"/>
</tr> </tr>
</thead> </thead>
<tfoot class="ui-widget-header" t-if="aggregate_columns.length"> <tfoot class="ui-widget-header">
<tr> <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>
<td t-if="options.deletable"/>
</tr> </tr>
</tfoot> </tfoot>
</table> </table>