Skip to content

Commit

Permalink
fix: field domain should have priority over fields
Browse files Browse the repository at this point in the history
  • Loading branch information
mguellsegarra committed Oct 23, 2024
1 parent fa8eb75 commit 460ba28
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/Form.ts
Original file line number Diff line number Diff line change
Expand Up @@ -240,9 +240,9 @@ class Form {

if (checkIfDomainHasValue(tagAttributes.domain)) {
domain = tagAttributes.domain;
}

if (checkIfDomainHasValue(this._fields[tagAttributes.name]?.domain)) {
} else if (
checkIfDomainHasValue(this._fields[tagAttributes.name]?.domain)
) {
domain = this._fields[tagAttributes.name].domain;
}

Expand Down
21 changes: 21 additions & 0 deletions src/spec/Form.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5831,4 +5831,25 @@ describe("A Form", () => {
// expect(pageAutoconsum).toBeDefined();
// expect(pageAutoconsum.invisible).toBeTruthy();
// });
it("a domain defined in the xml should have priority over the domain defined in the fields", () => {
const fields = {
field_char: {
type: "char",
domain: "[('value', '=', 'field')]",
},
};
const xmlViewForm = `<?xml version="1.0"?>
<form string="Form1">
<field name="field_char" colspan="4" nolabel="1" domain="[('value', '=', 'form')]"/>
</form>`;
const form = new Form(fields);
form.parse(xmlViewForm, {
values: {
field_char: "test",
},
});

const field_char = form.findById("field_char");
expect(field_char!.domain!).toBe("[('value', '=', 'form')]");
});
});

0 comments on commit 460ba28

Please sign in to comment.