Skip to content
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

Show progress bars in public lottery draw page #1187

Merged
merged 2 commits into from
Nov 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 2 additions & 1 deletion app/models/lottery_division.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ def withdrawn_entrants
private

def broadcast_lottery_draw_header
broadcast_replace_to self, :lottery_draw_header, target: "draw_tickets_header_lottery_division_#{id}", partial: "lottery_divisions/draw_tickets_header", locals: {division: self}
broadcast_replace_to self, :lottery_draw_header, target: "draw_tickets_header_lottery_division_#{id}", partial: "lottery_divisions/draw_tickets_header", locals: { division: self }
broadcast_replace_to self, :lottery_header, target: "lottery_header_lottery_division_#{id}", partial: "lottery_divisions/tickets_progress_bars", locals: { division: self, show_pre_selected: false }
end

def ordered_drawn_entrants
Expand Down
12 changes: 12 additions & 0 deletions app/views/lotteries/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,18 @@
</div>
<% end %>

<hr/>
<div class="row">
<% @presenter.ordered_divisions.each do |division| %>
<%= turbo_stream_from division, :lottery_header, class: "d-none" %>
<div class="col-12 col-md-6 col-lg-4 col-xl">
<h5 class="fw-bold"><%= division.name %></h5>
<%= render partial: "lottery_divisions/tickets_progress_bars", locals: { division: division, show_pre_selected: false } %>
</div>
<% end %>
</div>
<hr/>

<div id="lottery_draws">
<%= render partial: "lottery_draws/lottery_draw", collection: @presenter.lottery_draws_ordered %>
</div>
Expand Down
39 changes: 2 additions & 37 deletions app/views/lottery_divisions/_draw_tickets_header.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -28,41 +28,6 @@
</div>
</div>

<div class="card mt-3">
<div class="card-body">
<div class="row">
<div class="col-8">
<h6 class="fw-bold">Accepted</h6>
</div>
<div class="col-4">
<h6 class="text-end"><%= "(#{division.accepted_entrants.count}/#{division.maximum_entries})" %></h6>
</div>
</div>
<div class="progress">
<%= bootstrap_progress_bar(min_value: 0, max_value: division.maximum_entries, current_value: division.accepted_entrants.count, color: "success") %>
</div>
<div class="row mt-2">
<div class="col-8">
<h6 class="fw-bold">Wait List</h6>
</div>
<div class="col-4">
<h6 class="text-end"><%= "(#{division.wait_list_entrants.count}/#{division.maximum_wait_list})" %></h6>
</div>
</div>
<div class="progress">
<%= bootstrap_progress_bar(min_value: 0, max_value: division.maximum_wait_list, current_value: division.wait_list_entrants.count, color: "warning") %>
</div>
<div class="row mt-2">
<div class="col-8">
<h6 class="fw-bold">Pre-selected</h6>
</div>
<div class="col-4">
<h6 class="text-end"><%= "(#{division.entrants.pre_selected.drawn.count}/#{division.entrants.pre_selected.count})" %></h6>
</div>
</div>
<div class="progress">
<%= bootstrap_progress_bar(min_value: 0, max_value: division.entrants.pre_selected.count, current_value: division.entrants.pre_selected.drawn.count, color: "secondary") %>
</div>
</div>
</div>
<%= render partial: "lottery_divisions/tickets_progress_bars", locals: { division: division, show_pre_selected: true} %>

</div>
41 changes: 41 additions & 0 deletions app/views/lottery_divisions/_tickets_progress_bars.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<%# locals: (division:, show_pre_selected:) -%>

<div id="<%= dom_id(division, :lottery_header) %>" class="card mt-3">
<div class="card-body">
<div class="row">
<div class="col-8">
<h6 class="fw-bold">Accepted</h6>
</div>
<div class="col-4">
<h6 class="text-end"><%= "(#{division.accepted_entrants.count}/#{division.maximum_entries})" %></h6>
</div>
</div>
<div class="progress">
<%= bootstrap_progress_bar(min_value: 0, max_value: division.maximum_entries, current_value: division.accepted_entrants.count, color: "success") %>
</div>
<div class="row mt-2">
<div class="col-8">
<h6 class="fw-bold">Wait List</h6>
</div>
<div class="col-4">
<h6 class="text-end"><%= "(#{division.wait_list_entrants.count}/#{division.maximum_wait_list})" %></h6>
</div>
</div>
<div class="progress">
<%= bootstrap_progress_bar(min_value: 0, max_value: division.maximum_wait_list, current_value: division.wait_list_entrants.count, color: "warning") %>
</div>
<% if show_pre_selected %>
<div class="row mt-2">
<div class="col-8">
<h6 class="fw-bold">Pre-selected</h6>
</div>
<div class="col-4">
<h6 class="text-end"><%= "(#{division.entrants.pre_selected.drawn.count}/#{division.entrants.pre_selected.count})" %></h6>
</div>
</div>
<div class="progress">
<%= bootstrap_progress_bar(min_value: 0, max_value: division.entrants.pre_selected.count, current_value: division.entrants.pre_selected.drawn.count, color: "secondary") %>
</div>
<% end %>
</div>
</div>
Loading