vedia/views/votes.erb
2026-01-09 15:35:33 -06:00

34 lines
1.3 KiB
Text

<h1 class="mb-5"><%= _("Votes") %></h1>
<table class="table table-striped mb-5">
<tbody>
<% @votes.reverse.each do |vote| %>
<tr>
<td><%= format_date(vote.created_at) %></td>
<td class="text-nowrap">
<% case vote.state
when 'draft' %>
<span class="badge bg-secondary"><%= _("Draft") %></span>
<% when 'open' %>
<span class="badge bg-primary"><%= _("Open") %></span>
<% when 'closed' %>
<SPAN class="badge bg-dark"><%= _("Closed") %></span>
<% end %>
<% if vote.ratings.find { |rating| rating.user == current_user } %>
<span class="badge bg-success"><%= _("Voted") %></span>
<% elsif vote.state == 'open' %>
<span class="badge bg-danger"><%= _("Not voted") %></span>
<% end %>
<% if vote.users.exists?(current_user.id) %>
<span class="badge bg-warning text-bg-warning"><%= _("Organizer") %></span>
<% end %>
</td>
<td><a href="/votes/<%= vote.secure_id %>"><%= vote.title %></a></td>
</tr>
<% end %>
</tbody>
</table>
<form action="/votes/new" method="get">
<button type="submit" class="btn btn-primary"><%= _("Create new vote") %></button>
</form>