View Source Torch.TableView (Torch v4.1.0)
Helpers for rendering Torch-generated tables.
Link to this section Summary
Functions
Prettifies and associated struct for display.
Generates a sortable link for a table heading.
Link to this section Functions
Specs
Prettifies and associated struct for display.
Displays the model's name or "None", rather than the struct's ID.
Examples
iex> table_assoc_display_name(%{category_id: 1}, :category_id, [{"Articles", 1}])
"Articles"
iex> table_assoc_display_name(%{category_id: nil}, :category_id, [{"Articles", 1}])
"None"
Specs
table_link(Plug.Conn.t(), String.t(), atom()) :: Phoenix.HTML.safe()
Generates a sortable link for a table heading.
Clicking on the link will trigger a sort on that field. Clicking again will reverse the sort.
Example
iex> conn = %Plug.Conn{params: %{"sort_field" => "name", "sort_direction" => "asc"}}
...> table_link(conn, "Name", :name) |> safe_to_string()
"<a class=\"active asc\" href=\"?sort_direction=desc&sort_field=name\">Name<span class=\"caret\"></span></a>"