diff options
| author | qsm-odoo <qsm@odoo.com> | 2017-09-29 12:52:36 +0200 |
|---|---|---|
| committer | qsm-odoo <qsm@odoo.com> | 2017-09-29 13:40:25 +0200 |
| commit | a2da1df78ed359de318ade08169db7d088ce722b (patch) | |
| tree | 52d1701a14b9d9dfa462d343e356d188a6599cd2 | |
| parent | 2fcb780a01823468bf8062f8df09d8b89b957659 (diff) | |
[FIX] web, portal: checkbox rendering
This reverts commit b94939377a7dee66f7860f4ef9e59be85cccf2ba.
The commit was breaking most of the backend checkboxes trying to fix a
frontend one.
On top of the revert, this commit adds frontend-only style to fix the
frontend checkboxes.
| -rw-r--r-- | addons/portal/static/src/less/website.ui.less | 9 | ||||
| -rw-r--r-- | addons/web/static/src/js/core/dom.js | 10 | ||||
| -rw-r--r-- | addons/web/static/src/less/webclient_extra.less | 13 | ||||
| -rw-r--r-- | addons/web/static/tests/views/form_tests.js | 8 |
4 files changed, 20 insertions, 20 deletions
diff --git a/addons/portal/static/src/less/website.ui.less b/addons/portal/static/src/less/website.ui.less index c4b57e018bf..d5f508d18a5 100644 --- a/addons/portal/static/src/less/website.ui.less +++ b/addons/portal/static/src/less/website.ui.less @@ -64,3 +64,12 @@ body.o_connected_user { } } } + +// TODO should be a common backend/frontend style +div.o_checkbox { + display: inline-block; + vertical-align: sub; + > input + span { + display: none; + } +} diff --git a/addons/web/static/src/js/core/dom.js b/addons/web/static/src/js/core/dom.js index da125aa72af..6ca13f18e4e 100644 --- a/addons/web/static/src/js/core/dom.js +++ b/addons/web/static/src/js/core/dom.js @@ -265,19 +265,19 @@ return { * @returns {jQuery} */ renderCheckbox: function (options) { - var $container = $('<div class="checkbox o_checkbox"><label><input type="checkbox"/><span/></label></div>'); + var $container = $('<div class="o_checkbox"><input type="checkbox"/><span/></div>'); if (options && options.prop) { - $container.find('input').prop(options.prop); + $container.children('input').prop(options.prop); } if (options && options.text) { - $container.find('label').append( + $container = $('<label/>').append( + $container, $('<span/>', { + class: 'ml8', text: options.text, - class: 'o_checkbox_label', }) ); } - return $container; }, /** diff --git a/addons/web/static/src/less/webclient_extra.less b/addons/web/static/src/less/webclient_extra.less index 2f4e03e9479..7c337352618 100644 --- a/addons/web/static/src/less/webclient_extra.less +++ b/addons/web/static/src/less/webclient_extra.less @@ -4,17 +4,8 @@ div.o_checkbox { display: inline-block; vertical-align: sub; - margin-top: 0px; - margin-bottom: 0px; - input[type="checkbox"] { - position: inherit; - margin-left: 0; - } - > label { - padding-left: 0px; - > input + span { - display: none; - } + > input + span { + display: none; } } diff --git a/addons/web/static/tests/views/form_tests.js b/addons/web/static/tests/views/form_tests.js index 16370559aad..6a3fdb0fbea 100644 --- a/addons/web/static/tests/views/form_tests.js +++ b/addons/web/static/tests/views/form_tests.js @@ -1741,10 +1741,10 @@ QUnit.module('Views', { res_id: 1, }); - assert.strictEqual(form.$("label:not(.o_checkbox label)").length, 2, "should have rendered only two label"); - assert.strictEqual(form.$("label:not(.o_checkbox label)").first().text(), "Product", + assert.strictEqual(form.$("label").length, 2, "should have rendered only two label"); + assert.strictEqual(form.$("label").first().text(), "Product", "one should be the one for the product field"); - assert.strictEqual(form.$("label:not(.o_checkbox label)").eq(1).text(), "Bar", + assert.strictEqual(form.$("label").eq(1).text(), "Bar", "one should be the one for the bar field"); assert.strictEqual(form.$('.firstgroup td').first().attr('colspan'), undefined, @@ -3787,7 +3787,7 @@ QUnit.module('Views', { "button box should contain two children"); assert.strictEqual(form.$('.oe_button_box .oe_stat_button').length, 1, "button box should only contain one button"); - assert.strictEqual(form.$('.oe_button_box label:not(.o_checkbox label)').length, 1, + assert.strictEqual(form.$('.oe_button_box label').length, 1, "button box should only contain one label"); form.destroy(); |
