fix(tickets): flag every missing required field on new-ticket submit (PMS-514) #348

Merged
nrupard merged 1 commit from fix/PMS-514-ticket-form-validate-all-required into main 2026-06-25 18:42:19 +02:00
Owner

What

Fixes PMS-514: on the new-ticket form (TicketNewPage, src/pages/tickets.rs), submitting with both Title and Company empty surfaced only the company error; the empty title was not flagged.

Root cause

handle_submit parsed the company UUID first and returned immediately on failure, before the client-side title check ran. With the company missing, the early return prevented the POST, so the server never validated the blank title and the inline title_error slot stayed empty. The title was only ever flagged when the company was valid (the request reached the server, which rejected the blank title).

Fix

Validate both required fields up front and bail once, instead of short-circuiting on the company check:

  • Set title_error = "Title is required." when the trimmed title is empty.
  • Set the form-level error = "Please pick a company first." when the company UUID does not parse.
  • Bail (is_submitting.set(false); return;) without POSTing if either failed - company_uuid.filter(|_| !title_empty) is Some only when both pass, so the let Some(..) else fires if either field is invalid.

Both slots are set before the return, so missing-both renders both messages (title inline, company at the top). Reuses the form's existing "Title is required." wording (MAPPS-281) rather than the issue's suggested second wording, to avoid introducing two messages for the same condition. The server-side title validation stays as a backstop; a valid submit is unchanged.

Verification

just check parity via the rust-builder image: cargo clippy --all-targets -- -D warnings clean, cargo fmt --check clean, cargo check --target wasm32-unknown-unknown clean.

Behaviour walkthrough:

  • both empty -> title inline error + company top error, no POST
  • title empty, company valid -> title inline error, no POST
  • company empty, title present -> company top error, no POST
  • both present -> POST, toast, navigate to the created ticket (unchanged)

Docs

  • dev-docs/form-conventions.md: new "Required-field validation" section codifying the report-every-required-field convention for all create/edit forms.
  • YouTrack KB PMS-A-4 ("Mokosh form validation: the required-field 'report everything' convention") documents the convention and the PMS-515 gap.

Acceptance criteria

  • Submitting with both title and company empty shows BOTH the empty-title (inline) and the pick-a-company errors.
  • Submitting with only the title empty (company valid) still shows the title error.
  • Submitting with only the company empty (title present) still shows the company error.
  • A valid submission still creates the ticket and navigates to it, unchanged.
  • No POST is sent while any required field is invalid.
## What Fixes PMS-514: on the new-ticket form (`TicketNewPage`, `src/pages/tickets.rs`), submitting with both Title and Company empty surfaced only the company error; the empty title was not flagged. ## Root cause `handle_submit` parsed the company UUID first and `return`ed immediately on failure, before the client-side title check ran. With the company missing, the early return prevented the POST, so the server never validated the blank title and the inline `title_error` slot stayed empty. The title was only ever flagged when the company was valid (the request reached the server, which rejected the blank title). ## Fix Validate both required fields up front and bail once, instead of short-circuiting on the company check: - Set `title_error = "Title is required."` when the trimmed title is empty. - Set the form-level `error = "Please pick a company first."` when the company UUID does not parse. - Bail (`is_submitting.set(false); return;`) without POSTing if either failed - `company_uuid.filter(|_| !title_empty)` is `Some` only when both pass, so the `let Some(..) else` fires if either field is invalid. Both slots are set before the return, so missing-both renders both messages (title inline, company at the top). Reuses the form's existing `"Title is required."` wording (MAPPS-281) rather than the issue's suggested second wording, to avoid introducing two messages for the same condition. The server-side title validation stays as a backstop; a valid submit is unchanged. ## Verification `just check` parity via the rust-builder image: `cargo clippy --all-targets -- -D warnings` clean, `cargo fmt --check` clean, `cargo check --target wasm32-unknown-unknown` clean. Behaviour walkthrough: - both empty -> title inline error + company top error, no POST - title empty, company valid -> title inline error, no POST - company empty, title present -> company top error, no POST - both present -> POST, toast, navigate to the created ticket (unchanged) ## Docs - `dev-docs/form-conventions.md`: new "Required-field validation" section codifying the report-every-required-field convention for all create/edit forms. - YouTrack KB `PMS-A-4` ("Mokosh form validation: the required-field 'report everything' convention") documents the convention and the PMS-515 gap. ## Acceptance criteria - [x] Submitting with both title and company empty shows BOTH the empty-title (inline) and the pick-a-company errors. - [x] Submitting with only the title empty (company valid) still shows the title error. - [x] Submitting with only the company empty (title present) still shows the company error. - [x] A valid submission still creates the ticket and navigates to it, unchanged. - [x] No POST is sent while any required field is invalid.
fix(tickets): flag every missing required field on new-ticket submit
All checks were successful
Check / fmt + clippy + tests (pull_request) Successful in 1m21s
Create release / Create release from merged PR (pull_request) Has been skipped
5c5e8fdf7e
handle_submit validated the company UUID first and returned immediately on failure, before the title was ever checked client-side. Submitting the new-ticket form with both title and company empty therefore surfaced only "Please pick a company first."; the empty title went unflagged, because the early return prevented the POST and the title was only ever validated by the server.

Validate both required fields up front: set title_error when the trimmed title is empty and the form-level error when the company UUID does not parse, then bail once (without POSTing) if either failed. Both error slots are set before the return, so missing-both now renders both messages. Reuses the form's existing "Title is required." message (MAPPS-281) rather than introducing a second wording, and keeps the server-side title validation as a backstop. No behaviour change for a valid submit.

Document the report-every-required-field convention in dev-docs/form-conventions.md so other create/edit forms follow the same pattern (relates to the PMS-515 validation-unification epic).

#PMS-514
nrupard deleted branch fix/PMS-514-ticket-form-validate-all-required 2026-06-25 18:42:19 +02:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
psa-systems/mokosh-apps!348
No description provided.