-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Transactions cleanup #817
Merged
zachgoll
merged 34 commits into
main
from
795-transaction-sidebar-partials-and-controller-cleanup
May 31, 2024
Merged
Transactions cleanup #817
Changes from 32 commits
Commits
Show all changes
34 commits
Select commit
Hold shift + click to select a range
bd41211
Separate "modal" and "drawer" concepts for overlays
zachgoll 7086c5a
Remove unused mobile pagination, set proper Turbo action
zachgoll 7210c25
Add tests for pagination and transaction filtering
zachgoll 54b28a9
Merge branch 'main' of github.com:maybe-finance/maybe into 795-transa…
zachgoll 9cc34e3
Searchable concern
zachgoll 5b03bfa
Revert "Searchable concern"
zachgoll 565e6cb
Reorganize transaction partials part 1
zachgoll aab1978
Simplify search filters, temporarily remove Turbo
zachgoll e4f44cf
Simplify transaction searching, clean up controller
zachgoll 7679594
Complete filter badges and add test
zachgoll bc1b04a
Reorganize transaction partials part 2
zachgoll ee41044
Merge branch 'main' of github.com:maybe-finance/maybe into 795-transa…
zachgoll fdaf044
Fix tests
zachgoll 8f57916
Run system tests serially in CI
zachgoll c800ffb
Remove unused edit action
zachgoll 2e7fdc7
Add back turbo
zachgoll 91e9fcd
Clean up transaction model
zachgoll 7d0ac15
Fix association ordering
zachgoll 6d1a67c
Transaction controller cleanup part 3
zachgoll 7f7a289
Rework sync
zachgoll 2209fa1
Revert "Rework sync"
zachgoll e01057f
Tweaks to transaction model
zachgoll 3080f21
Render transaction amount sign correctly
zachgoll 9aeb10f
Add back simplified transaction turbo stream
zachgoll c41af41
Consolidate transaction partials and fix form update frame redirects
zachgoll 5c29d95
Bump capybara wait time
zachgoll c96e32d
System test stabilization
zachgoll e5c102e
Remove redundant test
zachgoll 6bca270
Don't enforce system tests yet for PRs
zachgoll 14ac8a8
Add back test DB url
zachgoll ad7c280
Job env
zachgoll ddeaa0a
Rails env for action
zachgoll 75a654c
Remove unused partial
zachgoll 5797f76
Merge branch 'main' of github.com:maybe-finance/maybe into 795-transa…
zachgoll File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
class Transactions::RowsController < ApplicationController | ||
before_action :set_transaction, only: %i[ show update ] | ||
|
||
def show | ||
end | ||
|
||
def update | ||
@transaction.update! transaction_params | ||
|
||
redirect_to transaction_row_path(@transaction) | ||
end | ||
|
||
private | ||
|
||
def transaction_params | ||
params.require(:transaction).permit(:category_id) | ||
end | ||
|
||
def set_transaction | ||
@transaction = Current.family.transactions.find(params[:id]) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
module Transactions::SearchesHelper | ||
def transaction_search_filters | ||
[ | ||
{ key: "account_filter", name: "Account", icon: "layers" }, | ||
{ key: "date_filter", name: "Date", icon: "calendar" }, | ||
{ key: "type_filter", name: "Type", icon: "shapes" }, | ||
{ key: "amount_filter", name: "Amount", icon: "hash" }, | ||
{ key: "category_filter", name: "Category", icon: "tag" }, | ||
{ key: "merchant_filter", name: "Merchant", icon: "store" } | ||
] | ||
end | ||
|
||
def get_transaction_search_filter_partial_path(filter) | ||
"transactions/searches/filters/#{filter[:key]}" | ||
end | ||
|
||
def get_default_transaction_search_filter | ||
transaction_search_filters[0] | ||
end | ||
|
||
def transactions_path_without_param(param_key, param_value) | ||
updated_params = request.query_parameters.deep_dup | ||
|
||
q_params = updated_params[:q] || {} | ||
|
||
current_value = q_params[param_key] | ||
if current_value.is_a?(Array) | ||
q_params[param_key] = current_value - [ param_value ] | ||
else | ||
q_params.delete(param_key) | ||
end | ||
|
||
updated_params[:q] = q_params | ||
|
||
transactions_path(updated_params) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,20 @@ | ||
module TransactionsHelper | ||
def transaction_filters | ||
[ | ||
{ name: "Account", partial: "account_filter", icon: "layers" }, | ||
{ name: "Date", partial: "date_filter", icon: "calendar" }, | ||
{ name: "Type", partial: "type_filter", icon: "shapes" }, | ||
{ name: "Amount", partial: "amount_filter", icon: "hash" }, | ||
{ name: "Category", partial: "category_filter", icon: "tag" }, | ||
{ name: "Merchant", partial: "merchant_filter", icon: "store" } | ||
] | ||
end | ||
def transactions_group(date, transactions, transaction_partial_path = "transactions/transaction") | ||
header_left = content_tag :span do | ||
"#{date.strftime('%b %d, %Y')} · #{transactions.size}".html_safe | ||
end | ||
|
||
def transaction_filter_id(filter) | ||
"txn-#{filter[:name].downcase}-filter" | ||
end | ||
header_right = content_tag :span do | ||
format_money(-transactions.sum(&:amount_money)) | ||
end | ||
|
||
def transaction_filter_by_name(name) | ||
transaction_filters.find { |filter| filter[:name] == name } | ||
end | ||
header = header_left.concat(header_right) | ||
|
||
content = render partial: transaction_partial_path, collection: transactions | ||
|
||
def full_width_transaction_row?(route) | ||
route != "/" | ||
render partial: "shared/list_group", locals: { | ||
header: header, | ||
content: content | ||
} | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See issue description for explanation of this.