Cinder.Selection (Cinder v0.17.0)

Copy Markdown View Source

Predicates that decide selection behaviour for a collection.

Selection has two distinct concerns:

  • whether selection is enabled for the collection at all (enabled?/1), which governs the checkbox column, the "select all" control and the bulk-action bar; and
  • whether an individual item may be selected (item_selectable?/2), which governs the per-item checkbox and click-to-toggle.

These functions are shared by the renderers and Cinder.LiveComponent. They treat the selectable value uniformly as true | false | (item -> boolean).

Summary

Functions

Returns whether selection is enabled for the collection.

Returns whether the given item may be selected.

Returns whether the given item is currently selected.

Returns whether the given item's checkbox should be interactive.

Functions

enabled?(arg1)

Returns whether selection is enabled for the collection.

false and nil disable selection entirely; any other value (true or a predicate function) enables it.

item_selectable?(fun, item)

Returns whether the given item may be selected.

A predicate function is called with the item and its result is coerced to a boolean.

item_selected?(selected_ids, item, id_field)

Returns whether the given item is currently selected.

item_toggleable?(selectable, selected_ids, item, id_field)

Returns whether the given item's checkbox should be interactive.

An item is toggleable when it is selectable, or when it is already selected so that an item that became non-selectable can still be removed.