[Enhancement] Add sorting, pagination, and new attributes to sources index table (#510)
* WIP - started improving handling of sorting for sources index table * WIP - Added UI to table to indicate sort column and direction * Refactored toggle liveview into a livecomponent * Added sorting for all table attrs * Added pagination to the sources table * Added tests for updated liveviews and live components * Add tests for new helper methods * Added fancy new CSS to my sources table * Added size to sources table * Adds relative div to ensure that sorting arrow doesn't run away * Fixed da tests
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
defmodule PinchflatWeb.Helpers.SortingHelpers do
|
||||
@moduledoc """
|
||||
Methods for working with sorting, usually in the context of LiveViews or LiveComponents.
|
||||
|
||||
These methods are fairly simple, but they're commonly repeated across different Live entities
|
||||
"""
|
||||
|
||||
@doc """
|
||||
Given the old sort attribute, the new sort attribute, and the old sort direction, returns the new sort direction.
|
||||
|
||||
Returns :asc | :desc
|
||||
"""
|
||||
def get_sort_direction(old_sort_attr, new_sort_attr, old_sort_direction) do
|
||||
case {new_sort_attr, old_sort_direction} do
|
||||
{^old_sort_attr, :desc} -> :asc
|
||||
{^old_sort_attr, _} -> :desc
|
||||
_ -> :asc
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user