Functional Weave
Code in Python

todo.filter@1.0.0

README.md

1,275 bytes · view raw

# todo.filter

The todos a list shows for its three controls: the view tab (`all`, `active`,
`completed`), the tag picked in the sidebar, and the search box. A todo must
pass all three, and the result keeps the input order, so sort first
(todo.sort) or after, whichever the app prefers.

- **View**: `active` is not done, `completed` is done, `all` is both. Any
  other view is an error: a typo should not quietly show an empty list.
- **Tag**: `null` means any tag. Otherwise the tag is normalised exactly as
  stored tags are (todo.normalise-tags), so `"#Home"` and `" HOME "` find
  todos tagged `home`, and `"Home Office"` finds `home-office`. It is an exact
  tag match: `home` does not find `home-office`. A tag that normalises to
  nothing (`"#"`, `"  "`) matches no todo, since a tag filter was asked for and
  no todo carries an empty tag. The todos' own tags are compared as stored;
  todo.item keeps them normalised.
- **Search**: the query is trimmed of ASCII spaces, then matched as a
  case-insensitive (ASCII only) substring of the title, the notes, or the tags
  joined with spaces, using collections.search-text. So searching `bills` finds
  a todo tagged `bills`, and `home` finds one tagged `home-office`. An empty or
  all-space query matches everything.