feat(web): create new orders (MO/PO/DO) with FK pickers — finish Phase 3 CRUD#25
Open
dnplkndll wants to merge 2 commits into
Open
feat(web): create new orders (MO/PO/DO) with FK pickers — finish Phase 3 CRUD#25dnplkndll wants to merge 2 commits into
dnplkndll wants to merge 2 commits into
Conversation
…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).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
proposed).How it's wired
lib/records.ts— a genericCreateFieldtype (text/number/date/select/fk), kept next toColumnsoRecordTablestays generic.lib/orders.ts— per-tabcreateconfig;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;fkfields 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.TabListScreen—creatablewiring (toast + reload), mirroring the editable path.globals.css— create-form styling in the planning-console design system.Validation
tsc --noEmitclean; 78 vitest tests pass (+5 forbuildCreateBody+ the create config shape); productionnext buildsucceeds.(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):
Purchase order — create (item + supplier + location pickers):
Self-review pass (2nd commit)
RecordTableleaked 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'soperationin the draft. Now remounts per tab (key={tabKey}).fkOptionsFromRowsand unit-tested it (name/reference → sorted, de-duped); notedfetchFkOptionsreads only the first DRF page (server-side search is a follow-on).aria-requiredon required create inputs.