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
@@ -118,6 +118,7 @@ fn form(app: &mut ModelApp, ui: &mut egui::Ui, t: &Tokens) {
|
||||
}
|
||||
});
|
||||
let mut invalid = 0;
|
||||
let mut create = None;
|
||||
// The typed fields edit the JSON text's object; text that is not an object stays in the
|
||||
// JSON view until it is.
|
||||
let object = params.as_object().cloned();
|
||||
@@ -135,6 +136,7 @@ fn form(app: &mut ModelApp, ui: &mut egui::Ui, t: &Tokens) {
|
||||
let cx = crate::form::Context { units, names: &|c| session.names(c), salt: form_id };
|
||||
let out = crate::form::show(ui, t, &cx, fields, &mut obj);
|
||||
invalid = out.invalid;
|
||||
create = out.create;
|
||||
if out.changed {
|
||||
d.text = Value::Object(obj).to_string();
|
||||
d.error = None;
|
||||
@@ -167,7 +169,9 @@ fn form(app: &mut ModelApp, ui: &mut egui::Ui, t: &Tokens) {
|
||||
cancel = true;
|
||||
}
|
||||
if cancel {
|
||||
app.dialog = None;
|
||||
app.close_dialog();
|
||||
} else if let Some((collection, path)) = create {
|
||||
app.create_from_form(collection, path);
|
||||
} else if run {
|
||||
app.submit_dialog();
|
||||
} else if use_selection
|
||||
|
||||
Reference in new issue
Block a user