Skip to content
Open
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
8cecccc
Add basic styling
manuthecoder Jun 17, 2025
ac6f4bc
[Buttons] Adjust SVG visibility for sort button active state
manuthecoder Jun 17, 2025
7cc65ce
Fix hover and focus states
manuthecoder Jun 17, 2025
a3bf6d0
[Buttons] Enhance sort button styles with active state and rotation e…
manuthecoder Jun 17, 2025
ed81fc3
Add filters for all columns
manuthecoder Jun 17, 2025
a5aa684
Fix table links
manuthecoder Jun 17, 2025
2c198a0
Fix arrow styling and add basic sorting functionality to the invoices…
manuthecoder Jun 17, 2025
f06d23c
Finalize logic
manuthecoder Jun 17, 2025
5539579
Refactor invoice table header to remove unnecessary text alignment class
manuthecoder Jun 17, 2025
9b6b5f6
Lint!
manuthecoder Jun 17, 2025
2aa6f5e
Remove unused styles
manuthecoder Jun 17, 2025
ccc44ac
Fix failing checks
manuthecoder Jun 17, 2025
6038246
Update app/controllers/invoices_controller.rb
manuthecoder Jun 17, 2025
b49dc63
Merge branch 'main' into add-invoice-sorting-ability
manuthecoder Jun 17, 2025
6e59634
Merge branch 'main' into add-invoice-sorting-ability
manuthecoder Jun 19, 2025
ae0c9d8
Merge branch 'main' into add-invoice-sorting-ability
manuthecoder Jun 21, 2025
9c4e512
[Buttons] Update sort button color for dark mode
manuthecoder Jun 23, 2025
e0c822a
Fix syntax for dark mode color in sort button styles
manuthecoder Jun 23, 2025
a5c7fdb
Improve controller!
manuthecoder Jun 23, 2025
bc9cd4c
Merge branch 'main' into add-invoice-sorting-ability
manuthecoder Jun 24, 2025
2c87cce
Merge branch 'main' into add-invoice-sorting-ability
manuthecoder Jun 24, 2025
24269a6
Merge branch 'main' into add-invoice-sorting-ability
manuthecoder Jun 25, 2025
7382574
Fix invoice assignment in the index action
manuthecoder Jun 25, 2025
51b3ade
Change instance varian;e
manuthecoder Jun 25, 2025
963bb94
Merge branch 'main' into add-invoice-sorting-ability
manuthecoder Jul 8, 2025
beeeae4
[Invoices] Simplify sort column and direction assignment logic
manuthecoder Jul 8, 2025
ff82793
Refactor sorting logic in event table header for clarity and maintain…
manuthecoder Jul 8, 2025
fe326a5
Refactor direction variable assignment for improved clarity in sortin…
manuthecoder Jul 8, 2025
0019163
Update app/views/events/_sort_table_header.html.erb
manuthecoder Jul 8, 2025
cfcefa0
Update app/views/events/_sort_table_header.html.erb
manuthecoder Jul 8, 2025
ea4ae5b
Update app/views/events/_sort_table_header.html.erb
manuthecoder Jul 8, 2025
0828e78
Update app/views/events/_sort_table_header.html.erb
manuthecoder Jul 8, 2025
b76899c
Merge branch 'main' into add-invoice-sorting-ability
manuthecoder Jul 16, 2025
022a036
Merge branch 'main' into add-invoice-sorting-ability
manuthecoder Jul 16, 2025
bc01976
Merge branch 'main' into add-invoice-sorting-ability
manuthecoder Aug 2, 2025
2623087
Update app/controllers/invoices_controller.rb
manuthecoder Aug 14, 2025
c270816
Merge branch 'main' into add-invoice-sorting-ability
manuthecoder Aug 14, 2025
5ef0c32
Update app/controllers/invoices_controller.rb
manuthecoder Aug 14, 2025
a2adc39
Refactor sorting logic in events table header for clarity and correct…
manuthecoder Aug 14, 2025
730145b
Refactor invoice table header to use dynamic columns for improved mai…
manuthecoder Aug 16, 2025
b934f31
Refactor invoices view to use instance variable for table columns and…
manuthecoder Aug 16, 2025
9a960ec
Merge branch 'main' into add-invoice-sorting-ability
manuthecoder Aug 16, 2025
c274173
Merge branch 'main' into add-invoice-sorting-ability
manuthecoder Aug 24, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions app/assets/stylesheets/components/_buttons.scss
Original file line number Diff line number Diff line change
Expand Up @@ -196,3 +196,43 @@ form .flex-auto + input[type='submit'] {
}
}
}

.sort-button {
text-decoration: none;
display: inline-flex;
align-items: center;
justify-content: start;
width: 100%;
font-weight: 600;
transition: color 0.125s ease-in-out;
gap: 0.5rem;

&.sort-button--right {
justify-content: end;
flex-direction: row-reverse;
}

&:hover,
&:focus {
color: map-get($palette, info);
}

& svg {
width: 16px;
height: 16px;
fill: currentColor;
opacity: 0;
transition:
opacity 0.125s ease-in-out,
transform 0.125s ease-in-out;
}

&:hover svg,
&:focus svg {
opacity: 1;
}

&.sort-button--active svg {
opacity: 1;
}
}
16 changes: 15 additions & 1 deletion app/controllers/invoices_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,19 @@ def index

relation = relation.search_description(params[:q]) if params[:q].present?

@invoices = relation.order(created_at: :desc)
allowed_sorts = {
"created_at" => "invoices.created_at",
"status" => "invoices.status",
"sponsors.name" => "sponsors.name",
"amount_due" => "invoices.amount_due"
}
allowed_directions = %w[asc desc]

sort_column = allowed_sorts[params[:sort]] || "invoices.created_at"
sort_direction = allowed_directions.include?(params[:direction]) ? params[:direction] : "desc"

relation = relation.joins(:sponsor) if sort_column == "sponsors.name"
relation = relation.order("#{sort_column} #{sort_direction}")

@sponsor = Sponsor.new(event: @event)
@invoice = Invoice.new(sponsor: @sponsor, event: @event)
Expand Down Expand Up @@ -89,6 +101,8 @@ def index
@invoices[i].state_text = "Sent"
@stats[:pending] += @invoices[i].item_amount
end
else
@invoices = relation
end
end

Expand Down
17 changes: 17 additions & 0 deletions app/views/events/_sort_table_header.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<% @active = params[:sort] == sort || (params[:sort].nil? && defined?(default) && default) %>

<%= link_to(
upsert_query_params(
sort: sort,
direction: params[:sort] == sort ?
(params[:direction] == "asc" ? "desc" : "asc") :
params[:direction] || "asc"
),
class: "sort-button #{@active ? 'sort-button--active' : ''} #{'sort-button--right' if defined?(right) && right}"
) do %>
<%= defined?(display) && display ? display : sort.humanize %>
<%= inline_icon(
params[:direction] == "desc" ? "down-caret" : "up-caret",
size: 16
) %>
<% end %>
16 changes: 12 additions & 4 deletions app/views/invoices/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,18 @@
<table>
<thead>
<tr>
<th>Status</th>
<th>Date</th>
<th>To</th>
<th class="text-right">Amount</th>
<th>
<%= render "events/sort_table_header", sort: "status" %>
</th>
<th>
<%= render "events/sort_table_header", sort: "date", default: true %>
</th>
<th>
<%= render "events/sort_table_header", sort: "sponsors.name", display: "To" %>
</th>
<th>
<%= render "events/sort_table_header", sort: "amount_due", right: true, display: "Amount" %>
</th>
<th></th>
</tr>
</thead>
Expand Down
Loading