diff --git a/tables/js/save.js b/tables/js/save.js index 517a80b..1ea4fd1 100644 --- a/tables/js/save.js +++ b/tables/js/save.js @@ -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.