forked from 1b-agent/fieldcraft-upstream
UI: a reference field is always a drop-down; with nothing to pick it offers Create …, and one candidate starts picked (#215)
A reference field (a material, set, step…) with no items was a free-text box; it is now a greyed
drop-down ("No materials yet") with a button that opens the command making one (the
collection's requirement provider). That form comes back to this one on OK, with the new item
picked, or as it was on Cancel. A required reference with one candidate, or with the browser's
selection of its kind, starts picked when the form opens, so the fields and the JSON view agree.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UhhZMBTviDQxZvwnyP89fo
This commit is contained in:
1 parent
29e7a4ca31
commit
6bfa0b410a
6 files changed
+224
-21
No files matched your search
@@ -9,6 +9,7 @@
|
||||
//! ATTRIBUTION.md.
|
||||
|
||||
use egui::{Color32, FontId, Pos2, Rect, RichText, Sense, Stroke, Vec2, pos2, vec2};
|
||||
use fieldcraft_engine::schema::Collection;
|
||||
use fieldcraft_model::Model;
|
||||
use serde::Serialize;
|
||||
use serde_json::{Value, json};
|
||||
@@ -39,6 +40,22 @@ pub enum Def {
|
||||
}
|
||||
|
||||
impl Def {
|
||||
/// The reference fields that name one of these.
|
||||
pub fn collection(self) -> Collection {
|
||||
match self {
|
||||
Def::Set => Collection::Set,
|
||||
Def::Material => Collection::Material,
|
||||
Def::Section => Collection::Section,
|
||||
Def::Step => Collection::Step,
|
||||
Def::BoundaryCondition => Collection::BoundaryCondition,
|
||||
Def::Load => Collection::Load,
|
||||
Def::ReferencePoint => Collection::ReferencePoint,
|
||||
Def::Coupling => Collection::Coupling,
|
||||
Def::Contact => Collection::Contact,
|
||||
Def::FluidDomain => Collection::FluidDomain,
|
||||
}
|
||||
}
|
||||
|
||||
/// The commands' stem: `model.<stem>.create|edit|delete`.
|
||||
pub fn stem(self) -> &'static str {
|
||||
match self {
|
||||
|
||||
Reference in new issue
Block a user