mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-07-25 08:09:38 +02:00
Feat transactions search (#532)
* gem: Add ransack gem * feat: Implement transactions search
This commit is contained in:
parent
7f2633f9da
commit
cca779d3c4
9 changed files with 116 additions and 33 deletions
|
@ -3,7 +3,19 @@ class TransactionsController < ApplicationController
|
|||
before_action :set_transaction, only: %i[ show edit update destroy ]
|
||||
|
||||
def index
|
||||
@pagy, @transactions = pagy(Current.family.transactions.order(date: :desc), items: 50)
|
||||
search_params = params[:q] || {}
|
||||
period = Period.find_by_name(search_params[:date])
|
||||
if period&.date_range
|
||||
search_params.merge!({ date_gteq: period.date_range.begin, date_lteq: period.date_range.end })
|
||||
end
|
||||
|
||||
@q = Current.family.transactions.ransack(search_params)
|
||||
@pagy, @transactions = pagy(@q.result.order(date: :desc), items: 50)
|
||||
|
||||
respond_to do |format|
|
||||
format.html # For full page reloads
|
||||
format.turbo_stream # For Turbo Frame requests
|
||||
end
|
||||
end
|
||||
|
||||
def show
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue