1
0
Fork 0
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:
hatz 2025-05-02 19:41:08 -05:00
parent 05147aadf9
commit 55575a7609
No known key found for this signature in database
2 changed files with 5 additions and 5 deletions

View file

@ -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)

View file

@ -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 %>