[ADD] attrs.invisible in readonly list cells
bzr revid: xmo@openerp.com-20110412065343-ee8iinkqw2iobl90
This commit is contained in:
parent
ae0a6c6cf1
commit
0006e356f9
|
@ -569,7 +569,8 @@ class ListView(View):
|
|||
eval_context = request.session.evaluation_context(
|
||||
request.context)
|
||||
return [
|
||||
{'data': row,
|
||||
{'data': dict((key, {'value': value})
|
||||
for key, value in row.iteritems()),
|
||||
'color': self.process_colors(view, row, eval_context)}
|
||||
for row in rows
|
||||
]
|
||||
|
|
|
@ -45,10 +45,26 @@ openerp.base.ListView = openerp.base.Controller.extend(
|
|||
this.name = "" + this.fields_view.arch.attrs.string;
|
||||
|
||||
var fields = this.fields_view.fields;
|
||||
var domain_computer = openerp.base.form.compute_domain;
|
||||
this.columns = _(this.fields_view.arch.children).chain()
|
||||
.map(function (field) {
|
||||
var name = field.attrs.name;
|
||||
return _.extend({id: name, tag: field.tag}, field.attrs, fields[name]);
|
||||
var column = _.extend({id: name, tag: field.tag},
|
||||
field.attrs, fields[name]);
|
||||
// attrs computer
|
||||
if (column.attrs) {
|
||||
var attrs = eval('(' + column.attrs + ')');
|
||||
column.attrs_for = function (fields) {
|
||||
var result = {};
|
||||
for (var attr in attrs) {
|
||||
result[attr] = domain_computer(attrs[attr], fields);
|
||||
}
|
||||
return result;
|
||||
};
|
||||
} else {
|
||||
column.attrs_for = function () { return {}; };
|
||||
}
|
||||
return column;
|
||||
}).value();
|
||||
|
||||
this.visible_columns = _.filter(this.columns, function (column) {
|
||||
|
@ -86,6 +102,9 @@ openerp.base.ListView = openerp.base.Controller.extend(
|
|||
*/
|
||||
do_fill_table: function(records) {
|
||||
this.rows = records;
|
||||
this.dataset.ids = _(records).chain().map(function (record) {
|
||||
return record.data.id.value;
|
||||
}).value();
|
||||
|
||||
var $table = this.$element.find('table');
|
||||
// remove all data lines
|
||||
|
@ -133,7 +152,7 @@ openerp.base.ListView = openerp.base.Controller.extend(
|
|||
// count number of preceding siblings to line clicked
|
||||
var row = this.rows[$target.prevAll().length];
|
||||
|
||||
var index = _.indexOf(this.dataset.ids, row.id);
|
||||
var index = _.indexOf(this.dataset.ids, row.data.id.value);
|
||||
if (index == undefined || index === -1) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -209,18 +209,20 @@
|
|||
<input type="checkbox"/>
|
||||
</th>
|
||||
<t t-foreach="columns" t-as="column">
|
||||
<!-- TODO: handle attrs -->
|
||||
<t t-set="attrs" t-value="column.attrs_for(row.data)"/>
|
||||
<td t-if="column.invisible !== '1'" t-att-title="column.help">
|
||||
<t t-set="is_button" t-value="column.tag === 'button'"/>
|
||||
<!-- TODO: get correct widget from form -->
|
||||
<t t-if="!is_button and row['data'][column.id]">
|
||||
<t t-esc="row['data'][column.id]"/>
|
||||
<t t-if="!attrs.invisible">
|
||||
<t t-set="is_button" t-value="column.tag === 'button'"/>
|
||||
<!-- TODO: get correct widget from form -->
|
||||
<t t-if="!is_button and row['data'][column.id].value">
|
||||
<t t-esc="row['data'][column.id].value"/>
|
||||
</t>
|
||||
<button type="button" t-att-title="column.help"
|
||||
t-if="is_button">
|
||||
<img t-att-src="'/base/static/src/img/icons/' + column.icon + '.png'"
|
||||
t-att-alt="column.string"/>
|
||||
</button>
|
||||
</t>
|
||||
<button type="button" t-att-title="column.help"
|
||||
t-if="is_button">
|
||||
<img t-att-src="'/base/static/src/img/icons/' + column.icon + '.png'"
|
||||
t-att-alt="column.string"/>
|
||||
</button>
|
||||
</td>
|
||||
</t>
|
||||
<td t-if="options.deletable" class='oe-record-delete'>
|
||||
|
|
Loading…
Reference in New Issue