Filter transactions by category (#581)

* Add transaction filtering by category

* Link label to checkbox

* Keep the dropdown open when clicked to allow tab change

* Show the badge with color and name when filter is applied

* Reduce color height
This commit is contained in:
Thibaut Gorioux
2024-04-02 18:17:26 +02:00
committed by GitHub
parent ea3ba4f33a
commit b3c48d13e7
6 changed files with 30 additions and 7 deletions

View File

@@ -32,6 +32,10 @@ class Transaction < ApplicationRecord
value.each do |account_id|
filters << { type: "account", value: family.accounts.find(account_id), original: { key: key, value: account_id } }
end
when "category_id_in"
value.each do |category_id|
filters << { type: "category", value: family.transaction_categories.find(category_id), original: { key: key, value: category_id } }
end
when "category_name_or_account_name_or_name_cont"
filters << { type: "search", value: value, original: { key: key, value: nil } }
end

View File

@@ -18,7 +18,7 @@ class Transaction::Category < ApplicationRecord
]
def self.ransackable_attributes(auth_object = nil)
%w[name]
%w[name id]
end
def self.ransackable_associations(auth_object = nil)