[IMP] web: allow to custom button_boolean widget
eg:
<field name="active" widget="boolean_button"
options="{
'terminology': {
'string_true': 'Published',
'hover_true': 'Unpublish',
'string_false': 'Unpublished',
'hover_false': 'Publish'
}
}"
/>
This commit is contained in:
@@ -42,7 +42,12 @@
|
||||
<field name="active" widget="boolean_button" options='{"terminology": "active"}'/>
|
||||
</button>
|
||||
<button name="toggle_prod_environment" type="object" class="oe_stat_button" icon="fa-check-square" attrs="{'invisible': ['|', ('delivery_type', '=', 'fixed'), ('delivery_type', '=', 'base_on_rule')]}">
|
||||
<field name="prod_environment" widget="boolean_button" options='{"terminology": "prod_environment"}'/>
|
||||
<field name="prod_environment" widget="boolean_button" options='{"terminology": {
|
||||
"string_true": "Production Environment",
|
||||
"hover_true": "Switch to test environment",
|
||||
"string_false": "Test Environment",
|
||||
"hover_false": "Switch to production environment"
|
||||
}}'/>
|
||||
</button>
|
||||
</div>
|
||||
<div class="oe_title" name="title">
|
||||
|
||||
@@ -641,17 +641,12 @@ var FieldBooleanButton = common.AbstractField.extend({
|
||||
this.string_false = _t("Archived");
|
||||
this.hover_false = _t("Unarchive");
|
||||
break;
|
||||
case "prod_environment":
|
||||
this.string_true = _t("Production Environment");
|
||||
this.hover_true = _t("Switch to test environment");
|
||||
this.string_false = _t("Test Environment");
|
||||
this.hover_false = _t("Switch to production environment");
|
||||
break;
|
||||
default:
|
||||
this.string_true = _t("On");
|
||||
this.hover_true = _t("Switch Off");
|
||||
this.string_false = _t("Off");
|
||||
this.hover_false = _t("Switch On");
|
||||
var terms = typeof this.options["terminology"] === 'string' ? {} : this.options["terminology"];
|
||||
this.string_true = _t(terms.string_true || "On");
|
||||
this.hover_true = _t(terms.hover_true || terms.string_false || "Switch Off");
|
||||
this.string_false = _t(terms.string_false || "Off");
|
||||
this.hover_false = _t(terms.hover_false || terms.string_true || "Switch On");
|
||||
}
|
||||
},
|
||||
render_value: function() {
|
||||
|
||||
Reference in New Issue
Block a user