[imp] setup of templates for status widget
bzr revid: nicolas.vanhoren@openerp.com-20110908150645-uqj6f9f5icnsf3jx
This commit is contained in:
@@ -2479,55 +2479,17 @@ openerp.web.form.FieldBinaryImage = openerp.web.form.FieldBinary.extend({
|
||||
});
|
||||
|
||||
openerp.web.form.FieldStatus = openerp.web.form.Field.extend({
|
||||
init: function(view, node) {
|
||||
var self = this;
|
||||
this._super(view, node);
|
||||
this.template = "FieldSelection";
|
||||
this.values = this.field.selection;
|
||||
_.each(this.values, function(v, i) {
|
||||
if (v[0] === false && v[1] === '') {
|
||||
self.values.splice(i, 1);
|
||||
}
|
||||
});
|
||||
this.values.unshift([false, '']);
|
||||
},
|
||||
template: "FieldStatus",
|
||||
start: function() {
|
||||
var ischanging = false;
|
||||
this._super.apply(this, arguments);
|
||||
this.$element.find('select')
|
||||
.change(this.on_ui_change)
|
||||
.change(function () { ischanging = true; })
|
||||
.click(function () { ischanging = false; })
|
||||
.keyup(function (e) {
|
||||
if (e.which !== 13 || !ischanging) { return; }
|
||||
e.stopPropagation();
|
||||
ischanging = false;
|
||||
});
|
||||
this._super();
|
||||
this.render_list();
|
||||
},
|
||||
set_value: function(value) {
|
||||
value = value === null ? false : value;
|
||||
value = value instanceof Array ? value[0] : value;
|
||||
this._super(value);
|
||||
var index = 0;
|
||||
for (var i = 0, ii = this.values.length; i < ii; i++) {
|
||||
if (this.values[i][0] === value) index = i;
|
||||
}
|
||||
this.$element.find('select')[0].selectedIndex = index;
|
||||
this.render_list();
|
||||
},
|
||||
set_value_from_ui: function() {
|
||||
this.value = this.values[this.$element.find('select')[0].selectedIndex][0];
|
||||
this._super();
|
||||
},
|
||||
update_dom: function() {
|
||||
this._super.apply(this, arguments);
|
||||
this.$element.find('select').attr('disabled', this.readonly);
|
||||
},
|
||||
validate: function() {
|
||||
var value = this.values[this.$element.find('select')[0].selectedIndex];
|
||||
this.invalid = !(value && !(this.required && value[0] === false));
|
||||
},
|
||||
focus: function() {
|
||||
this.$element.find('select').focus();
|
||||
render_list: function() {
|
||||
this.$element.html("Youpsla");
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -1376,5 +1376,11 @@
|
||||
Depending on your needs, OpenERP is available through a web or application client.
|
||||
</p>
|
||||
</div>
|
||||
</t>
|
||||
<t t-name="FieldStatus">
|
||||
<div t-att-id="widget.element_id"></div>
|
||||
</t>
|
||||
<t t-name="FieldStatus.content">
|
||||
|
||||
</t>
|
||||
</templates>
|
||||
|
||||
Reference in New Issue
Block a user