Outline: show constraint details
This commit is contained in:
parent
7709c61f71
commit
fc85d15f83
3 changed files with 35 additions and 5 deletions
|
|
@ -4,6 +4,12 @@ use web_sys::{Element, KeyboardEvent, MouseEvent, wasm_bindgen::JsCast};
|
|||
|
||||
use crate::AppState;
|
||||
|
||||
// this component lists the elements of the assembly, showing the constraints
|
||||
// on each element as a collapsible sub-list. its implementation is based on
|
||||
// Kate Morley's HTML + CSS tree views:
|
||||
//
|
||||
// https://iamkate.com/code/tree-views/
|
||||
//
|
||||
#[component]
|
||||
pub fn Outline() -> View {
|
||||
// sort the elements alphabetically by ID
|
||||
|
|
@ -118,9 +124,21 @@ pub fn Outline() -> View {
|
|||
ul(class="constraints") {
|
||||
Keyed(
|
||||
list=elt.constraints.into_iter().collect::<Vec<_>>(),
|
||||
view=|c_key: usize| view! {
|
||||
li(class="cst") {
|
||||
(c_key.to_string())
|
||||
view=move |c_key: usize| {
|
||||
let c_state = use_context::<AppState>();
|
||||
let assembly = &c_state.assembly;
|
||||
let cst = assembly.constraints.with(|csts| csts[c_key].clone());
|
||||
let other_arg = if cst.args.0 == key {
|
||||
cst.args.1
|
||||
} else {
|
||||
cst.args.0
|
||||
};
|
||||
let other_arg_label = assembly.elements.with(|elts| elts[other_arg].label.clone());
|
||||
view! {
|
||||
li(class="cst") {
|
||||
div(class="cst-label") { (other_arg_label) }
|
||||
div(class="cst-rep") { (cst.rep) }
|
||||
}
|
||||
}
|
||||
},
|
||||
key=|c_key| c_key.clone()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue