App: store constraints
Draft listing of constraints in outline view.
This commit is contained in:
parent
147e275823
commit
050e2373a6
4 changed files with 89 additions and 51 deletions
|
|
@ -18,6 +18,7 @@ pub fn Outline() -> View {
|
|||
|
||||
view! {
|
||||
ul(
|
||||
id="outline",
|
||||
on:click={
|
||||
let state = use_context::<AppState>();
|
||||
move |_| state.selection.update(|sel| sel.clear())
|
||||
|
|
@ -30,9 +31,9 @@ pub fn Outline() -> View {
|
|||
let class = create_memo({
|
||||
move || {
|
||||
if state.selection.with(|sel| sel.contains(&key)) {
|
||||
"selected"
|
||||
"elt selected"
|
||||
} else {
|
||||
""
|
||||
"elt"
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
@ -44,29 +45,12 @@ pub fn Outline() -> View {
|
|||
view! {
|
||||
/* [TO DO] switch to integer-valued parameters whenever
|
||||
that becomes possible again */
|
||||
li(
|
||||
class=class.get(),
|
||||
tabindex="0",
|
||||
on:click={
|
||||
move |event: MouseEvent| {
|
||||
if event.shift_key() {
|
||||
state.selection.update(|sel| {
|
||||
if !sel.remove(&key) {
|
||||
sel.insert(key);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
state.selection.update(|sel| {
|
||||
sel.clear();
|
||||
sel.insert(key);
|
||||
});
|
||||
}
|
||||
event.stop_propagation();
|
||||
}
|
||||
},
|
||||
on:keydown={
|
||||
move |event: KeyboardEvent| {
|
||||
if event.key() == "Enter" {
|
||||
li {
|
||||
div(
|
||||
class=class.get(),
|
||||
tabindex="0",
|
||||
on:click={
|
||||
move |event: MouseEvent| {
|
||||
if event.shift_key() {
|
||||
state.selection.update(|sel| {
|
||||
if !sel.remove(&key) {
|
||||
|
|
@ -79,13 +63,39 @@ pub fn Outline() -> View {
|
|||
sel.insert(key);
|
||||
});
|
||||
}
|
||||
event.prevent_default();
|
||||
event.stop_propagation();
|
||||
}
|
||||
},
|
||||
on:keydown={
|
||||
move |event: KeyboardEvent| {
|
||||
if event.key() == "Enter" {
|
||||
if event.shift_key() {
|
||||
state.selection.update(|sel| {
|
||||
if !sel.remove(&key) {
|
||||
sel.insert(key);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
state.selection.update(|sel| {
|
||||
sel.clear();
|
||||
sel.insert(key);
|
||||
});
|
||||
}
|
||||
event.prevent_default();
|
||||
}
|
||||
}
|
||||
}
|
||||
) {
|
||||
div(class="elt-label") { (label) }
|
||||
div(class="elt-rep") { (rep_components) }
|
||||
}
|
||||
ul(class="constraints") {
|
||||
Keyed(
|
||||
list=elt.constraints.into_iter().collect::<Vec<_>>(),
|
||||
view=|c_key: usize| view! { li { (c_key.to_string()) } },
|
||||
key=|c_key| c_key.clone()
|
||||
)
|
||||
}
|
||||
) {
|
||||
div(class="elt-label") { (label) }
|
||||
div(class="elt-rep") { (rep_components) }
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue