feat: schema-driven form descriptor API and dynamic form rendering
- Add ui section to kindred-rd.yaml with category_picker (multi-stage),
item_fields, field_groups, category_field_groups, and field_overrides
- Add UIConfig structs to Go schema parser with full YAML/JSON tags
- Add ValidateUI() to validate field references against property schemas
- Add ValuesByDomain() helper to auto-derive subcategory picker stages
- Implement GET /api/schemas/{name}/form endpoint that returns resolved
form descriptor with field metadata, widget hints, and category picker
- Replace GET /api/schemas/{name}/properties route with /form
- Add FormDescriptor TypeScript types
- Create useFormDescriptor hook (replaces useCategories)
- Rewrite CreateItemPane to render all sections dynamically from descriptor
- Update CategoryPicker with multi-stage domain/subcategory selection
- Delete useCategories.ts (superseded by useFormDescriptor)
This commit is contained in:
@@ -846,3 +846,255 @@ schema:
|
||||
type: string
|
||||
default: ""
|
||||
description: "Inspection/QC requirements"
|
||||
|
||||
# UI configuration — drives form rendering for all clients.
|
||||
ui:
|
||||
category_picker:
|
||||
style: multi_stage
|
||||
stages:
|
||||
- name: domain
|
||||
label: "Domain"
|
||||
values:
|
||||
F: "Fasteners"
|
||||
C: "Fluid Fittings"
|
||||
R: "Motion"
|
||||
S: "Structural"
|
||||
E: "Electrical"
|
||||
M: "Mechanical"
|
||||
T: "Tooling"
|
||||
A: "Assemblies"
|
||||
P: "Purchased"
|
||||
X: "Custom Fabricated"
|
||||
|
||||
# Item-level fields (stored on items table, not in revision properties)
|
||||
item_fields:
|
||||
description:
|
||||
type: string
|
||||
widget: text
|
||||
label: "Description"
|
||||
item_type:
|
||||
type: string
|
||||
widget: select
|
||||
label: "Type"
|
||||
options: [part, assembly, consumable, tool]
|
||||
derived_from_category:
|
||||
A: assembly
|
||||
T: tool
|
||||
default: part
|
||||
sourcing_type:
|
||||
type: string
|
||||
widget: select
|
||||
label: "Sourcing Type"
|
||||
options: [manufactured, purchased]
|
||||
default: manufactured
|
||||
long_description:
|
||||
type: string
|
||||
widget: textarea
|
||||
label: "Long Description"
|
||||
projects:
|
||||
type: string_array
|
||||
widget: tag_input
|
||||
label: "Projects"
|
||||
search_endpoint: "/api/projects"
|
||||
|
||||
field_groups:
|
||||
identity:
|
||||
label: "Identity"
|
||||
order: 1
|
||||
fields: [item_type, description]
|
||||
sourcing:
|
||||
label: "Sourcing"
|
||||
order: 2
|
||||
fields:
|
||||
[
|
||||
sourcing_type,
|
||||
manufacturer,
|
||||
manufacturer_pn,
|
||||
supplier,
|
||||
supplier_pn,
|
||||
sourcing_link,
|
||||
]
|
||||
cost:
|
||||
label: "Cost & Lead Time"
|
||||
order: 3
|
||||
fields: [standard_cost, lead_time_days, minimum_order_qty]
|
||||
status:
|
||||
label: "Status"
|
||||
order: 4
|
||||
fields: [lifecycle_status, rohs_compliant, country_of_origin]
|
||||
details:
|
||||
label: "Details"
|
||||
order: 5
|
||||
fields: [long_description, projects, notes]
|
||||
|
||||
# Per-category-prefix field groups (rendered after global groups)
|
||||
category_field_groups:
|
||||
F:
|
||||
fastener_specs:
|
||||
label: "Fastener Specifications"
|
||||
order: 10
|
||||
fields:
|
||||
[
|
||||
material,
|
||||
finish,
|
||||
thread_size,
|
||||
thread_pitch,
|
||||
length,
|
||||
head_type,
|
||||
drive_type,
|
||||
strength_grade,
|
||||
torque_spec,
|
||||
]
|
||||
C:
|
||||
fitting_specs:
|
||||
label: "Fitting Specifications"
|
||||
order: 10
|
||||
fields:
|
||||
[
|
||||
material,
|
||||
connection_type,
|
||||
size_1,
|
||||
size_2,
|
||||
pressure_rating,
|
||||
temperature_min,
|
||||
temperature_max,
|
||||
media_compatibility,
|
||||
seal_material,
|
||||
]
|
||||
R:
|
||||
motion_specs:
|
||||
label: "Motion Specifications"
|
||||
order: 10
|
||||
fields:
|
||||
[
|
||||
load_capacity,
|
||||
speed_rating,
|
||||
power_rating,
|
||||
voltage_nominal,
|
||||
current_nominal,
|
||||
torque_continuous,
|
||||
bore_diameter,
|
||||
travel,
|
||||
stroke,
|
||||
operating_pressure,
|
||||
]
|
||||
S:
|
||||
structural_specs:
|
||||
label: "Structural Specifications"
|
||||
order: 10
|
||||
fields:
|
||||
[
|
||||
material,
|
||||
material_spec,
|
||||
profile,
|
||||
dimension_a,
|
||||
dimension_b,
|
||||
wall_thickness,
|
||||
length,
|
||||
weight_per_length,
|
||||
finish,
|
||||
temper,
|
||||
]
|
||||
E:
|
||||
electrical_specs:
|
||||
label: "Electrical Specifications"
|
||||
order: 10
|
||||
fields:
|
||||
[
|
||||
voltage_rating,
|
||||
current_rating,
|
||||
power_rating,
|
||||
value,
|
||||
tolerance,
|
||||
package,
|
||||
mounting,
|
||||
pin_count,
|
||||
wire_gauge,
|
||||
connector_type,
|
||||
]
|
||||
M:
|
||||
mechanical_specs:
|
||||
label: "Mechanical Specifications"
|
||||
order: 10
|
||||
fields:
|
||||
[
|
||||
material,
|
||||
spring_rate,
|
||||
free_length,
|
||||
max_load,
|
||||
travel,
|
||||
inner_diameter,
|
||||
outer_diameter,
|
||||
hardness,
|
||||
temperature_range,
|
||||
]
|
||||
T:
|
||||
tooling_specs:
|
||||
label: "Tooling Specifications"
|
||||
order: 10
|
||||
fields:
|
||||
[
|
||||
material,
|
||||
tolerance,
|
||||
surface_finish,
|
||||
hardness,
|
||||
associated_part,
|
||||
machine,
|
||||
cycle_life,
|
||||
]
|
||||
A:
|
||||
assembly_specs:
|
||||
label: "Assembly Specifications"
|
||||
order: 10
|
||||
fields:
|
||||
[
|
||||
weight,
|
||||
dimensions,
|
||||
component_count,
|
||||
assembly_time,
|
||||
test_procedure,
|
||||
voltage_rating,
|
||||
current_rating,
|
||||
ip_rating,
|
||||
]
|
||||
P:
|
||||
purchased_specs:
|
||||
label: "Purchased Item Specifications"
|
||||
order: 10
|
||||
fields:
|
||||
[
|
||||
material,
|
||||
form,
|
||||
grade,
|
||||
quantity_per_unit,
|
||||
unit_of_measure,
|
||||
shelf_life,
|
||||
]
|
||||
X:
|
||||
fabrication_specs:
|
||||
label: "Fabrication Specifications"
|
||||
order: 10
|
||||
fields:
|
||||
[
|
||||
material,
|
||||
material_spec,
|
||||
finish,
|
||||
critical_dimensions,
|
||||
weight,
|
||||
process,
|
||||
secondary_operations,
|
||||
drawing_rev,
|
||||
inspection_requirements,
|
||||
]
|
||||
|
||||
field_overrides:
|
||||
standard_cost:
|
||||
widget: currency
|
||||
currency: USD
|
||||
sourcing_link:
|
||||
widget: url
|
||||
lifecycle_status:
|
||||
widget: select
|
||||
options: [active, deprecated, obsolete, prototype]
|
||||
rohs_compliant:
|
||||
widget: checkbox
|
||||
|
||||
Reference in New Issue
Block a user