Skip to content

Commit

Permalink
Merge pull request #14720 from Budibase/allow-calculation-fields-to-h…
Browse files Browse the repository at this point in the history
…ide-required-fields

Allow calculation views to hide required fields.
  • Loading branch information
samwho authored Oct 8, 2024
2 parents 7d6c32b + 1106244 commit ca8ed4f
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
20 changes: 20 additions & 0 deletions packages/server/src/api/routes/tests/viewV2.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1071,6 +1071,26 @@ describe.each([
)
})

it("can add a new group by field that is invisible, even if required on the table", async () => {
view.schema!.name = { visible: false }
await config.api.viewV2.update(view)

const { rows } = await config.api.row.search(view.id)
expect(rows).toHaveLength(2)
expect(rows).toEqual(
expect.arrayContaining([
{
country: "USA",
age: 65,
},
{
country: "UK",
age: 61,
},
])
)
})

it("can add a new calculation field", async () => {
view.schema!.count = {
visible: true,
Expand Down
6 changes: 5 additions & 1 deletion packages/server/src/sdk/app/views/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,11 @@ async function guardViewSchema(
}

await checkReadonlyFields(table, view)
checkRequiredFields(table, view)

if (!helpers.views.isCalculationView(view)) {
checkRequiredFields(table, view)
}

checkDisplayField(view)
}

Expand Down

0 comments on commit ca8ed4f

Please sign in to comment.