diff options
| author | Raphael Collet <rco@openerp.com> | 2015-08-28 11:37:30 +0200 |
|---|---|---|
| committer | Raphael Collet <rco@openerp.com> | 2015-08-28 13:54:57 +0200 |
| commit | d2b9015255942902c495e6bac27e38692be7140c (patch) | |
| tree | b741fbf4e25ab95672bb79a53758b16148066608 | |
| parent | f6a4f5c05f465bd01c99fc5885848f5484987652 (diff) | |
[IMP] web: in `boolean_button`, move options to inner elements to handle translations
In practice, we replace:
<field name="active" widget="boolean_button"
options='{"true": "Active", "false": "Inactive"}'/>
by:
<field name="active" widget="boolean_button">
<span class="o_stat_text o_true text-success">Active</span>
<span class="o_stat_text o_false text-danger">Inactive</span>
</field>
| -rw-r--r-- | addons/web/static/src/css/base.css | 8 | ||||
| -rw-r--r-- | addons/web/static/src/css/base.sass | 8 | ||||
| -rw-r--r-- | addons/web/static/src/js/views/form_widgets.js | 5 | ||||
| -rw-r--r-- | addons/web/static/src/xml/base.xml | 5 | ||||
| -rw-r--r-- | openerp/addons/base/res/res_users_view.xml | 6 |
5 files changed, 13 insertions, 19 deletions
diff --git a/addons/web/static/src/css/base.css b/addons/web/static/src/css/base.css index 91b8fe7e927..b497982ad05 100644 --- a/addons/web/static/src/css/base.css +++ b/addons/web/static/src/css/base.css @@ -301,11 +301,11 @@ .openerp .oe_button_box .oe_stat_button { display: inline-table; } -.openerp .oe_button_box .oe_stat_button .o_stat_info:not(.is_true) > .o_stat_text.oe_true { - display: none; +.openerp .oe_button_box .oe_stat_button .o_stat_info:not(.is_true) .o_true { + display: none !important; } -.openerp .oe_button_box .oe_stat_button .o_stat_info.is_true > .o_stat_text.oe_false { - display: none; +.openerp .oe_button_box .oe_stat_button .o_stat_info.is_true .o_false { + display: none !important; } .openerp button.oe_toggle_button { box-shadow: none; diff --git a/addons/web/static/src/css/base.sass b/addons/web/static/src/css/base.sass index f04f963ae37..ca7b3d293ab 100644 --- a/addons/web/static/src/css/base.sass +++ b/addons/web/static/src/css/base.sass @@ -359,10 +359,10 @@ $sheet-padding: 16px text-align: right .oe_stat_button display: inline-table - .o_stat_info:not(.is_true) > .o_stat_text.oe_true - display: none - .o_stat_info.is_true > .o_stat_text.oe_false - display: none + .o_stat_info:not(.is_true) .o_true + display: none !important + .o_stat_info.is_true .o_false + display: none !important button.oe_toggle_button box-shadow: none white-space: nowrap diff --git a/addons/web/static/src/js/views/form_widgets.js b/addons/web/static/src/js/views/form_widgets.js index f3fe595fec9..d0e614d57cd 100644 --- a/addons/web/static/src/js/views/form_widgets.js +++ b/addons/web/static/src/js/views/form_widgets.js @@ -635,11 +635,6 @@ var FieldBoolean = common.AbstractField.extend({ */ 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()); diff --git a/addons/web/static/src/xml/base.xml b/addons/web/static/src/xml/base.xml index bbed4b59880..cb698908cd8 100644 --- a/addons/web/static/src/xml/base.xml +++ b/addons/web/static/src/xml/base.xml @@ -1436,9 +1436,6 @@ <img t-attf-src="#{_s}/web/static/src/img/icons/#{widget.icon}" t-att-alt="widget.string"/> </button> -<div t-name="BooleanButton" class="o_stat_info is_true"> - <span class="o_stat_text oe_true text-success"><t t-esc="widget.true_string"/></span> - <span class="o_stat_text oe_false text-danger"><t t-esc="widget.false_string"/></span> -</div> +<div t-name="BooleanButton" class="o_stat_info is_true"/> </templates> diff --git a/openerp/addons/base/res/res_users_view.xml b/openerp/addons/base/res/res_users_view.xml index 317c6cdff8b..92375981580 100644 --- a/openerp/addons/base/res/res_users_view.xml +++ b/openerp/addons/base/res/res_users_view.xml @@ -173,8 +173,10 @@ <field name="id" invisible="1"/> <div class="oe_button_box" name="button_box"> <button name="toggle_active" type="object" class="oe_stat_button" icon="fa-check"> - <field name="active" widget="boolean_button" - options='{"true": "Active User", "false": "Inactive User"}'/> + <field name="active" widget="boolean_button"> + <span class="o_stat_text o_true text-success">Active User</span> + <span class="o_stat_text o_false text-danger">Inactive User</span> + </field> </button> </div> <field name="image" widget='image' class="oe_avatar" options='{"preview_image": "image_medium"}'/> |
