[IMP] Added ReinilizeWidgetMixin
bzr revid: nicolas.vanhoren@openerp.com-20120928124132-od7gze2in1mq6onc
This commit is contained in:
parent
2c2bb730f5
commit
2a76eb2e1c
|
@ -2093,10 +2093,10 @@ instance.web.form.AbstractField = instance.web.form.FormWidget.extend(instance.w
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A mixin to apply on any field that has to completely re-render when its readonly state
|
* A mixin to apply on any FormWidget that has to completely re-render when its readonly state
|
||||||
* switch.
|
* switch.
|
||||||
*/
|
*/
|
||||||
instance.web.form.ReinitializeFieldMixin = {
|
instance.web.form.ReinitializeWidgetMixin = {
|
||||||
/**
|
/**
|
||||||
* Default implementation of start(), use it or call explicitly initialize_field().
|
* Default implementation of start(), use it or call explicitly initialize_field().
|
||||||
*/
|
*/
|
||||||
|
@ -2109,10 +2109,8 @@ instance.web.form.ReinitializeFieldMixin = {
|
||||||
this.destroy_content();
|
this.destroy_content();
|
||||||
this.renderElement();
|
this.renderElement();
|
||||||
this.initialize_content();
|
this.initialize_content();
|
||||||
this.render_value();
|
|
||||||
});
|
});
|
||||||
this.initialize_content();
|
this.initialize_content();
|
||||||
this.render_value();
|
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* Called to destroy anything that could have been created previously, called before a
|
* Called to destroy anything that could have been created previously, called before a
|
||||||
|
@ -2123,11 +2121,25 @@ instance.web.form.ReinitializeFieldMixin = {
|
||||||
* Called to initialize the content.
|
* Called to initialize the content.
|
||||||
*/
|
*/
|
||||||
initialize_content: function() {},
|
initialize_content: function() {},
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A mixin to apply on any field that has to completely re-render when its readonly state
|
||||||
|
* switch.
|
||||||
|
*/
|
||||||
|
instance.web.form.ReinitializeFieldMixin = _.extend({}, instance.web.form.ReinitializeWidgetMixin, {
|
||||||
|
initialize_field: function() {
|
||||||
|
instance.web.form.ReinitializeWidgetMixin.initialize_field.call(this);
|
||||||
|
this.on("change:effective_readonly", this, function() {
|
||||||
|
this.render_value();
|
||||||
|
});
|
||||||
|
this.render_value();
|
||||||
|
},
|
||||||
/**
|
/**
|
||||||
* Called to render the value. Should also be explicitly called at the end of a set_value().
|
* Called to render the value. Should also be explicitly called at the end of a set_value().
|
||||||
*/
|
*/
|
||||||
render_value: function() {},
|
render_value: function() {},
|
||||||
};
|
});
|
||||||
|
|
||||||
instance.web.form.FieldChar = instance.web.form.AbstractField.extend(instance.web.form.ReinitializeFieldMixin, {
|
instance.web.form.FieldChar = instance.web.form.AbstractField.extend(instance.web.form.ReinitializeFieldMixin, {
|
||||||
template: 'FieldChar',
|
template: 'FieldChar',
|
||||||
|
|
Loading…
Reference in New Issue