Skip to content

feat(web): create new orders (MO/PO/DO) with FK pickers — finish Phase 3 CRUD#25

Open
dnplkndll wants to merge 2 commits into
modernizationfrom
phase3-order-create
Open

feat(web): create new orders (MO/PO/DO) with FK pickers — finish Phase 3 CRUD#25
dnplkndll wants to merge 2 commits into
modernizationfrom
phase3-order-create

Conversation

@dnplkndll

@dnplkndll dnplkndll commented Jul 7, 2026

Copy link
Copy Markdown

What changed

Adds a "+ New" order form to the Orders screen, completing Phase 3 CRUD (the create half — edit/delete already shipped in #11).

Each order type gets the right fields with foreign-key pickers sourced live from the input API:

  • MO → operation · PO → item + supplier + location · DO → item + origin + destination
  • shared: reference (optional — the engine auto-assigns when blank), quantity (required), end date, status (defaults to proposed).

How it's wired

  • lib/records.ts — a generic CreateField type (text/number/date/select/fk), kept next to Column so RecordTable stays generic.
  • lib/orders.ts — per-tab create config; createOrder (POST, surfaces the DRF validation body on error), buildCreateBody (drops blanks, normalises dates, defaults status), fetchFkOptions (loads a FK's natural keys, sorted/deduped).
  • RecordTable — a create form; fk fields use a <datalist> type-ahead loaded when the form opens, degrading to free text if options can't load; the Create button is guarded on required fields.
  • TabListScreencreatable wiring (toast + reload), mirroring the editable path.
  • globals.css — create-form styling in the planning-console design system.

Validation

  • Frontend tsc --noEmit clean; 78 vitest tests pass (+5 for buildCreateBody + the create config shape); production next build succeeds.

(Screenshots below — captured against the built app with the API route-mocked.)

No secrets/backend needed for the shots. Per convention, not auto-merging.

Screenshots

Manufacturing order — create (operation picker + qty/date/status):

MO create

Purchase order — create (item + supplier + location pickers):

PO create


Self-review pass (2nd commit)

  • Bug fixed: RecordTable leaked internal state (open create form + draft, edit, filter) across tab switches — open MO's create form, switch to Purchase, and it stayed open with MO's operation in the draft. Now remounts per tab (key={tabKey}).
  • Coverage: extracted the FK option parsing into a pure fkOptionsFromRows and unit-tested it (name/reference → sorted, de-duped); noted fetchFkOptions reads only the first DRF page (server-side search is a follow-on).
  • a11y: aria-required on required create inputs.
  • Typecheck clean; 80 vitest tests pass. Screenshots unchanged (fixes are behavioral/a11y, not visual).

dnplkndll added 2 commits July 7, 2026 14:35
…e 3 CRUD

Add a "+ New" order form to the Orders screen, completing Phase 3 CRUD
(create/edit/delete). Each order type gets the right fields with foreign-key
pickers sourced from the input API:
- MO: operation; PO: item + supplier + location; DO: item + origin + destination
- shared: reference (optional — engine auto-assigns when blank), quantity
  (required), end date, status (defaults to proposed).

- lib/records.ts: a generic `CreateField` type (kind text/number/date/select/fk).
- lib/orders.ts: per-tab `create` field config; `createOrder` (POST, surfaces the
  DRF validation body on error), `buildCreateBody` (drops blanks, normalises dates,
  defaults status), `fetchFkOptions` (loads a FK's natural keys).
- RecordTable: a create form with per-field inputs; fk fields use a <datalist>
  type-ahead loaded on open, degrading to free text if options can't load;
  required-field guard on the Create button.
- TabListScreen: `creatable` wiring (toast + reload), mirroring the editable path.
- globals.css: create-form styling in the planning-console design system.

Frontend typecheck clean; 78 vitest tests pass (+5 for buildCreateBody + the
create config); production build succeeds.
Self-review of the Order Create branch:
- Bug: RecordTable kept its internal state (open create form + draft, per-row
  edit, filter) across tab switches, so opening MO's create form then switching
  to Purchase left the form open with MO's `operation` in the draft. Remount the
  table per tab (`key={tabKey}`) so each order type starts clean.
- Coverage: extract the FK option parsing (name/reference -> sorted, de-duped)
  from fetchFkOptions into a pure `fkOptionsFromRows`, and unit-test it (no fetch
  mock needed). Note the first-page pagination limitation on fetchFkOptions.
- a11y: mark required create-form inputs with aria-required.

Frontend typecheck clean; 80 vitest tests pass (+2).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant