LR-VIEW-PHOTOGRID: group the photo/square grid by date with day/month/year headers

Catalog date runs (stacks never split), Sort.group (auto/day/month/year/none) in the sort
menus, library.groups query, sticky headers, header click selects the group; layout unit
tests and a headless test.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Brandon Thomas
2026-10-01 12:52:07 -04:00
co-authored by Claude Opus 5.5
parent cec012d032
commit 89b8aa3f77
13 changed files with 570 additions and 65 deletions
+34
View File
@@ -0,0 +1,34 @@
//! Library management commands: date groups, keyword rename/delete/merge, batch rename, capture
//! time, label names, import review.
use serde_json::json;
use crate::Session;
/// Date headers follow the grid order and the sort's grouping.
#[test]
fn date_groups_follow_sort_and_grouping() {
let mut s = Session::with_demo();
let vis = s.visible_cloned();
let g = s.execute("library.groups", &json!({})).unwrap();
let groups = g.as_array().unwrap();
assert!(groups.len() > 3, "{g}");
let total: u64 = groups.iter().map(|x| x["count"].as_u64().unwrap()).sum();
assert_eq!(total as usize, vis.len());
// contiguous runs in grid order, labelled with weekday and date
let mut next = 0;
for x in groups {
assert_eq!(x["start"].as_u64().unwrap(), next);
next += x["count"].as_u64().unwrap();
assert!(x["label"].as_str().unwrap().contains(", "), "{x}");
}
let months = s.execute("library.groups", &json!({"by": "month"})).unwrap();
assert!(months.as_array().unwrap().len() < groups.len());
assert_eq!(months[0]["key"].as_str().unwrap().len(), 7);
s.execute("library.sort", &json!({"group": "none"})).unwrap();
assert_eq!(s.execute("library.groups", &json!({})).unwrap(), json!([]));
s.execute("library.sort", &json!({"group": "year", "key": "fileName"})).unwrap();
assert_eq!(s.execute("library.groups", &json!({})).unwrap(), json!([]), "no date headers when sorting by name");
assert_eq!(s.sort.group, lightcraft_catalog::GroupBy::Year);
assert!(s.execute("library.sort", &json!({"group": "week"})).is_err());
}