Expand description
The checklist: checkboxes in groups, one component for every screen.
A screen describes the list; the component decides how to present it from
its size. Past SELECT_ALL_PAST choices it offers select all and none,
past SEARCH_PAST a search box, and past COLLAPSE_PAST choices in
more than one group it closes the groups that are settled (every choice
ticked, or none) and opens the ones partly ticked. Each decision has an
override: Checklist::select_all, Checklist::search,
Checklist::expand.
use laterite_admin::checklist::{Checklist, Choice};
use laterite_core::Translator;
let html = Checklist::new("Topics")
.choice(Choice::new("topic", "news", "News").checked(true))
.group("Sport", vec![
Choice::new("topic", "football", "Football").into(),
Choice::new("topic", "cricket", "Cricket").note("Tests and one-day").into(),
])
.render(&Translator::new("en"));
assert!(html.as_str().contains(r#"name="topic" value="football""#));The markup works before any script runs: the boxes submit and the groups
open and close. The checklist island adds the group boxes, the counts that
follow the ticks, the search and the lat:checklist:changed event.
Structs§
- Checklist
- A checklist, as a screen describes it.
- Checklist
View - A checklist resolved for rendering. Built by
Checklist::view. - Choice
- One checkbox.
- Group
- A heading over entries of its own. Its box is ticked when all of them are, clear when none is, and in between otherwise.
Enums§
- Entry
- A line of the checklist: a choice, or a group of lines.
- Expand
- Which groups start open.
- Offer
- Whether a part of the checklist is offered: decided from the size of the
list, or stated. In a descriptor file:
auto,true,false.
Constants§
- COLLAPSE_
PAST - Settled groups start closed past this many choices.
- SEARCH_
PAST - The search box is offered past this many choices.
- SELECT_
ALL_ PAST - Select all and select none are offered past this many choices.