fix(front): only offer fields the role can edit in the bulk Update form

Merged
HA
2d ago
+56-4

Fixes #30367

Description

The bulk Update {objects} form (2+ records selected from the command menu) listed every field of the object, including fields the member's role is not allowed to edit or read. The member filled one in, submitted, and the server refused the update with no permission to write field "…" on "…".

The form now derives its fields from the object's readable and updatable fields, which already carry the role's field permissions, so it behaves like the single-record form.

Root cause

UpdateMultipleRecordsForm filtered objectMetadataItem.fields only with shouldDisplayFormMultiEditField, which checks field type and uniqueness — not the role's field permissions. useObjectMetadataItem already returns the enriched object with readableFields and updatableFields computed from the member's permissions (getPermittedFields), so the form can use them directly.

Fix

New getFieldsEditableInMultiEditForm util in record-update-multiple/utils:

  • keeps only fields present in both readableFields and updatableFields (the server accepts writing only updatable fields, and listing an unreadable field would let the member set a value they cannot see),
  • keeps the existing shouldDisplayFormMultiEditField type/uniqueness filtering and the alphabetical sort.

The command's availability (numberOfSelectedRecords >= 2 and objectPermissions.canUpdateObjectRecords) is unchanged: object-level permissions still gate the command, and field-level restrictions now gate the form.

Tests

New getFieldsEditableInMultiEditForm.test.ts:

  • only fields the member can both read and update are returned,
  • unique fields are excluded,
  • unrestricted roles keep all displayed fields, alphabetically sorted.

All 17 record-update-multiple tests pass; tsgo --noEmit typecheck and the diff lint on twenty-front are clean.