diff options
| author | Christophe Matthieu <chm@openerp.com> | 2013-04-11 11:06:54 +0200 |
|---|---|---|
| committer | Christophe Matthieu <chm@openerp.com> | 2013-04-11 11:06:54 +0200 |
| commit | 67452d290eac4e26a0d940510960e2cdc36c657b (patch) | |
| tree | bce80a7d6574c5ca0f55d46dd751693b90e288c2 /addons/web | |
| parent | f2beb97168c474b11b80eff24cab7ff4a450a2ab (diff) | |
[IMP] view_form: radio button: change style for required field
bzr revid: chm@openerp.com-20130411090654-ujf7fio6lnsppv90
Diffstat (limited to 'addons/web')
| -rw-r--r-- | addons/web/static/src/css/base.css | 19 | ||||
| -rw-r--r-- | addons/web/static/src/css/base.sass | 16 | ||||
| -rw-r--r-- | addons/web/static/src/js/view_form.js | 5 | ||||
| -rw-r--r-- | addons/web/static/src/xml/base.xml | 10 |
4 files changed, 42 insertions, 8 deletions
diff --git a/addons/web/static/src/css/base.css b/addons/web/static/src/css/base.css index e2115440717..7e3b3e1a43c 100644 --- a/addons/web/static/src/css/base.css +++ b/addons/web/static/src/css/base.css @@ -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; diff --git a/addons/web/static/src/css/base.sass b/addons/web/static/src/css/base.sass index c92e7fd3c55..4e3dc656882 100644 --- a/addons/web/static/src/css/base.sass +++ b/addons/web/static/src/css/base.sass @@ -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 diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index e1c5208358c..42c021f9717 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -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] : ""); diff --git a/addons/web/static/src/xml/base.xml b/addons/web/static/src/xml/base.xml index df289bbb2ea..d57dc2107f5 100644 --- a/addons/web/static/src/xml/base.xml +++ b/addons/web/static/src/xml/base.xml @@ -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]"/>&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> |
