80 lines
3.0 KiB
Rust
80 lines
3.0 KiB
Rust
//! Explicit attachment pair and final destination field controls.
|
|
use super::{
|
|
attachments::{Editor, Event, Family},
|
|
*,
|
|
};
|
|
use iced::{
|
|
Element as View, Fill,
|
|
widget::{button, column, pick_list, row, text, text_input},
|
|
};
|
|
|
|
pub(super) fn pairs<'a>(
|
|
editor: &'a Editor,
|
|
project: &'a Project,
|
|
trace: &'a Trace,
|
|
) -> View<'a, Event> {
|
|
let mut content = column![
|
|
text("Existing children and relationship endpoints").size(16),
|
|
text("Choose explicit Operational and System identities. A child's final parent or a relationship's final endpoint is reviewed independently; opening another trace keeps this draft.").size(12),
|
|
pick_list([Family::Child, Family::Source, Family::Target], Some(editor.family), Event::Family).text_size(12).padding(7).width(Fill),
|
|
text_input("Filter attachment identities by name or alias", &editor.search).on_input(Event::Search).size(12).padding(7),
|
|
].spacing(9);
|
|
for layer in [Layer::Oa, Layer::Sa] {
|
|
let label = if layer == Layer::Oa {
|
|
"Operational"
|
|
} else {
|
|
"System"
|
|
};
|
|
let owner = if layer == Layer::Oa {
|
|
trace.oa
|
|
} else {
|
|
trace.sa
|
|
};
|
|
content = content.push(text(format!("{label} owner: {}", project.named(owner))).size(12));
|
|
content = content.push(
|
|
row![
|
|
pick_list(
|
|
editor.choices(project, trace, layer),
|
|
editor.selection(layer).cloned(),
|
|
move |choice| Event::Pick(layer, Some(choice))
|
|
)
|
|
.placeholder(format!("Choose an existing {label} identity"))
|
|
.text_size(12)
|
|
.padding(7)
|
|
.width(Fill),
|
|
button(text("No identity on this side").size(11))
|
|
.style(crate::style::nav)
|
|
.padding(7)
|
|
.on_press(Event::Pick(layer, None)),
|
|
]
|
|
.spacing(7),
|
|
);
|
|
}
|
|
content = content.push(
|
|
button(text("Use exact attachment pair").size(12))
|
|
.padding(8)
|
|
.style(crate::style::nav)
|
|
.on_press(Event::Stage),
|
|
);
|
|
content.push(text("Taking an absent relationship endpoint requires an explicit final replacement. New child and relationship creation uses a separate explicit transition mapping.").size(11)).padding(iced::Padding::default().right(18)).into()
|
|
}
|
|
|
|
pub(super) fn candidate<'a>(
|
|
editor: &'a Editor,
|
|
project: &'a Project,
|
|
facet: &'a FacetSelector,
|
|
layer: Layer,
|
|
) -> Option<View<'a, Message>> {
|
|
let draft = editor.drafts.get(facet)?;
|
|
let (id, _) = attachments::actual_slot(facet, layer)?;
|
|
let path = attachments::path(project, facet, layer)?;
|
|
Some(
|
|
column![
|
|
text(format!("Destination record: {}", project.named(id))).size(12),
|
|
crate::forms::scoped(draft, project, &path, attachments::label(facet)),
|
|
]
|
|
.spacing(7)
|
|
.into(),
|
|
)
|
|
}
|