web: add select all/partial/none for search table
This commit is contained in:
parent
cda99fc7a5
commit
42ce88d931
@ -9,7 +9,7 @@
|
||||
integrity="sha512-SzlrxWUlpfuzQ+pcUCosxcglQRNAq/DZjVsC0lE40xsADsfeQoEypE+enwcOiGjk/bSuGGKHEyjSoQ1zVisanQ=="
|
||||
crossorigin="anonymous" referrerpolicy="no-referrer" />
|
||||
<link rel="icon" href="https://static.xinu.tv/favicon/letterbox.svg" />
|
||||
<!-- Pretty checkboxes -->
|
||||
<!-- Pretty checkboxes from https://justboil.github.io/bulma-checkbox/ -->
|
||||
<link data-trunk rel="css" href="static/main.css" />
|
||||
<style>
|
||||
.message {
|
||||
@ -66,7 +66,7 @@
|
||||
}
|
||||
|
||||
.index .edit {
|
||||
width: 1.5em;
|
||||
width: 2em;
|
||||
}
|
||||
|
||||
.index .unread {
|
||||
|
||||
@ -277,6 +277,24 @@ pub fn update(msg: Msg, model: &mut Model, orders: &mut impl Orders<Msg>) {
|
||||
Msg::ShowThreadResult(bad) => {
|
||||
error!("show_thread_query error: {bad:#?}");
|
||||
}
|
||||
Msg::SelectionSetNone => {
|
||||
if let Context::SearchResult {
|
||||
selected_threads, ..
|
||||
} = &mut model.context
|
||||
{
|
||||
*selected_threads = HashSet::new();
|
||||
}
|
||||
}
|
||||
Msg::SelectionSetAll => {
|
||||
if let Context::SearchResult {
|
||||
results,
|
||||
selected_threads,
|
||||
..
|
||||
} = &mut model.context
|
||||
{
|
||||
*selected_threads = results.iter().map(|node| node.thread.clone()).collect();
|
||||
}
|
||||
}
|
||||
Msg::SelectionMarkAsRead => {
|
||||
if let Context::SearchResult {
|
||||
selected_threads, ..
|
||||
@ -423,6 +441,8 @@ pub enum Msg {
|
||||
Result<graphql_client::Response<graphql::show_thread_query::ResponseData>, gloo_net::Error>,
|
||||
),
|
||||
|
||||
SelectionSetNone,
|
||||
SelectionSetAll,
|
||||
SelectionMarkAsRead,
|
||||
SelectionMarkAsUnread,
|
||||
SelectionAddThread(String),
|
||||
|
||||
@ -117,6 +117,8 @@ fn view_search_results(
|
||||
set_title(query);
|
||||
}
|
||||
let show_bulk_edit = !selected_threads.is_empty();
|
||||
let all_checked = selected_threads.len() == results.len();
|
||||
let partially_checked = !selected_threads.is_empty() && !all_checked;
|
||||
let rows = results.iter().map(|r| {
|
||||
let tid = r.thread.clone();
|
||||
let check_tid = r.thread.clone();
|
||||
@ -185,7 +187,25 @@ fn view_search_results(
|
||||
"is-striped",
|
||||
],
|
||||
thead![tr![
|
||||
th![C!["edit"], ""],
|
||||
th![
|
||||
C!["edit"],
|
||||
label![
|
||||
C!["b-checkbox", "checkbox"],
|
||||
input![
|
||||
IF!(partially_checked => C!["is-indeterminate"]),
|
||||
attrs! {
|
||||
At::Type=>"checkbox",
|
||||
At::Checked=>all_checked.as_at_value(),
|
||||
}
|
||||
],
|
||||
span![C!["check"]],
|
||||
ev(Ev::Click, move |_| if all_checked {
|
||||
Msg::SelectionSetNone
|
||||
} else {
|
||||
Msg::SelectionSetAll
|
||||
})
|
||||
]
|
||||
],
|
||||
th![C!["from"], "From"],
|
||||
th![C!["subject"], "Subject"],
|
||||
th![C!["date"], "Date"]
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user