Cardbox.Choice (Cardbox v0.1.0)

Copy Markdown View Source

The choices of a select, a multi-select or a status field: each an id, a name and a color, and for a status a group.

%{"id" => "in_review", "name" => "In review", "color" => "purple", "group" => "doing"}

A record keeps a choice's id, so a choice renamed or recolored is renamed everywhere at once, and a choice removed from the field is removed from the records that had it.

The colors are Erabi's nine (gray, brown, orange, yellow, green, blue, purple, pink, red), which its pickers draw with their contrast checked in light and dark; to_options/1 gives the choices as Erabi takes them.

A status's groups are "todo", "doing" and "done", in that order: a board of a status field shows them, and a filter takes a whole group (in_group).

Summary

Functions

The colors a choice takes.

The choice of a list with this id, or with this name (without case), or nil.

The groups of a status's choices, in their order.

The choices as Erabi's options (Erabi.Option): value the id, label the name, color the color as an atom, and a status's group as group.

Functions

colors()

@spec colors() :: [String.t()]

The colors a choice takes.

find(choices, value)

@spec find([map()], term()) :: map() | nil

The choice of a list with this id, or with this name (without case), or nil.

groups()

@spec groups() :: [String.t()]

The groups of a status's choices, in their order.

to_options(choices)

@spec to_options([map()]) :: [map()]

The choices as Erabi's options (Erabi.Option): value the id, label the name, color the color as an atom, and a status's group as group.