mirror of
https://github.com/we-promise/sure.git
synced 2026-04-19 20:14:08 +00:00
Feat transactions search (#532)
* gem: Add ransack gem * feat: Implement transactions search
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user