Commit 6f67bec4 authored by Benoit MARTIN-CHAVE's avatar Benoit MARTIN-CHAVE
Browse files

Add sorter helpers

parent a234d351
Pipeline #4313 passed with stage
in 28 seconds
# Changelog
## Next version
- Add sorter helpers
## v1.3.0
- Replace `icon` helper by `fa_s`/`fa_r`/`fa_b` helpers
......
......@@ -23,4 +23,26 @@ class BMC::Sorter
def self.call(...)
new(...).call
end
private
def inverted_direction
{asc: :desc, desc: :asc}[direction]
end
def joins(...)
@collection = @collection.joins(...)
end
def left_joins(...)
@collection = @collection.left_joins(...)
end
def by_column(c = column)
{c => direction}
end
def by_lower(c = column)
Arel.sql "LOWER(#{c}) #{direction}"
end
end
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment