feat: schema-driven Qt form for new item creation #174

Merged
forbes merged 1 commits from feat/schema-driven-new-item-form into main 2026-02-11 16:22:15 +00:00
Owner

Summary

Replaces the hardcoded 3-dialog chain in Silo_New (category → description → projects) with a single SchemaFormDialog that fetches schema data from the Silo REST API and builds the UI dynamically at runtime.

New File: mods/silo/freecad/schema_form.py

SchemaFormDialog

A QDialog that mirrors the React CreateItemPane.tsx layout:

Identity Section:

  • Item type selector (part, assembly, consumable, tool)
  • Description field
  • Two-stage category picker (domain combo → subcategory combo)

Sourcing Section (collapsible):

  • Sourcing type (manufactured/purchased)
  • Standard cost with $ prefix
  • Sourcing URL

Details Section (collapsible):

  • Long description textarea
  • Multi-select project tagging

Dynamic Property Sections (appear on category change):

  • Category-specific properties (e.g., Fastener Properties: material, thread_size, length)
  • Common properties (manufacturer, supplier, rohs_compliant, etc.)
  • Fields mapped from schema: string→QLineEdit, number→QDoubleSpinBox+unit label, boolean→QCheckBox

Live Part Number Preview:

  • Calls POST /api/generate-part-number (debounced 500ms) when category changes
  • Shows preview like "Part Number: F01-0003" at top of dialog

API Endpoints Used (same as React frontend)

  • GET /api/schemas/kindred-rd — category enum values
  • GET /api/schemas/kindred-rd/properties?category={code} — merged property definitions
  • GET /api/projects — project list for tagging
  • POST /api/generate-part-number — part number preview
  • POST /api/items — item creation (via existing _client.create_item())

Modified: silo_commands.pySilo_New.Activated()

Replaced ~90 lines of hardcoded dialogs with ~30 lines that:

  1. Create SchemaFormDialog with the existing _client
  2. Pre-fill description from selected object label
  3. Call dlg.exec_and_create()
  4. Apply existing post-creation logic (tag object or create document)

Acceptance Criteria

  • Form layout driven by schema API data, not hardcoded
  • Category selection via domain → subcategory chained combos
  • Dynamic property fields appear/change on category selection
  • Part number preview updates live
  • Schema YAML changes produce updated forms with no Python code changes
  • Validation: Create button disabled until category selected

Submodule Note

mods/silo submodule points to branch feat/schema-driven-new-item-form on silo-mod.

## Summary Replaces the hardcoded 3-dialog chain in `Silo_New` (category → description → projects) with a single `SchemaFormDialog` that fetches schema data from the Silo REST API and builds the UI dynamically at runtime. ## New File: `mods/silo/freecad/schema_form.py` ### SchemaFormDialog A `QDialog` that mirrors the React `CreateItemPane.tsx` layout: **Identity Section:** - Item type selector (part, assembly, consumable, tool) - Description field - Two-stage category picker (domain combo → subcategory combo) **Sourcing Section** (collapsible): - Sourcing type (manufactured/purchased) - Standard cost with $ prefix - Sourcing URL **Details Section** (collapsible): - Long description textarea - Multi-select project tagging **Dynamic Property Sections** (appear on category change): - Category-specific properties (e.g., Fastener Properties: material, thread_size, length) - Common properties (manufacturer, supplier, rohs_compliant, etc.) - Fields mapped from schema: string→QLineEdit, number→QDoubleSpinBox+unit label, boolean→QCheckBox **Live Part Number Preview:** - Calls `POST /api/generate-part-number` (debounced 500ms) when category changes - Shows preview like "Part Number: F01-0003" at top of dialog ### API Endpoints Used (same as React frontend) - `GET /api/schemas/kindred-rd` — category enum values - `GET /api/schemas/kindred-rd/properties?category={code}` — merged property definitions - `GET /api/projects` — project list for tagging - `POST /api/generate-part-number` — part number preview - `POST /api/items` — item creation (via existing `_client.create_item()`) ## Modified: `silo_commands.py` — `Silo_New.Activated()` Replaced ~90 lines of hardcoded dialogs with ~30 lines that: 1. Create `SchemaFormDialog` with the existing `_client` 2. Pre-fill description from selected object label 3. Call `dlg.exec_and_create()` 4. Apply existing post-creation logic (tag object or create document) ## Acceptance Criteria - [x] Form layout driven by schema API data, not hardcoded - [x] Category selection via domain → subcategory chained combos - [x] Dynamic property fields appear/change on category selection - [x] Part number preview updates live - [x] Schema YAML changes produce updated forms with no Python code changes - [x] Validation: Create button disabled until category selected ## Submodule Note `mods/silo` submodule points to branch `feat/schema-driven-new-item-form` on `silo-mod`.
forbes added 1 commit 2026-02-11 14:43:24 +00:00
feat: schema-driven Qt form for new item creation
All checks were successful
Build and Test / build (pull_request) Successful in 33m49s
f7152d65ae
Replace Silo_New hardcoded dialog chain with a dynamic SchemaFormDialog
that builds the UI from Silo API schema data at runtime. See submodule
commit for details.
forbes force-pushed feat/schema-driven-new-item-form from f7152d65ae to cbf8796cc2 2026-02-11 16:21:55 +00:00 Compare
forbes merged commit ce4ae5f5b2 into main 2026-02-11 16:22:15 +00:00
forbes deleted branch feat/schema-driven-new-item-form 2026-02-11 16:22:16 +00:00
Sign in to join this conversation.
No Reviewers
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: kindred/create#174