Gitpro.Views.Filters (gitpro v0.1.0)

Copy Markdown View Source

The switches, as a popup: one group per axis of Gitpro.Filter.

State, the board's columns, the labels the cards wear and the people they are assigned to — each with a switch, and each starting on, which is the only default that is not a guess about what someone came to look at.

  ^P ^N   move          SPACE    toggle
a           all on        n         all off
ESC q ^F    close

The groups combine: a card is shown when it passes every axis. Within the multi-valued ones — labels, assignees — it passes when any of its own is on, which is what makes turning one label off mean "hide the cards that are only that" rather than "hide everything wearing it". Gitpro.Filter has the whole of that rule.

Live, not on close

Each toggle is sent straight to Gitpro.Views.Issues with Atui.Runtime.send_event_to/3, so the list narrows behind the popup as the switches are set. The popup holds the filter while it is up and the list view holds it the rest of the time; there is one filter, and the popup is a way of editing it rather than a second copy of it.

Labels and assignees are only known once the cards have loaded, so a popup opened while the board is still loading has two groups in it and four a moment later — which is why the cursor is kept on the switch it was on rather than on the row number it was at.

Summary

Functions

The switches, in the order the popup lists them.

The rows drawn, group headers included; only the switches can hold the cursor.

Functions

flags(filter)

@spec flags(Gitpro.Filter.t()) :: [Gitpro.Filter.flag()]

The switches, in the order the popup lists them.

Delegated to Gitpro.Filter.flags/1, because the order the switches are drawn in and the order they are filtered in are the same order, and keeping two lists of that would be one too many.

rows(filter)

@spec rows(Gitpro.Filter.t()) :: [
  {:header, String.t()} | {:flag, Gitpro.Filter.flag(), non_neg_integer()}
]

The rows drawn, group headers included; only the switches can hold the cursor.

An axis with nothing on it is left out rather than given an empty heading — a board with no labels on any card has no labels to switch.