web: add pagination to bottom of search results
This commit is contained in:
parent
ec1a12ca11
commit
72622032ad
@ -8,7 +8,7 @@ use std::{
|
||||
};
|
||||
|
||||
use itertools::Itertools;
|
||||
use log::{debug, error, info, warn, Level};
|
||||
use log::{debug, error, info, Level};
|
||||
use notmuch::{Content, Part, Thread, ThreadNode, ThreadSet};
|
||||
use seed::{prelude::*, *};
|
||||
use serde::de::Deserialize;
|
||||
@ -512,7 +512,8 @@ fn view_mobile_search_results(query: &str, search_results: &shared::SearchResult
|
||||
div![
|
||||
h1!["Search results"],
|
||||
view_search_pager(first, summaries.len(), search_results.total),
|
||||
rows
|
||||
rows,
|
||||
view_search_pager(first, summaries.len(), search_results.total)
|
||||
]
|
||||
}
|
||||
|
||||
@ -564,26 +565,35 @@ fn view_search_results(query: &str, search_results: &shared::SearchResult) -> No
|
||||
th![C!["date"], "Date"]
|
||||
]],
|
||||
tbody![rows]
|
||||
]
|
||||
],
|
||||
view_search_pager(first, summaries.len(), search_results.total)
|
||||
]
|
||||
}
|
||||
|
||||
fn view_search_pager(page: usize, count: usize, total: usize) -> Node<Msg> {
|
||||
fn view_search_pager(start: usize, count: usize, total: usize) -> Node<Msg> {
|
||||
let is_first = start <= 0;
|
||||
let is_last = (start + SEARCH_RESULTS_PER_PAGE) >= total;
|
||||
nav![
|
||||
C!["pagination"],
|
||||
a![
|
||||
C!["pagination-previous", "button"],
|
||||
C![
|
||||
"pagination-previous",
|
||||
"button",
|
||||
IF!(is_first => "is-static"),
|
||||
IF!(is_first => "is-info"),
|
||||
],
|
||||
"<",
|
||||
ev(Ev::Click, |_| Msg::PreviousPage)
|
||||
],
|
||||
a![
|
||||
C!["pagination-next", "button"],
|
||||
C!["pagination-next", "button", IF!(is_last => "is-static")],
|
||||
IF!(is_last => attrs!{ At::Disabled=>true }),
|
||||
">",
|
||||
ev(Ev::Click, |_| Msg::NextPage)
|
||||
],
|
||||
ul![
|
||||
C!["pagination-list"],
|
||||
li![format!("{} - {} of {}", page, page + count, total)],
|
||||
li![format!("{} - {} of {}", start, start + count, total)],
|
||||
],
|
||||
]
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user