Rewrite views with Bootstrap
This commit is contained in:
parent
529f7118b1
commit
5a278fcddf
19 changed files with 424 additions and 279 deletions
|
|
@ -1,57 +1,82 @@
|
|||
<h1><%= @vote.title %></h1>
|
||||
<div class="mb-5">
|
||||
<h1><%= @vote.title %></h1>
|
||||
<ul class="list-unstyled">
|
||||
<li>
|
||||
<span class="badge bg-primary"><%= _("Open") %></span>
|
||||
</li>
|
||||
<% if @vote.expire_on %>
|
||||
<li><%= _("Closes 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"><%= _("Options") %></h2>
|
||||
|
||||
<% if @errors %>
|
||||
<% @errors.each do |error| %>
|
||||
<% if error.attribute == :rating and error.type == :blank %>
|
||||
<p class="error"><%= _("Missing rating for candidate <i>%{name}</i>.") % { name: error.candidate.name } %></p>
|
||||
<p class="alert alert-warning mb-4"><%= _("Missing rating for candidate <i>%{name}</i>.") % { name: error.candidate.name } %></p>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
<% if @vote.expire_on %>
|
||||
<p><%= _("Closing date: %{date}") % { date: format_date_and_time(@vote.expire_on) } %></p>
|
||||
<% end %>
|
||||
<form action="/votes/<%= @vote.secure_id %>/ratings" method="post" class="mb-5">
|
||||
|
||||
<%= markdown(@vote.description) %>
|
||||
|
||||
<h2><%= _("Your ratings") %></h2>
|
||||
|
||||
<form action="/votes/<%= @vote.secure_id %>/ratings" method="post">
|
||||
<ul>
|
||||
<% @vote.candidates.each do |candidate| %>
|
||||
<% rating = @vote.ratings.find { |rating| rating.user == current_user and rating.candidate == candidate } %>
|
||||
<% if rating
|
||||
value = rating.value
|
||||
elsif @params[candidate.id.to_s]
|
||||
value = params[candidate.id.to_s].to_i
|
||||
else
|
||||
value = 0
|
||||
end %>
|
||||
<li>
|
||||
<p><b><%= candidate.name %></b></p>
|
||||
<%= markdown(candidate.description) %>
|
||||
<ul>
|
||||
<% settings.values.reverse.each do |v| %>
|
||||
<li><input type="radio" name="<%= candidate.id %>" id="<%= candidate.id %>-<%= v[:id] %>" value="<%= v[:id] %>" <% if value == v[:id] %>checked<% end %>><label for="<%= candidate.id %>-<%= v[:id] %>" class="value-<%= v[:id] %>"><%= _(v[:label]) %></label></li>
|
||||
<% end %>
|
||||
</ul>
|
||||
</li>
|
||||
<div class="card mb-4">
|
||||
<div class="card-body">
|
||||
<h3 class="mb-3"><%= candidate.name %></h3>
|
||||
<%= markdown(candidate.description) %>
|
||||
<% rating = @vote.ratings.find { |rating| rating.user == current_user and rating.candidate == candidate } %>
|
||||
<% if rating
|
||||
value = rating.value
|
||||
elsif @params[candidate.id.to_s]
|
||||
value = params[candidate.id.to_s].to_i
|
||||
else
|
||||
value = 0
|
||||
end %>
|
||||
<div class="btn-group">
|
||||
<% settings.values.reverse.each do |v| %>
|
||||
<input type="radio" name="<%= candidate.id %>" id="<%= candidate.id %>-<%= v[:id] %>" value="<%= v[:id] %>" class="btn-check" <% if value == v[:id] %>checked<% end %>>
|
||||
<label for="<%= candidate.id %>-<%= v[:id] %>" class="btn btn-radio-<%= v[:id] %>"><%= _(v[:label]) %></label>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
</ul>
|
||||
<button type="submit"><%= _("Save") %></button>
|
||||
|
||||
<button type="submit" class="btn btn-primary"><%= _("Vote") %></button>
|
||||
</form>
|
||||
|
||||
<h2><%= _("Participants") %></h2>
|
||||
<h2 class="mb-4"><%= _("Participants") %></h2>
|
||||
|
||||
<ul>
|
||||
<ul class="mb-5">
|
||||
<% @vote.ratings.collect { |rating| rating.user }.uniq.each do |user| %>
|
||||
<li><%= user.email %></li>
|
||||
<% end %>
|
||||
</ul>
|
||||
|
||||
<% if @vote.users.exists?(current_user.id) and @vote.expire_on.nil? %>
|
||||
|
||||
<form action="/votes/<%= @vote.secure_id %>/draft" method="post">
|
||||
<button type="submit" class="btn btn-outline-danger mb-3"><%= _("Change back to draft vote") %></button>
|
||||
</form>
|
||||
|
||||
<form action="/votes/<%= @vote.secure_id %>/close" method="post" class="mb-5">
|
||||
<button type="submit" class="btn btn-outline-primary mb-3"><%= _("Close votes and show results") %></button>
|
||||
</form>
|
||||
|
||||
<% end %>
|
||||
|
||||
<% unless @vote.organizers.blank? %>
|
||||
|
||||
<h2><%= _("Organizers") %></h2>
|
||||
<h2 class="mb-4"><%= _("Organizers") %></h2>
|
||||
|
||||
<ul>
|
||||
<% @vote.organizers.each do |organizer| %>
|
||||
|
|
@ -61,26 +86,16 @@
|
|||
|
||||
<% end %>
|
||||
|
||||
<% if @vote.users.exists?(current_user.id) and @vote.expire_on.nil? %>
|
||||
<% if @vote.users.exists?(current_user.id) or @vote.expire_on.nil? %>
|
||||
|
||||
<h3><%= _("Actions for organizers") %></h3>
|
||||
<h3 class="mb-3"><%= _("Add organizer") %></h3>
|
||||
|
||||
<form action="/votes/<%= @vote.secure_id %>/draft" method="post">
|
||||
<button type="submit"><%= _("Change back to draft vote") %></button>
|
||||
</form>
|
||||
|
||||
<form action="/votes/<%= @vote.secure_id %>/close" method="post">
|
||||
<button type="submit"><%= _("Close votes and show results") %></button>
|
||||
</form>
|
||||
|
||||
<h3><%= _("Add organizer") %></h3>
|
||||
|
||||
<form action="/votes/<%= @vote.secure_id %>/organizers" method="post">
|
||||
<p>
|
||||
<label for="email"><%= _("Email") %></label>
|
||||
<input type="text" name="email">
|
||||
</p>
|
||||
<button type="submit"><%= _("Add organizer") %></button>
|
||||
<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 %>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue