What a person asked of a grid: its order, its filters and its search.
A source (Masu.Source) gets the query with every key and value
already checked against the grid's columns: each sort names a column
that sorts, each filter a column that filters, with its value read for
the column's type. search is text to find in the columns that are
searchable, or nil.
groups are the keys of the columns the rows are grouped by, the
first the outermost (Masu.Group).
In a tree (Masu.Tree), expanded holds the ids of the rows the
person opened, and collapsed those they closed while a filter or a
search shows every row it keeps open. Neither goes to the browser with
the query, nor into a view's params.
open_groups is what the grid's expanded gives a grouped grid: the
keys of the columns whose groups start open, or :all. A group of
such a column is open unless the person closed it (it is then in
collapsed); any other group is closed unless they opened it (in
expanded).
A grid starts with the query of its sort and filters attributes,
and changes it as the person sorts and searches. Masu.Test changes it
the same way.
Summary
Functions
Makes a query from what the browser sends, and checks it against the
columns: sorts [%{"key" => key, "dir" => "asc" | "desc"}], filters
[%{"key" => key, "op" => op, "value" => value}] and a "search".
Makes a query from Elixir terms (the grid's attributes, or Masu.Test)
and checks it the same way: sort is a list of keys, {key, direction}
or Masu.Sort structs; filters a list of Masu.Filter structs or
{key, op, value}.
The query as the browser gets it.
Types
@type t() :: %Masu.Query{ collapsed: MapSet.t(), expanded: MapSet.t(), filters: [Masu.Filter.t()], groups: [String.t()], open_groups: :all | [String.t()], search: String.t() | nil, sorts: [Masu.Sort.t()] }
Functions
@spec from_wire(map(), [Masu.Column.t()]) :: {:ok, t()} | {:error, String.t()}
Makes a query from what the browser sends, and checks it against the
columns: sorts [%{"key" => key, "dir" => "asc" | "desc"}], filters
[%{"key" => key, "op" => op, "value" => value}] and a "search".
The sorts on a column that does not sort, and the repeated ones, are left out. A filter that does not check is an error, so that a grid never shows rows the person did not ask for. So is a query with more than 100 sorts, filters or groups, a text over 1,000 bytes, a list filter of more than 10,000 values, and a text with a NUL character.
@spec new(keyword(), [Masu.Column.t()]) :: {:ok, t()} | {:error, String.t()}
Makes a query from Elixir terms (the grid's attributes, or Masu.Test)
and checks it the same way: sort is a list of keys, {key, direction}
or Masu.Sort structs; filters a list of Masu.Filter structs or
{key, op, value}.
The query as the browser gets it.