Add transactions widget to dashboard page #656
Reference in New Issue
Block a user
Delete Branch "feature/transactions-widget"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
closes #649
I added the transactions widget to the dashboard:
@zachgoll for this, I’ve reused the transaction partial. Currently, when a user clicks on a transaction, an edit modal opens. Should we maintain this behavior, or would it be better to make the widget "read-only"?
@mattia-malnis looking good! I think it's okay if we keep the the modal functionality.
@@ -1,17 +1,22 @@<%# locals: (transaction:) %>Small nitpick here, but since we're unsure where a transaction will be shown in the UI, do you think instead of
is_widget, we introduce something likefields: [:name, :category, :account, :amount]that explicitly tells the partial which transaction fields to display and the sizing automatically works based on that?@@ -1,17 +1,22 @@<%# locals: (transaction:) %>I think introducing the
fieldsconcept is a good idea! However, with the current code structure, dynamic size calculation could be tricky. I'm not entirely sure how to handle it because the same partial should fit both a narrow widget and a wide page while keeping the columns aligned.Using a
<table>could potentially fix this issue, but it might be a bit old-fashionedc46662c99f/app/views/transactions/_transaction.html.erb (L3)c46662c99f/app/views/transactions/_transaction.html.erb (L8)@zachgoll I noticed there's an issue with the category dropdown (in the
mainbranch):transactions_path, which could be misleading for a user who is on the dashboard or the account details page.I think it's better to open a new issue for these problems.
@@ -1,17 +1,22 @@<%# locals: (transaction:) %>If it's too challenging I think it's okay if we keep it as-is. A table will introduce styling challenges of its own and make it less flexible to deal with if we start introducing inline turbo frame editing to this partial.
@mattia-malnis yep, I'm seeing that bug with the categories too. I agree that we should open a separate issue for that and it's probably worth including all of them in one issue as an "Improvements" (even though technically there is a bug in there). Looks like we need to address the redirects behavior, some Turbo Streams, the bug, and a few others.
If you want to open up an issue outlining what you're seeing I can go back through and update it with any additional things that we might want to cover in it.
@zachgoll This PR is ready for review!
I'm gonna open a separate issue regarding the categories dropdown issue, either later today or tomorrow
I opened the issue related to the categories dropdown: #659
@@ -1,17 +1,22 @@<%# locals: (transaction:) %>In order for the Tailwind JIT compiler to scan and find all the static classes it needs to include, each class needs to be complete. The JIT compiler cannot execute code, so this could cause unexpected styles in prod:
https://tailwindcss.com/docs/content-configuration#dynamic-class-names
@@ -1,5 +1,8 @@<%# locals: (date:, transactions:) %><div class="bg-gray-25 rounded-xl p-1"><%# locals: (transaction_group:) %>While I'm fine with the
is_widgetconcept, I don't think we should be passingis_widgetthrough so many partials (_transaction_group,_menu,_row) and storing in query params. Many of these partials don't need to know about this config and are simply passing it along.I think we could isolate this piece of logic better by encapsulating it directly in the
_transactionpartial and using a helper to determine the setting. While this solution still doesn't feel like the best, it reduces the surface area for change and will allow us to update one file in the future if we do come up with a better solution (rather than having to pass locals to so many partials):@@ -1,5 +1,8 @@<%# locals: (date:, transactions:) %><div class="bg-gray-25 rounded-xl p-1"><%# locals: (transaction_group:) %>I agree with you, I'm passing
is_widgetto many partials, and the code could be difficult to maintain. Unfortunately, I don't think that moving the logic inside atransactions_helper.rbwill fix the problem:1 - On the dashboard,
request.pathis "/";2 - When I edit the transaction from the dashboard,
request.pathis "/transactions/:id";3 - On the transactions page,
request.pathis "/transactions";4 - When I edit the transaction from the transactions page,
request.pathis "/transactions/:id";As you can see from points 2 and 4,
request.pathis the same (as we're pointing totransactions#update) but for point 2, we need the widget version, while for point 4, we need the full-width version.Probably, this could be a solution (there could be some mistakes, I just want to give an idea):
By doing so, I can leave
is_widgetonly on the_transactionpartial. The controller will render all, and when we are on the dashboard, Turbo will skip thetransactions/transaction_account_namepartial because it won't find the corresponding id.What do you think about that?
@@ -1,5 +1,8 @@<%# locals: (date:, transactions:) %><div class="bg-gray-25 rounded-xl p-1"><%# locals: (transaction_group:) %>@mattia-malnis got it, I understand what you're saying now. I was not considering the stream response that's being constructed after editing.
While long term I'd imagine we'll introduce editing from the dashboard, it sounds like if we made it "read only" on the dashboard we could use the helper and avoid this. Am I thinking about that correctly?
If so, I think we'd be totally fine to make this read only for now to avoid all the extra complexity.
@@ -1,5 +1,8 @@<%# locals: (date:, transactions:) %><div class="bg-gray-25 rounded-xl p-1"><%# locals: (transaction_group:) %>@zachgoll I updated the code following your advice on using the
full_width_transaction_row?helper and making the widget read-only!@@ -1,5 +1,8 @@<%# locals: (date:, transactions:) %><div class="bg-gray-25 rounded-xl p-1"><%# locals: (transaction_group:) %>Looks good!