summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js/views/form_widgets.js
diff options
context:
space:
mode:
authorGaurav Panchal <gan@openerp.com>2015-08-27 11:34:21 +0200
committerRaphael Collet <rco@openerp.com>2015-08-27 16:59:47 +0200
commit95cb54b80bcfabde0473770d1a082a2b398dafbe (patch)
treeb876796391c6a0175a7644a45fe0bd6431b88f92 /addons/web/static/src/js/views/form_widgets.js
parent40cbf2bea132d89ccf81600f141613b3cc3cd993 (diff)
[ADD] web: add dynamic widget to toggle boolean button
Diffstat (limited to 'addons/web/static/src/js/views/form_widgets.js')
-rw-r--r--addons/web/static/src/js/views/form_widgets.js24
1 files changed, 24 insertions, 0 deletions
diff --git a/addons/web/static/src/js/views/form_widgets.js b/addons/web/static/src/js/views/form_widgets.js
index 0d42f3d4469..f3fe595fec9 100644
--- a/addons/web/static/src/js/views/form_widgets.js
+++ b/addons/web/static/src/js/views/form_widgets.js
@@ -630,6 +630,29 @@ var FieldBoolean = common.AbstractField.extend({
});
/**
+ This widget is intended to be used on stat button boolean fields.
+ It is a read-only field that will display a simple string "<label of value>".
+*/
+var FieldBooleanButton = common.AbstractField.extend({
+ template: 'BooleanButton',
+ init: function() {
+ this._super.apply(this, arguments);
+ this.true_string = this.options['true'] || _t('True');
+ this.false_string = this.options['false'] || _t('False');
+ },
+ render_value: function() {
+ this._super();
+ this.$el.toggleClass("is_true", this.get_value());
+ if (this.node.attrs.class) {
+ this.$el.addClass(this.node.attrs.class);
+ }
+ },
+ is_false: function() {
+ return false;
+ },
+});
+
+/**
The progressbar field expect a float from 0 to 100.
*/
var FieldProgressBar = common.AbstractField.extend(common.ReinitializeFieldMixin, {
@@ -1597,6 +1620,7 @@ core.form_widget_registry
.add('radio', FieldRadio)
.add('reference', FieldReference)
.add('boolean', FieldBoolean)
+ .add('boolean_button', FieldBooleanButton)
.add('toggle_button', FieldToggleBoolean)
.add('float', FieldFloat)
.add('percentpie', FieldPercentPie)