Skip to content

Commit

Permalink
accepts array of ids when setting link_row fields
Browse files Browse the repository at this point in the history
  • Loading branch information
narthur committed Apr 9, 2024
1 parent be265a0 commit 50865f4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/codegen/makeClassMethods.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,4 +126,15 @@ describe("makeClassMethods", () => {
]),
).not.toContain("setTheFieldName");
});

it("accepts id array for link_row setters", () => {
expect(
makeClassMethods([
f({
name: "the_field_name",
type: "link_row",
}),
]),
).toContain("value: number[]");
});
});
6 changes: 6 additions & 0 deletions src/codegen/makeClassMethods.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ function makeGetter(field: FieldDefinition): string {
}

function makeSetter(field: FieldDefinition): string {
if (field.type === "link_row") {
return `public ${toCamelCase(`set ${field.name}`)}(value: number[]): Promise<void> {
return this.setField("${field.name}", value);
}`;
}

return `public ${toCamelCase(`set ${field.name}`)}(value: ${makeFieldType(
field,
)}): Promise<void> {
Expand Down

0 comments on commit 50865f4

Please sign in to comment.