Rewrite views with Bootstrap

This commit is contained in:
ricola 2025-12-04 01:00:19 +01:00
parent 529f7118b1
commit 5a278fcddf
19 changed files with 424 additions and 279 deletions

View file

@ -1,38 +1,76 @@
<h1><%= @vote.title %></h1>
<div class="mb-5">
<h1><%= @vote.title %></h1>
<ul class="list-unstyled">
<li>
<span class="badge bg-secondary"><%= _("Draft") %></span>
<span class="badge bg-warning text-bg-warning"><%= _("Organizer") %></span>
</li>
</ul>
</div>
<p><span class="badge bg-primary">Draft</span></p>
<div class="mb-5">
<div class="lead">
<%= markdown(@vote.description) %>
</div>
<form action="/votes/<%= @vote.secure_id %>/edit" method="get" class="mb-5">
<button type="submit" class="btn btn-outline-primary"><%= _("Edit") %></button>
</form>
</div>
<%= markdown(@vote.description) %>
<form action="/votes/<%= @vote.secure_id %>/edit" method="get">
<button type="submit"><%= _("Edit") %></button>
</form>
<h2><%= _("Candidates") %></h2>
<h2 class="mb-4"><%= _("Candidates") %></h2>
<% @vote.candidates.each do |candidate| %>
<h3><%= candidate.name %></h3>
<%= markdown(candidate.description) %>
<form action="/votes/<%= @vote.secure_id %>/candidates/<%= candidate.id %>/delete" method="post">
<button type="submit"><%= _("Delete") %></button>
</form>
<div class="card mb-4">
<div class="card-body">
<h3 class="mb-3"><%= candidate.name %></h3>
<%= markdown(candidate.description) %>
<form action="/votes/<%= @vote.secure_id %>/candidates/<%= candidate.id %>/delete" method="post">
<button type="submit" class="btn btn-outline-danger"><%= _("Delete") %></button>
</form>
</div>
</div>
<% end %>
<h3><%= _("Add candidate") %></h3>
<div class="card mb-4">
<div class="card-body">
<h3 class="mb-3"><%= _("Add candidate") %></h3>
<% if @vote.candidates.empty? %>
<div class="alert alert-primary mb-4"><%= _("This vote has no candidates yet. Add a first candidate.") %></div>
<% end %>
<form action="/votes/<%= @vote.secure_id %>/candidates" method="post">
<div class="mb-3">
<label for="name" class="form-label"><%= _("Name") %></label>
<input type="text" name="name" class="form-control">
</div>
<div class="mb-3">
<label for="description" class="form-label"><%= _("Description") %></label>
<textarea type="text" name="description" class="form-control"></textarea>
</div>
<% if @vote.candidates.length < 2 %>
<button type="submit" class="btn btn-primary"><%= _("Add candidate") %></button>
<% else %>
<button type="submit" class="btn btn-outline-primary"><%= _("Add candidate") %></button>
<% end %>
</form>
</div>
</div>
<form action="/votes/<%= @vote.secure_id %>/candidates" method="post">
<p>
<label for="name"><%= _("Name") %></label>
<input type="text" name="name">
</p>
<p>
<label for="description"><%= _("Description") %></label>
<textarea type="text" name="description"></textarea>
</p>
<button type="submit"><%= _("Add candidate") %></button>
<form action="/votes/<%= @vote.secure_id %>/open" method="get" class="mb-3">
<% if @vote.candidates.length < 2 %>
<p class="alert alert-warning mb-4"><%= _("Add at least 2 candidates before opening the vote to participants.") %></p>
<fieldset disabled="">
<% end %>
<button type="submit" class="btn btn-primary"><%= _("Open vote to participants") %></button>
<% if @vote.candidates.length < 2 %>
</fieldset>
<% end %>
</form>
<h2><%= _("Organizers") %></h2>
<form action="/votes/<%= @vote.secure_id %>/delete" method="post" class="mb-5">
<button type="submit" class="btn btn-outline-danger"><%= _("Delete vote") %></button>
</form>
<h2 class="mb-4"><%= _("Organizers") %></h2>
<ul>
<% @vote.organizers.each do |organizer| %>
@ -40,26 +78,12 @@
<% end %>
</ul>
<h3><%= _("Add organizer") %></h3>
<h3 class="mb-3"><%= _("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>
<h3><%= _("Actions for organizers") %></h2>
<form action="/votes/<%= @vote.secure_id %>/open" method="get">
<% if @vote.candidates.length < 2 %>
<button type="submit" disabled><%= _("Open vote to participants") %></button>
<p><%= _("Add at least 2 candidates before opening the vote to participants.") %></p>
<% else %>
<button type="submit"><%= _("Open vote to participants") %></button>
<% end %>
</form>
<form action="/votes/<%= @vote.secure_id %>/delete" method="post">
<button type="submit"><%= _("Delete vote") %></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>