mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-08-09 15:35:22 +02:00
Use updated_at for sorting instead of created_at
This commit is contained in:
parent
05147aadf9
commit
55575a7609
2 changed files with 5 additions and 5 deletions
|
@ -7,7 +7,7 @@ class RulesController < ApplicationController
|
|||
@sort_by = params[:sort_by] || "name"
|
||||
@direction = params[:direction] || "asc"
|
||||
|
||||
allowed_columns = [ "name", "created_at" ]
|
||||
allowed_columns = [ "name", "updated_at" ]
|
||||
@sort_by = "name" unless allowed_columns.include?(@sort_by)
|
||||
@direction = "asc" unless [ "asc", "desc" ].include?(@direction)
|
||||
|
||||
|
|
|
@ -56,10 +56,10 @@
|
|||
<% end %>
|
||||
</div>
|
||||
<div class="flex items-center">
|
||||
<%= link_to rules_path(sort_by: "created_at", direction: (@sort_by == "created_at" && @direction == "asc") ? "desc" : "asc"),
|
||||
class: "px-2 py-1 rounded flex items-center hover:bg-gray-100 #{@sort_by == 'created_at' ? 'font-medium' : ''}" do %>
|
||||
<span class="mr-1">Date</span>
|
||||
<% if @sort_by == "created_at" %>
|
||||
<%= link_to rules_path(sort_by: "updated_at", direction: (@sort_by == "updated_at" && @direction == "asc") ? "desc" : "asc"),
|
||||
class: "px-2 py-1 rounded flex items-center hover:bg-gray-100 #{@sort_by == 'updated_at' ? 'font-medium' : ''}" do %>
|
||||
<span class="mr-1">Updated At</span>
|
||||
<% if @sort_by == "updated_at" %>
|
||||
<%= icon(@direction == "asc" ? "arrow-up" : "arrow-down", size: "xs") %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue