Skip to content

Commit

Permalink
feat: add expand all and collapse all Button (#68)
Browse files Browse the repository at this point in the history
  • Loading branch information
felixrieg authored Aug 22, 2023
1 parent 23a2ff0 commit bcb4d51
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
16 changes: 16 additions & 0 deletions uvls/src/webview.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,8 @@ pub enum UIAction {
SolverActive,
Save,
Show,
ExpandAll,
CollapseAll,
}
#[derive(Debug, Clone)]
pub enum UISyncState {
Expand Down Expand Up @@ -490,6 +492,20 @@ async fn ui_event_loop(
});
}
}
UIAction::ExpandAll => {
ui_config.with_mut(|UIConfigState { entries, .. }| {
entries.into_iter().for_each(|(_, entrie)| {
entrie.open = true;
})
});
}
UIAction::CollapseAll => {
ui_config.with_mut(|UIConfigState { entries, .. }| {
entries.into_iter().for_each(|(_, entrie)| {
entrie.open = false;
})
});
}
UIAction::Save => {
let module = tx_config.borrow().module.clone();
let output_name = ui_state.read().file_name.clone();
Expand Down
18 changes: 18 additions & 0 deletions uvls/src/webview/frontend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -554,6 +554,24 @@ pub fn App(cx: Scope<AppProps>) -> Element {
}
}
}
li{
button{
class:"btn-save",
onclick: move |_|{
ui_tx.send(UIAction::ExpandAll);
},
rsx!{"Expand All"}
}
}
li{
button{
class:"btn-save",
onclick: move |_|{
ui_tx.send(UIAction::CollapseAll);
},
rsx!{"Collapse All"}
}
}
}
"Files:"
table{
Expand Down

0 comments on commit bcb4d51

Please sign in to comment.