Skip to content

Commit

Permalink
feat(shared account): add show more button for shared account
Browse files Browse the repository at this point in the history
  • Loading branch information
VladislavSokov committed Sep 26, 2023
1 parent 1358aae commit bc5d532
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ document.addEventListener('turbolinks:load', function() {
if (!toggleButton) {
return
}
var transactionsHidden = true;
var tbodyRows = Array.from(document.querySelectorAll('tbody.transactions tr'));
var elementsHidden = true;
var tbodyRows = Array.from(document.querySelectorAll('tbody.toggleable tr'));

if (tbodyRows.length > 10) {
toggleRows();
Expand All @@ -21,7 +21,7 @@ document.addEventListener('turbolinks:load', function() {
e.preventDefault();
toggleRows();

toggleButton.textContent = transactionsHidden ? 'Hide' : 'Show all';
transactionsHidden = !transactionsHidden;
toggleButton.textContent = elementsHidden ? 'Hide' : 'Show all';
elementsHidden = !elementsHidden;
});
});
2 changes: 1 addition & 1 deletion app/javascript/packs/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ require("turbolinks").start()
require("@rails/activestorage").start()
require("channels")
require("menu/navbar")
require("account/transactions")
require("account/toggleButton")

// Uncomment to copy all static images under ../images to the output folder and reference
// them with the image_pack_tag helper in views (e.g <%= image_pack_tag 'rails.png' %>)
Expand Down
7 changes: 6 additions & 1 deletion app/views/account_shares/index.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,9 @@ h2.title.is-4
th Accepted
th Link
th Actions
= render partial: 'account_share', collection: account.account_shares.order(created_at: :desc)
tbody.toggleable
- account_shares = account.account_shares.order(created_at: :desc)
= render partial: 'account_share', collection: account_shares
- if account_shares.count > 10
.card-footer
= link_to "Show all", "#", id: "toggle-button", class: 'card-footer-item'
2 changes: 1 addition & 1 deletion app/views/accounts/show.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ h2.title.is-4
th Amount
th Description
th Actions
tbody.transactions
tbody.toggleable
- transactions = account.transactions
= render partial: 'transaction', collection: transactions, account: account
- if transactions.count > 10
Expand Down

0 comments on commit bc5d532

Please sign in to comment.