143 lines
3.8 KiB
Text
143 lines
3.8 KiB
Text
<div class="mb-5">
|
|
<h1><%= @vote.title %></h1>
|
|
<ul class="list-unstyled">
|
|
<li>
|
|
<span class="badge bg-dark text-bg-dark"><%= _("Closed") %></span>
|
|
<% if @vote.users.exists?(current_user.id) %>
|
|
<span class="badge bg-warning text-bg-warning"><%= _("Organizer") %></span>
|
|
<% end %>
|
|
</li>
|
|
<% if @vote.expire_on %>
|
|
<li><%= _("Closed on %{date}") % { date: format_date_and_time(@vote.expire_on) } %></li>
|
|
<% end %>
|
|
</ul>
|
|
</div>
|
|
|
|
<div class="mb-5">
|
|
<div class="lead">
|
|
<%= markdown(@vote.description) %>
|
|
</div>
|
|
</div>
|
|
|
|
<h2 class="mb-4"><%= _("Candidates") %></h2>
|
|
|
|
<% @vote.candidates.each do |candidate| %>
|
|
<div class="card mb-4">
|
|
<div class="card-body">
|
|
<h3 class="mb-3"><%= candidate.name %></h3>
|
|
<%= markdown(candidate.description) %>
|
|
</div>
|
|
</div>
|
|
<% end %>
|
|
|
|
<div class="mb-5"></div>
|
|
|
|
<h2 class="mb-4"><%= _("Results") %></h2>
|
|
|
|
<% if @vote.ratings.blank? %>
|
|
|
|
<%= _("No results are available because nobody voted on this vote.") %>
|
|
|
|
<% else %>
|
|
|
|
<table class="table mb-4">
|
|
<tr>
|
|
<th></th>
|
|
<th><%= _("Rank") %></th>
|
|
<th><%= _("Candidate") %></th>
|
|
<th><%= _("Majority Judgment") %></th>
|
|
<th><%= _("Proponents") %></th>
|
|
<th><%= _("Opponents") %></th>
|
|
</tr>
|
|
<% i = 0 %>
|
|
<% @vote.candidates.sort { |a, b| a.mj <=> b.mj }.reverse.each do |candidate| %>
|
|
<% i = i + 1 %>
|
|
<% if i == 1 %>
|
|
<tr class="table-success">
|
|
<td><i class="bi bi-trophy-fill"></i></td>
|
|
<td><%= i %></i></td>
|
|
<% else %>
|
|
<tr>
|
|
<td></td>
|
|
<td><%= i %></td>
|
|
<% end %>
|
|
<td><%= candidate.name %></td>
|
|
<% value = settings.values.select { |e| e[:id] == candidate.mj.mj }.first %>
|
|
<td class="h5"><span class="badge bg-<%= value[:id] %>"><%= _(value[:label]) %></span></td>
|
|
<td><%= candidate.mj.proponents %></td>
|
|
<td><%= candidate.mj.opponents %></td>
|
|
</tr>
|
|
<% end %>
|
|
</table>
|
|
|
|
<%
|
|
data = []
|
|
colors = []
|
|
settings.values.reverse.each do |v|
|
|
d = { name: v[:label], data: [] }
|
|
@vote.candidates.sort { |a, b| a.mj <=> b.mj }.reverse.each do |c|
|
|
d[:data] << [c.name, c.mj.count[v[:id]]]
|
|
end
|
|
data << d
|
|
colors << v[:color]
|
|
end
|
|
%>
|
|
<%= bar_chart data, colors: colors, stacked: true, legend: 'bottom' %>
|
|
|
|
<div class="mb-5"></div>
|
|
|
|
<h2 class="mb-4"><%= _("Ratings") %></h2>
|
|
|
|
<table class="table table-striped mb-5">
|
|
<thead>
|
|
<tr>
|
|
<th><%= _("Participant") %></th>
|
|
<% @vote.candidates.each do |candidate| %>
|
|
<th><%= candidate.name %></th>
|
|
<% end %>
|
|
</tr>
|
|
</thead>
|
|
<% @vote.ratings.collect { |rating| rating.user }.uniq.each do |user| %>
|
|
<tr>
|
|
<td><%= user.email %></td>
|
|
<% @vote.candidates.each do |candidate| %>
|
|
<% if rating = @vote.ratings.find { |rating| rating.user == user and rating.candidate == candidate } %>
|
|
<% value = settings.values.select { |e| e[:id] == rating.value }.first %>
|
|
<td class="h5"><span class="badge bg-<%= value[:id] %>"><%= _(value[:label]) %></td>
|
|
<% end %>
|
|
<% end %>
|
|
</tr>
|
|
<% end %>
|
|
</table>
|
|
|
|
<% end %>
|
|
|
|
<% if @vote.users.exists?(current_user.id) and @vote.expire_on.nil? %>
|
|
|
|
<form action="/votes/<%= @vote.secure_id %>/reopen" method="post" class="mb-5">
|
|
<button type="submit" class="btn btn-outline-primary"><%= _("Reopen voting period") %></button>
|
|
</form>
|
|
|
|
<% end %>
|
|
|
|
<h2 class="mb-4"><%= _("Organizers") %></h2>
|
|
|
|
<ul>
|
|
<% @vote.organizers.each do |organizer| %>
|
|
<li><%= organizer.user.email %></li>
|
|
<% end %>
|
|
</ul>
|
|
|
|
<% if @vote.users.exists?(current_user.id) and @vote.expire_on.nil? %>
|
|
|
|
<h3 class="mb-3"><%= _("Add organizer") %></h3>
|
|
|
|
<form action="/votes/<%= @vote.secure_id %>/organizers" method="post" class="mb-5">
|
|
<div class="mb-3">
|
|
<label for="email" class="form-label"><%= _("Email") %></label>
|
|
<input type="text" name="email" class="form-control">
|
|
</div>
|
|
<button type="submit" class="btn btn-outline-primary"><%= _("Add organizer") %></button>
|
|
</form>
|
|
|
|
<% end %>
|