fix(tables): required-field check only enforces fields that are columns
The client-side required check was enforcing every field in the row schema's
`required` list — including ones with no table column (e.g. the risk register's
project/discipline/sequence tracking-number components, which are composed
server-side / set via the add-row form, not inline-editable). That blocked
saves naming fields the user can't fill in the grid ("Can't save — required:
party, project, discipline, sequence").
Now requiredFields() intersects `required` with the visible columns, so the
client only blocks on required fields the table can actually fill; non-column
required fields are left to the server (it composes them or returns a 422).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
8b690b782f
commit
af91916b58
1 changed files with 10 additions and 2 deletions
|
|
@ -132,10 +132,18 @@
|
|||
|
||||
// --- Required-field validation + inline row errors ----------------
|
||||
|
||||
// Field names the row schema marks required (form.yaml schema.required).
|
||||
// Required fields the table can actually enforce: the row schema's
|
||||
// `required` list intersected with the visible COLUMNS. Required fields
|
||||
// that aren't columns (e.g. the risk register's project/discipline/
|
||||
// sequence tracking-number components, composed server-side or set via the
|
||||
// add-row form) are NOT inline-fillable, so the client must not block on
|
||||
// them — the server validates those (and composes them) authoritatively.
|
||||
function requiredFields() {
|
||||
const ctx = app.context || {};
|
||||
return (ctx.rowSchema && Array.isArray(ctx.rowSchema.required)) ? ctx.rowSchema.required : [];
|
||||
const req = (ctx.rowSchema && Array.isArray(ctx.rowSchema.required)) ? ctx.rowSchema.required : [];
|
||||
const colFields = {};
|
||||
(ctx.columns || []).forEach(function (c) { if (c && c.field) colFields[c.field] = true; });
|
||||
return req.filter(function (f) { return colFields[f]; });
|
||||
}
|
||||
|
||||
// Human label for a field — the column title, else the field name.
|
||||
|
|
|
|||
Loading…
Reference in a new issue