Skip to content

Commit

Permalink
Merge branch 'fix/domain-xml-has-priority-over-fields' into alpha
Browse files Browse the repository at this point in the history
  • Loading branch information
mguellsegarra committed Oct 23, 2024
2 parents df60f7e + 460ba28 commit 7ad7086
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 @@ -5954,4 +5954,25 @@ describe("A Form", () => {
expect(but7.readOnly).toBeTruthy();
expect(but8.readOnly).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 7ad7086

Please sign in to comment.