Back office in the website's style; People as record cards
The back office now looks like lannadesk.com: - Light theme as a printed letterhead (warm paper, navy ink, thin gold rules, a gold line across the top), and the default; the dark theme is the same navy and gold and stays a click away. - Trirong for headings and names, Sarabun for text: the website's fonts, self-hosted in static/fonts/ (latin and Thai subsets, OFL), since the CSP allows fonts from this origin only. - The header reads "Lanna Desk, back office"; primary buttons are navy on paper and gold on navy; corners are squarer. People are record cards, like the example record on the website: a monogram, the name in Trirong, nationality and province, the most urgent deadline's chip, the stay today, the next four dated deadlines with how far away they are, the passport and the employer. The filter works on the cards; "Table" shows the table as before (?view=table), and the switch keeps the employer and archive filters. Checks: fmt, clippy, 109 unit and 57 integration tests (the cards show the stay, the next dates and the monogram; the table view and the switch keep their filters); screenshots of People (light, dark, phone), a person, the deadlines and a client link.
This commit is contained in:
1 parent
39980694f6
commit
3d2d8fa30b
29 files changed
+496
-53
No files matched your search
@@ -398,6 +398,12 @@ pub struct ListItem {
|
||||
pub province: String,
|
||||
/// The most urgent deadline; the page fills it in.
|
||||
pub next: Option<crate::deadlines::Deadline>,
|
||||
/// Where the person stands today, and the next dated deadlines, most
|
||||
/// urgent first: the page fills them in for the record cards.
|
||||
pub stay: Option<crate::deadlines::Stay>,
|
||||
pub upcoming: Vec<crate::deadlines::Deadline>,
|
||||
/// "EM" for MUSTERMANN, Erika: the card's monogram.
|
||||
pub initials: String,
|
||||
/// Lower-case text the filter box searches.
|
||||
pub q: String,
|
||||
}
|
||||
@@ -447,8 +453,16 @@ pub async fn list(
|
||||
r.nationality
|
||||
)
|
||||
.to_lowercase();
|
||||
let initials: String = [r.first_name.chars().next(), r.surname.chars().next()]
|
||||
.into_iter()
|
||||
.flatten()
|
||||
.flat_map(char::to_uppercase)
|
||||
.collect();
|
||||
ListItem {
|
||||
id: r.id,
|
||||
initials,
|
||||
stay: None,
|
||||
upcoming: Vec::new(),
|
||||
age: r.date_of_birth.map(|d| dates::age(d, today)),
|
||||
passport_expires: r.passport_expires.map(dates::fmt_date).unwrap_or_default(),
|
||||
passport_status: r.passport_expires.map(|d| dates::passport_status(d, today)),
|
||||
|
||||
+35
-1
@@ -273,6 +273,9 @@ pub struct ListQuery {
|
||||
/// A company's id: only the people it employs.
|
||||
#[serde(default)]
|
||||
company: Option<String>,
|
||||
/// "table" for the table; the record cards otherwise.
|
||||
#[serde(default)]
|
||||
view: Option<String>,
|
||||
}
|
||||
|
||||
pub async fn list(
|
||||
@@ -287,8 +290,36 @@ pub async fn list(
|
||||
let ids: Vec<i64> = rows.iter().map(|r| r.id).collect();
|
||||
let mut found = deadlines::for_people(&st.db, &ids, today).await?;
|
||||
for r in &mut rows {
|
||||
r.next = found.remove(&r.id).and_then(|a| a.next().cloned());
|
||||
if let Some(a) = found.remove(&r.id) {
|
||||
r.next = a.next().cloned();
|
||||
r.upcoming = a
|
||||
.items
|
||||
.iter()
|
||||
.filter(|d| d.due.is_some())
|
||||
.take(4)
|
||||
.cloned()
|
||||
.collect();
|
||||
r.stay = Some(a.stay);
|
||||
}
|
||||
}
|
||||
let table = q.view.as_deref() == Some("table");
|
||||
// the other view keeps the filters
|
||||
let mut keep: Vec<String> = Vec::new();
|
||||
if archived {
|
||||
keep.push("archived=1".into());
|
||||
}
|
||||
if let Some(c) = company {
|
||||
keep.push(format!("company={c}"));
|
||||
}
|
||||
let with = |extra: Option<&str>| {
|
||||
let all: Vec<&str> = keep.iter().map(String::as_str).chain(extra).collect();
|
||||
if all.is_empty() {
|
||||
"/people".to_string()
|
||||
} else {
|
||||
format!("/people?{}", all.join("&"))
|
||||
}
|
||||
};
|
||||
let (cards_href, table_href) = (with(None), with(Some("view=table")));
|
||||
let (n_active, n_archived) = people::counts(&st.db).await?;
|
||||
let company_name = match company {
|
||||
Some(c) => companies::name(&st.db, c).await?,
|
||||
@@ -308,6 +339,9 @@ pub async fn list(
|
||||
StatusCode::OK,
|
||||
context! {
|
||||
people => rows,
|
||||
table,
|
||||
cards_href,
|
||||
table_href,
|
||||
archived,
|
||||
n_active,
|
||||
n_archived,
|
||||
|
||||
Reference in new issue
Block a user