Skip to content

Commit

Permalink
add pagination to account transactions list (maybe-finance#1095)
Browse files Browse the repository at this point in the history
* add pagination to account transactions list

* use global pagination partial
  • Loading branch information
code-constructor authored Aug 16, 2024
1 parent 9dda260 commit c70a08a
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 4 deletions.
5 changes: 4 additions & 1 deletion app/controllers/account/transactions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ class Account::TransactionsController < ApplicationController
before_action :set_entry, only: :update

def index
@entries = @account.entries.account_transactions.reverse_chronological
@pagy, @entries = pagy(
@account.entries.account_transactions.reverse_chronological,
limit: params[:per_page] || "10"
)
end

def update
Expand Down
3 changes: 3 additions & 0 deletions app/views/account/transactions/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
<%= render entries %>
<% end %>
</div>
<div class="pt-4">
<%= render "pagination", pagy: @pagy %>
</div>
<% end %>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
</div>
</div>
<div class="flex items-center gap-4">
<%= form_with url: transactions_path,
<%= form_with url: url_for,
method: :get,
class: "flex items-center gap-4",
data: { controller: "auto-submit-form" } do |f| %>
Expand Down
5 changes: 5 additions & 0 deletions config/locales/views/application/en.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
en:
application:
pagination:
rows_per_page: Rows per page
2 changes: 0 additions & 2 deletions config/locales/views/transactions/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,5 @@ en:
success: Marked as transfer
new:
new_transaction: New transaction
pagination:
rows_per_page: Rows per page
unmark_transfers:
success: Transfer removed

0 comments on commit c70a08a

Please sign in to comment.