diff options
| author | Fabien Meghazi <fme@openerp.com> | 2012-03-19 11:29:04 +0100 |
|---|---|---|
| committer | Fabien Meghazi <fme@openerp.com> | 2012-03-19 11:29:04 +0100 |
| commit | cade2c3f162a184a463a6ffd5c1e42e9b15a9a86 (patch) | |
| tree | 86f90ae27133e16ff7f44973404ae62fe5bd9873 /addons/web/static/src | |
| parent | b106632bd2c53862528f9fe8fd1a36aa227d8b9b (diff) | |
[FIX] Fixed labels and stuff
bzr revid: fme@openerp.com-20120319102904-gcnls0j3rl25asq5
Diffstat (limited to 'addons/web/static/src')
| -rw-r--r-- | addons/web/static/src/css/base.css | 3 | ||||
| -rw-r--r-- | addons/web/static/src/css/base.sass | 4 | ||||
| -rw-r--r-- | addons/web/static/src/js/view_form.js | 22 | ||||
| -rw-r--r-- | addons/web/static/src/xml/base.xml | 53 |
4 files changed, 52 insertions, 30 deletions
diff --git a/addons/web/static/src/css/base.css b/addons/web/static/src/css/base.css index 71d5298a68b..4a09865a0f8 100644 --- a/addons/web/static/src/css/base.css +++ b/addons/web/static/src/css/base.css @@ -340,3 +340,6 @@ border-left: 1px solid #666666; padding: 0 4px 0 4px; } +.openerp2 .oe_form_label_help, .openerp2 .oe_form_label { + white-space: nowrap; +} diff --git a/addons/web/static/src/css/base.sass b/addons/web/static/src/css/base.sass index 246b621ba68..a5ad8fd7ad1 100644 --- a/addons/web/static/src/css/base.sass +++ b/addons/web/static/src/css/base.sass @@ -334,7 +334,9 @@ $colour4: #8a89ba .oe_vertical_separator border-left: 1px solid #666 padding: 0 4px 0 4px - // }}} + .oe_form_label_help, .oe_form_label + white-space: nowrap + // }}} .openerp // Transitional overrides for old styles {{{ diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index b4287180452..b7ca275a1e7 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -885,7 +885,17 @@ openerp.web.FormRenderingEngine = openerp.web.Widget.extend({ $separator.before($new_separator).remove(); }, process_label: function($label, $form) { - var $new_label = $(QWeb.render('FormRenderingLabel', $label.getAttributes())); + var dict = $label.getAttributes(); + var align = parseFloat(dict.align); + if (isNaN(align) || align === 1) { + align = 'right'; + } else if (align === 0) { + align = 'left'; + } else { + align = 'center'; + } + dict.align = align; + var $new_label = $(QWeb.render('FormRenderingLabel', dict)); $label.before($new_label).remove(); } }); @@ -1343,6 +1353,16 @@ openerp.web.form.AbstractField = openerp.web.form.Widget.extend(/** @lends opene this.view.on("change:readonly", this, test_effective_readonly); this.view.on("change:force_readonly", this, test_effective_readonly); _.bind(test_effective_readonly, this)(); + + if (this.view) { + this.$label = this.view.$element.find('label[for="' + this.name + '"]'); + if (this.$label.length) { + this.id_for_label = _.uniqueId(['field', this.type, this.name, ''].join('_')); + this.$label.attr('for', this.id_for_label); + } else { + this.$label; + } + } }, start: function() { this._super.apply(this, arguments); diff --git a/addons/web/static/src/xml/base.xml b/addons/web/static/src/xml/base.xml index 31dc699e4e6..58d7b8c95c3 100644 --- a/addons/web/static/src/xml/base.xml +++ b/addons/web/static/src/xml/base.xml @@ -869,7 +869,7 @@ <t t-name="FormRenderingLabel"> <label t-att-for="for" t-att-title="help" - t-attf-class="oe_label#{help ? '_help' : ''} oe_align_#{align}"> + t-attf-class="oe_form_label#{help ? '_help' : ''} oe_align_#{align}"> <t t-esc="string"/> <span t-if="help">?</span> : @@ -944,12 +944,11 @@ </t> <t t-name="FieldChar"> <t t-if="!widget.get('effective_readonly')"> - <div t-attf-class="oe_form_field_#{type}"> - <input t-att-type="widget.password ? 'password' : 'text'" size="1" + <div t-attf-class="oe_form_field_#{widget.type}"> + <input t-att-type="widget.password ? 'password' : 'text'" t-att-name="widget.name" - t-att-id="widget.node.attrs.id" + t-att-id="widget.id_for_label" t-attf-class="field_#{widget.type} #{_(['integer', 'float', 'float_time']).contains(widget.type) ? 'oe-number' : ''}" - style="width: 100%" /><img class="oe_field_translate oe_input_icon" t-if="widget.field.translate" t-att-src='_s + "/web/static/src/img/icons/terp-translate.png"' width="16" height="16" border="0"/> </div> </t> @@ -962,9 +961,9 @@ </t> <t t-name="FieldEmail"> <t t-if="!widget.get('effective_readonly')"> - <table t-attf-class="oe_form_field_#{type}" cellpadding="0" cellspacing="0" border="0" width="100%"> + <table t-attf-class="oe_form_field_#{widget.type}" cellpadding="0" cellspacing="0" border="0"> <tr> - <td width="100%"> + <td> <t t-call="FieldChar"/> </td> <td width="16"> @@ -983,9 +982,9 @@ </t> <t t-name="FieldUrl"> <t t-if="!widget.get('effective_readonly')"> - <table t-attf-class="oe_form_field_#{type}" cellpadding="0" cellspacing="0" border="0" width="100%"> + <table t-attf-class="oe_form_field_#{widget.type}" cellpadding="0" cellspacing="0" border="0"> <tr> - <td width="100%"> + <td> <t t-call="FieldChar"/> </td> <td width="16"> @@ -1003,18 +1002,17 @@ </t> </t> <t t-name="FieldText"> - <div t-attf-class="oe_form_field_#{type}"> + <div t-attf-class="oe_form_field_#{widget.type}"> <textarea rows="6" t-att-name="widget.name" t-attf-class="field_#{widget.type}" - style="width: 100%" ></textarea><img class="oe_field_translate oe_input_icon" t-if="widget.field.translate" t-att-src='_s + "/web/static/src/img/icons/terp-translate.png"' width="16" height="16" border="0"/> </div> </t> <t t-name="web.datetimepicker"> - <div class="oe_datepicker_root" t-attf-class="oe_form_field_#{type}"> - <input type="text" size="1" class="oe_datepicker_container" disabled="disabled" style="display: none;"/> - <input type="text" size="1" style="width: 100%" + <div class="oe_datepicker_root" t-attf-class="oe_form_field_#{widget.type}"> + <input type="text" class="oe_datepicker_container" disabled="disabled" style="display: none;"/> + <input type="text" t-att-name="widget.name" t-attf-class="oe_datepicker_master field_#{widget.type_of_date}" /><img class="oe_input_icon oe_datepicker_trigger" t-att-src='_s + "/web/static/src/img/ui/field_calendar.png"' @@ -1023,11 +1021,10 @@ </t> <t t-name="FieldSelection"> <t t-if="!widget.get('effective_readonly')"> - <div t-attf-class="oe_form_field_#{type}"> + <div t-attf-class="oe_form_field_#{widget.type}"> <select t-att-name="widget.name" - t-att-id="widget.node.attrs.id" - style="width: 100%"> + t-att-id="widget.id_for_label"> <t t-foreach="widget.values" t-as="option"> <option><t t-esc="option[1]"/></option> </t> @@ -1042,9 +1039,9 @@ </t> </t> <t t-name="FieldMany2One"> - <table t-attf-class="oe_form_field_#{type}" cellpadding="0" cellspacing="0" border="0" width="100%"> + <table t-attf-class="oe_form_field_#{widget.type}" cellpadding="0" cellspacing="0" border="0"> <tr> - <td width="100%" valign="top"> + <td valign="top"> <t t-call="FieldChar"/> <span class="oe-m2o-drop-down-button"> <img t-att-src='_s + "/web/static/src/img/down-arrow.png"' /></span> @@ -1079,10 +1076,10 @@ <t t-name="FieldOne2Many"> </t> <t t-name="FieldMany2Many"> - <div t-attf-class="oe_form_field_#{type}" t-att-id="widget.list_id"></div> + <div t-attf-class="oe_form_field_#{widget.type}" t-att-id="widget.list_id"></div> </t> <t t-name="FieldReference"> - <table t-attf-class="oe_form_field_#{type}" border="0" width="100%" cellpadding="0" cellspacing="0" class="oe_frame oe_forms"> + <table t-attf-class="oe_form_field_#{widget.type}" border="0" cellpadding="0" cellspacing="0" class="oe_frame oe_forms"> <tr> <td t-attf-class="oe_form_frame_cell oe_form_selection oe_form_view_reference_selection"> </td> @@ -1092,19 +1089,19 @@ </table> </t> <t t-name="FieldBoolean"> - <div t-attf-class="oe_form_field_#{type}"> + <div t-attf-class="oe_form_field_#{widget.type}"> <input type="checkbox" t-att-name="widget.name" t-attf-class="field_#{widget.type}"/> </div> </t> <t t-name="FieldProgressBar"> - <div t-attf-class="oe_form_field_#{type}" t-opentag="true"> + <div t-attf-class="oe_form_field_#{widget.type}" t-opentag="true"> <span></span> </div> </t> <t t-name="FieldBinaryImage"> - <table t-attf-class="oe_form_field_#{type}" cellpadding="0" cellspacing="0" border="0"> + <table t-attf-class="oe_form_field_#{widget.type}" cellpadding="0" cellspacing="0" border="0"> <tr> <td align="center"> <img t-att-src='_s + "/web/static/src/img/placeholder.png"' class="oe-binary-image" @@ -1153,13 +1150,13 @@ </table> </t> <t t-name="FieldBinaryFile"> - <table t-attf-class="oe_form_field_#{type}" cellpadding="0" cellspacing="0" border="0" width="100%"> + <table t-attf-class="oe_form_field_#{widget.type}" cellpadding="0" cellspacing="0" border="0"> <tr> - <td width="100%"> + <td> <input type="text" size="1" readonly="readonly" t-att-name="widget.name" t-att-id="widget.element_id + '_field'" - t-attf-class="field_#{widget.type}" style="width: 100%" + t-attf-class="field_#{widget.type}" /> </td> <td class="oe-binary" nowrap="true"> @@ -1203,7 +1200,7 @@ </table> </t> <t t-name="WidgetButton"> - <div t-attf-class="oe_form_field_#{type}"> + <div t-attf-class="oe_form_field_#{widget.type}"> <button type="button" class="oe_button"> <img t-if="widget.node.attrs.icon" t-att-src="_s + '/web/static/src/img/icons/' + widget.node.attrs.icon + '.png'" width="16" height="16"/> <span t-if="widget.string"><t t-esc="widget.string"/></span> |
