[IMP] view_form: radio button: change style for required field

bzr revid: chm@openerp.com-20130411090654-ujf7fio6lnsppv90
This commit is contained in:
Christophe Matthieu 2013-04-11 11:06:54 +02:00
parent f2beb97168
commit 67452d290e
4 changed files with 42 additions and 8 deletions

View File

@ -2312,9 +2312,26 @@
.openerp .oe_form_field_radio.oe_horizontal {
white-space: nowrap;
}
.openerp .oe_form_field_radio.oe_horizontal label {
.openerp .oe_form_field_radio.oe_required .oe_radio_input {
border: 1px solid transparent;
display: inline-block;
height: 12px;
width: 12px;
vertical-align: bottom;
border-radius: 10px;
margin: 1px 0;
}
.openerp .oe_form_field_radio.oe_required.oe_form_invalid .oe_radio_input {
border-color: red;
}
.openerp .oe_form_field_radio.oe_horizontal label,
.openerp .oe_form_field_radio.oe_horizontal div {
display: inline-block;
text-align: center;
height: 16px;
}
.openerp .oe_form_field_radio.oe_vertical label {
margin-left: 4px;
}
.openerp .oe_form_field_progressbar.ui-progressbar {
height: 22px;

View File

@ -486,6 +486,22 @@ $sheet-padding: 16px
label
display: inline-block
text-align: center
height: 16px
&.oe_vertical
label
margin-left: 4px
&.oe_required
.oe_radio_input
border: 2px solid transparent
display: inline-block
height: 12px
width: 12px
vertical-align: bottom
border-radius: 10px
margin: 1px 0
&.oe_form_invalid
.oe_radio_input
border-color: red
.oe_tags
&.oe_inline
min-width: 250px

View File

@ -2813,14 +2813,13 @@ instance.web.form.FieldRadio = instance.web.form.AbstractField.extend(instance.w
/* Radio button widget: Attributes options:
* - "horizontal" to display in column
* - "no_radiolabel" don't display text values
* - "display_readonly" to display radio button (not clickable) in read only mode
*/
this._super(field_manager, node);
this.horizontal = +this.options.horizontal || false;
this.no_radiolabel = +this.options.no_radiolabel || false;
this.display_readonly = +this.options.display_readonly || false;
this.selection = _.clone(this.field.selection) || [];
this.domain = false;
console.log(this);
},
initialize_content: function () {
this.uniqueId = _.uniqueId("radio");
@ -2888,7 +2887,7 @@ instance.web.form.FieldRadio = instance.web.form.AbstractField.extend(instance.w
render_value: function () {
this.$(".oe_radio_edit_only, .oe_radio_read_only").hide();
this.$(this.get('effective_readonly') ? ".oe_radio_read_only" : ".oe_radio_edit_only").show();
this.$("input[checked]").prop("checked", false);
this.$("input[checked]").attr("checked", false);
if (this.get_value()) {
this.$("input[value='" + this.get_value() + "']").attr("checked", true);
this.$(".oe_radio_read_only .oe_radio_header").text(this.get('value') ? this.get('value')[1] : "");

View File

@ -1112,7 +1112,7 @@
</span>
</t>
<t t-name="FieldRadio">
<span t-attf-class="oe_form_field oe_form_field_radio #{widget.horizontal ? 'oe_horizontal' : 'oe_vertical'}" t-att-style="widget.node.attrs.style">
<span t-attf-class="oe_form_field oe_form_field_radio #{widget.horizontal ? 'oe_horizontal' : 'oe_vertical'} #{widget.field.required or widget.node.attrs.required ? 'oe_required' : ''}" t-att-style="widget.node.attrs.style">
<span class="oe_radio_edit_only">
<t t-if="widget.horizontal">
<t t-set="width" t-value="Math.floor(100 / widget.selection.length)"/>
@ -1123,13 +1123,15 @@
<br/>
</t>
<t t-foreach="widget.selection" t-as="selection">
<input type="radio" t-att-name="widget.uniqueId" t-att-id="widget.uniqueId + '_' + selection[0]" t-att-style="'width: ' + width + '%;'" t-att-value="selection[0]"/>
<div t-att-style="'width: ' + width + '%;'">
<span class="oe_radio_input"><input type="radio" t-att-name="widget.uniqueId" t-att-id="widget.uniqueId + '_' + selection[0]" t-att-value="selection[0]"/></span>
</div>
</t>
</t>
<t t-if="!widget.horizontal">
<t t-foreach="widget.selection" t-as="selection">
<div t-att-data-id="selection[0]">
<input type="radio" t-att-id="widget.uniqueId + '_' + selection[0]" t-att-name="widget.uniqueId" t-att-value="selection[0]"/>&amp;nbsp;<label t-if="!widget.no_radiolabel" t-att-for="widget.uniqueId + '_' + selection[0]"><t t-esc="selection[1]"/></label>
<div>
<span class="oe_radio_input"><input type="radio" t-att-id="widget.uniqueId + '_' + selection[0]" t-att-name="widget.uniqueId" t-att-value="selection[0]"/></span><label t-if="!widget.no_radiolabel" t-att-for="widget.uniqueId + '_' + selection[0]"><t t-esc="selection[1]"/></label>
</div>
</t>
</t>