Torch v2.0.0-rc.3 Torch.FilterView View Source

Provides input generators for Torch's filter sidebar.

Link to this section Summary

Functions

Generates a select box for a belongs_to association

Generates a filter select box for a boolean field

Generates a filter datepicker input

Generates a filter input for a number field

Generates a "contains/equals" filter type select box for a given string or text field

Generates a filter input for a string field

DEPRECATED: Generates a filter input for a text field. Use the filter_string_input/3 function instead

Generates a number filter type select box for a given number field

Link to this section Types

Link to this section Functions

Link to this function

filter_assoc_select(prefix, field, options, params) View Source
filter_assoc_select(prefix(), field(), list(), map()) :: Phoenix.HTML.safe()

Generates a select box for a belongs_to association.

Example

iex> params = %{"post" => %{"category_id_equals" => 1}}
...> filter_assoc_select(:post, :category_id, [{"Articles", 1}], params) |> safe_to_string()
"<select id=\"post_category_id_equals\" name=\"post[category_id_equals]\"><option value=\"\">Choose one</option><option value=\"1\" selected>Articles</option></select>"
Link to this function

filter_boolean_input(prefix, field, params) View Source
filter_boolean_input(prefix(), field(), map()) :: Phoenix.HTML.safe()

Generates a filter select box for a boolean field.

Example

iex> params = %{"post" => %{"draft_equals" => "false"}}
iex> filter_boolean_input(:post, :draft, params) |> safe_to_string()
"<input name=\"post[draft_equals]\" type=\"hidden\" value=\"false\"><input id=\"post_draft_equals\" name=\"post[draft_equals]\" type=\"checkbox\" value=\"true\">"
Link to this function

filter_date_input(prefix, field, params) View Source
filter_date_input(prefix(), field(), map()) :: Phoenix.HTML.safe()

Generates a filter datepicker input.

Example

iex> params = %{"post" => %{"inserted_at_between" => %{"start" => "01/01/2018", "end" => "01/31/2018"}}}
...> filter_date_input(:post, :inserted_at, params) |> safe_to_string()
"<input class=\"datepicker start\" name=\"post[inserted_at_between][start]\" placeholder=\"Select Start Date\" type=\"text\" value=\"01/01/2018\"><input class=\"datepicker end\" name=\"post[inserted_at_between][end]\" placeholder=\"Select End Date\" type=\"text\" value=\"01/31/2018\">"
Link to this function

filter_number_input(prefix, field, params) View Source
filter_number_input(prefix(), field(), map()) :: Phoenix.HTML.safe()

Generates a filter input for a number field.

Example

iex> params = %{"post" => %{"rating_equals" => 5}}
...> filter_number_input(:post, :rating, params) |> safe_to_string()
"<input id=\"post_rating_equals\" name=\"post[rating_equals]\" type=\"number\" value=\"5\">"
Link to this function

filter_select(prefix, field, params) View Source
filter_select(prefix(), field(), map()) :: Phoenix.HTML.safe()

Generates a "contains/equals" filter type select box for a given string or text field.

Example

iex> params = %{"post" => %{"title_contains" => "test"}}
...> filter_select(:post, :title, params) |> safe_to_string()
"<select class=\"filter-type\" id=\"filters_\" name=\"filters[]\"><option value=\"post[title_contains]\" selected>Contains</option><option value=\"post[title_equals]\">Equals</option></select>"
Link to this function

filter_string_input(prefix, field, params) View Source
filter_string_input(prefix(), field(), map()) :: Phoenix.HTML.safe()

Generates a filter input for a string field.

Example

iex> params = %{"post" => %{"title_contains" => "test"}}
iex> filter_string_input(:post, :title, params) |> safe_to_string()
"<input id=\"post_title_contains\" name=\"post[title_contains]\" type=\"text\" value=\"test\">"
Link to this function

filter_text_input(prefix, field, params) View Source

This function is deprecated. Use filter_string_input/3 instead.

DEPRECATED: Generates a filter input for a text field. Use the filter_string_input/3 function instead.

Link to this function

number_filter_select(prefix, field, params) View Source
number_filter_select(prefix(), field(), map()) :: Phoenix.HTML.safe()

Generates a number filter type select box for a given number field.

Example

iex> params = %{"post" => %{"rating_greater_than" => 0}}
...> number_filter_select(:post, :rating, params) |> safe_to_string()
"<select class=\"filter-type\" id=\"filters_\" name=\"filters[]\"><option value=\"post[rating_equals]\">Equals</option><option value=\"post[rating_greater_than]\" selected>Greater Than</option><option value=\"post[rating_greater_than_or]\">Greater Than Or Equal</option><option value=\"post[rating_less_than]\">Less Than</option></select>"