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=="
|
integrity="sha512-SzlrxWUlpfuzQ+pcUCosxcglQRNAq/DZjVsC0lE40xsADsfeQoEypE+enwcOiGjk/bSuGGKHEyjSoQ1zVisanQ=="
|
||||||
crossorigin="anonymous" referrerpolicy="no-referrer" />
|
crossorigin="anonymous" referrerpolicy="no-referrer" />
|
||||||
<link rel="icon" href="https://static.xinu.tv/favicon/letterbox.svg" />
|
<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" />
|
<link data-trunk rel="css" href="static/main.css" />
|
||||||
<style>
|
<style>
|
||||||
.message {
|
.message {
|
||||||
@ -66,7 +66,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.index .edit {
|
.index .edit {
|
||||||
width: 1.5em;
|
width: 2em;
|
||||||
}
|
}
|
||||||
|
|
||||||
.index .unread {
|
.index .unread {
|
||||||
|
|||||||
@ -277,6 +277,24 @@ pub fn update(msg: Msg, model: &mut Model, orders: &mut impl Orders<Msg>) {
|
|||||||
Msg::ShowThreadResult(bad) => {
|
Msg::ShowThreadResult(bad) => {
|
||||||
error!("show_thread_query error: {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 => {
|
Msg::SelectionMarkAsRead => {
|
||||||
if let Context::SearchResult {
|
if let Context::SearchResult {
|
||||||
selected_threads, ..
|
selected_threads, ..
|
||||||
@ -423,6 +441,8 @@ pub enum Msg {
|
|||||||
Result<graphql_client::Response<graphql::show_thread_query::ResponseData>, gloo_net::Error>,
|
Result<graphql_client::Response<graphql::show_thread_query::ResponseData>, gloo_net::Error>,
|
||||||
),
|
),
|
||||||
|
|
||||||
|
SelectionSetNone,
|
||||||
|
SelectionSetAll,
|
||||||
SelectionMarkAsRead,
|
SelectionMarkAsRead,
|
||||||
SelectionMarkAsUnread,
|
SelectionMarkAsUnread,
|
||||||
SelectionAddThread(String),
|
SelectionAddThread(String),
|
||||||
|
|||||||
@ -117,6 +117,8 @@ fn view_search_results(
|
|||||||
set_title(query);
|
set_title(query);
|
||||||
}
|
}
|
||||||
let show_bulk_edit = !selected_threads.is_empty();
|
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 rows = results.iter().map(|r| {
|
||||||
let tid = r.thread.clone();
|
let tid = r.thread.clone();
|
||||||
let check_tid = r.thread.clone();
|
let check_tid = r.thread.clone();
|
||||||
@ -185,7 +187,25 @@ fn view_search_results(
|
|||||||
"is-striped",
|
"is-striped",
|
||||||
],
|
],
|
||||||
thead![tr![
|
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!["from"], "From"],
|
||||||
th![C!["subject"], "Subject"],
|
th![C!["subject"], "Subject"],
|
||||||
th![C!["date"], "Date"]
|
th![C!["date"], "Date"]
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user