[FIX] web: settings_form_compiler, copy all attributes to the labels

Before this commit, the labels tags that were after the fields losses
their attributes (i.e. classes) after the compilation of the form view
arch.

Now, the attributes are correctly copied after the compilation.

similar to : 873790f802

X-original-commit: 395bdf8880c5929652838a93351596b045708905
Part-of: odoo/odoo#105315
Co-authored-by: Patrick Hoste <pko@odoo.com>
This commit is contained in:
Jorge Pinna Puissant
2022-11-08 14:40:15 +01:00
co-authored by Patrick Hoste
parent 57154abf8b
commit e42175c1d5
2 changed files with 29 additions and 1 deletions
@@ -177,7 +177,7 @@ export class SettingsFormCompiler extends FormCompiler {
{ selector: "h2", fn: compileSettingsGroupTitle },
{ selector: "h3.o_setting_tip", fn: compileSettingsGroupTip },
// search terms and highlight :
{ selector: "label", fn: compileLabel },
{ selector: "label", fn: compileLabel, doNotCopyAttributes: true },
{ selector: "span.o_form_label", fn: compileGenericLabel },
{ selector: "div.text-muted", fn: compileGenericLabel },
{ selector: "field", fn: compileField }
@@ -508,6 +508,34 @@ QUnit.module("SettingsFormView", (hooks) => {
await nextTick();
});
QUnit.test("correctly copy attributes to compiled labels", async function (assert) {
await makeView({
type: "form",
resModel: "res.config.settings",
serverData,
arch: `
<form string="Settings" js_class="base_settings">
<div class="settings">
<div class="app_settings_block" string="CRM" data-key="crm">
<div class="row mt16 o_settings_container">
<div class="col-12 col-lg-6 o_setting_box">
<div class="o_setting_left_pane">
<label for="foo" string="Label Before" class="a"/>
<field name="foo" class="b"/>
<label for="foo" string="Label After" class="c"/>
</div>
</div>
</div>
</div>
</div>
</form>`,
});
assert.hasClass(target.querySelectorAll(".o_form_label")[0], "a");
assert.hasClass(target.querySelector(".o_field_widget.o_field_boolean"), "b");
assert.hasClass(target.querySelectorAll(".o_form_label")[1], "c");
});
QUnit.test("settings views does not write the id on the url", async function (assert) {
serverData.actions = {
1: {