Guard and preserve behavior forms across document lifecycle
This commit is contained in:
@@ -14,10 +14,10 @@ use iced::{
|
||||
};
|
||||
use oa_core::*;
|
||||
use std::collections::BTreeMap;
|
||||
mod scenario;
|
||||
pub(crate) mod scenario;
|
||||
mod state_scene;
|
||||
mod states;
|
||||
mod topology;
|
||||
pub(crate) mod states;
|
||||
pub(crate) mod topology;
|
||||
#[derive(Debug, Clone)]
|
||||
pub enum Event {
|
||||
Topology(topology::Event),
|
||||
@@ -26,6 +26,13 @@ pub enum Event {
|
||||
Submit,
|
||||
}
|
||||
impl Event {
|
||||
pub fn starts_form(&self) -> bool {
|
||||
matches!(self,
|
||||
Self::Topology(topology::Event::Start(..))
|
||||
| Self::Scenario(scenario::Event::Start(..))
|
||||
| Self::States(states::Event::Start(..) | states::Event::Edit(..))
|
||||
)
|
||||
}
|
||||
pub fn is_submit(&self) -> bool {
|
||||
matches!(
|
||||
self,
|
||||
@@ -123,7 +130,7 @@ pub fn view(app: &App) -> Element<'_, Message> {
|
||||
label: format!("{} · {}", e.kind(), e.name),
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
let owner = selected_behavior(p, app.selected);
|
||||
let owner = app.behavior.pending_owner().or_else(|| selected_behavior(p, app.selected));
|
||||
let selected = owner
|
||||
.and_then(|id| choices.iter().find(|c| c.id == id))
|
||||
.or(choices.first())
|
||||
|
||||
Reference in New Issue
Block a user