[imp] added possibility to only show some states in status widget
bzr revid: nicolas.vanhoren@openerp.com-20110908163536-bewx1817u96t11rc
This commit is contained in:
parent
ec24f26ca6
commit
7987d3a2f6
|
@ -2482,16 +2482,25 @@ openerp.web.form.FieldStatus = openerp.web.form.Field.extend({
|
|||
template: "FieldStatus",
|
||||
start: function() {
|
||||
this._super();
|
||||
this.selected_index = null;
|
||||
this.selected_value = null;
|
||||
this.render_list();
|
||||
},
|
||||
set_value: function(value) {
|
||||
this._super(value);
|
||||
var select = _.detect(this.field.selection, function(x) { return x[0] === value; });
|
||||
this.selected_index = _.indexOf(this.field.selection, select);
|
||||
this.selected_value = value;
|
||||
this.render_list();
|
||||
},
|
||||
render_list: function() {
|
||||
var self = this;
|
||||
var shown = _.map(((this.node.attrs || {}).statusbar_visible || "").split(","),
|
||||
function(x) { return x.trim(); });
|
||||
if (shown.length == 0) {
|
||||
this.to_show = this.field.selection;
|
||||
} else {
|
||||
this.to_show = _.select(this.field.selection, function(x) {
|
||||
return _.indexOf(shown, x[0]) !== -1 || x[0] === self.selected_value;
|
||||
});
|
||||
}
|
||||
var content = openerp.web.qweb.render("FieldStatus.content", {widget: this, _:_});
|
||||
this.$element.html(content);
|
||||
}
|
||||
|
|
|
@ -1382,10 +1382,10 @@
|
|||
</t>
|
||||
<t t-name="FieldStatus.content">
|
||||
<ul class="oe-arrow-list">
|
||||
<t t-set="size" t-value="widget.field.selection.length"/>
|
||||
<t t-set="size" t-value="widget.to_show.length"/>
|
||||
<t t-foreach="_.range(size)" t-as="i">
|
||||
<li t-att-class="i === widget.selected_index ? 'oe-arrow-list-selected' : ''">
|
||||
<span class="oe-arrow-list-before" t-if="i > 0"></span><span><t t-esc="widget.field.selection[i][1]"/></span><span class="oe-arrow-list-after" t-if="i < size - 1"></span>
|
||||
<li t-att-class="widget.to_show[i][0] === widget.selected_value ? 'oe-arrow-list-selected' : ''">
|
||||
<span class="oe-arrow-list-before" t-if="i > 0"></span><span><t t-esc="widget.to_show[i][1]"/></span><span class="oe-arrow-list-after" t-if="i < size - 1"></span>
|
||||
</li>
|
||||
</t>
|
||||
</ul>
|
||||
|
|
Loading…
Reference in New Issue