Display only one of description and tiebreak at once
This commit is contained in:
parent
6c700a8f13
commit
103fcd6e50
1 changed files with 86 additions and 84 deletions
|
|
@ -71,91 +71,93 @@
|
||||||
</a>
|
</a>
|
||||||
<% end %>
|
<% end %>
|
||||||
</p>
|
</p>
|
||||||
<div class="collapse" id="description-<%= r %>">
|
<div id="content-wrapper-<%= r %>">
|
||||||
<%= markdown(c.description) %>
|
<div class="collapse" data-bs-parent="#content-wrapper-<%= r %>" id="description-<%= r %>">
|
||||||
</div>
|
<%= markdown(c.description) %>
|
||||||
<% if r > 1 and c.mj.mj == @results.first.mj.mj %>
|
|
||||||
<div class="collapse" id="tiebreak-<%= r %>">
|
|
||||||
<p>
|
|
||||||
<%= _("This candidate and the winning candidate have the same majority judgment.") %>
|
|
||||||
</p>
|
|
||||||
<p><%= _("To break the tie, we remove the vote that corresponds to the majority judgment one-by-one until one candidate has a better majority judgment than the other.") %></p>
|
|
||||||
<div class="row fw-bold">
|
|
||||||
<div class="col"><%= _("Votes for this candidate") %></div>
|
|
||||||
<div class="col text-end"><%= _("Votes for the winning candidate") %></div>
|
|
||||||
</div>
|
|
||||||
<table class="table table-borderless tiebreak">
|
|
||||||
<% n = 0 %>
|
|
||||||
<% previous = nil %>
|
|
||||||
<% max = @results.first.mj.n * 2 + 1 %>
|
|
||||||
<% c.mj.break_tie(@results.first.mj).each do |a, b| %>
|
|
||||||
<tr class="tiebreak-top">
|
|
||||||
<td colspan="<%= max %>"></td>
|
|
||||||
</tr>
|
|
||||||
<tr class="tiebreak-round">
|
|
||||||
<td colspan="<%= max %>">
|
|
||||||
<% if n == 0 %>
|
|
||||||
<% current = erb :rating_badge, :locals => { :value => settings.values.select { |e| e[:id] == a.mj }.first } %>
|
|
||||||
<%= _("Without removing any vote, both candidates have the same majority judgement of %{current}.") % { current: current } %>
|
|
||||||
<% end %>
|
|
||||||
<% if n == 1 %>
|
|
||||||
<% if a.mj == b.mj %>
|
|
||||||
<% current = erb :rating_badge, :locals => { :value => settings.values.select { |e| e[:id] == a.mj }.first } %>
|
|
||||||
<%= _("Removing a vote of rating %{previous}, both candidates still have the same majority judgement of %{current}.") % { previous: previous, current: current } %>
|
|
||||||
<% else %>
|
|
||||||
<% losing = erb :rating_badge, :locals => { :value => settings.values.select { |e| e[:id] == a.mj }.first } %>
|
|
||||||
<% winning = erb :rating_badge, :locals => { :value => settings.values.select { |e| e[:id] == b.mj }.first } %>
|
|
||||||
<%= _("Removing a vote of rating %{previous}, this candidate has a majority judgement of %{losing}, but the winning candidate has a majority judgement of %{winning}.") % { previous: previous, losing: losing, winning: winning } %>
|
|
||||||
<% end %>
|
|
||||||
<% end %>
|
|
||||||
<% if n > 1 %>
|
|
||||||
<% if a.mj == b.mj %>
|
|
||||||
<% current = erb :rating_badge, :locals => { :value => settings.values.select { |e| e[:id] == a.mj }.first } %>
|
|
||||||
<%= _("Removing another vote of rating %{previous}, both candidates still have the same majority judgement of %{current}.") % { previous: previous, current: current } %>
|
|
||||||
<% else %>
|
|
||||||
<% losing = erb :rating_badge, :locals => { :value => settings.values.select { |e| e[:id] == a.mj }.first } %>
|
|
||||||
<% winning = erb :rating_badge, :locals => { :value => settings.values.select { |e| e[:id] == b.mj }.first } %>
|
|
||||||
<%= _("Removing another vote of rating %{previous}, this candidate has a majority judgement of %{losing}, but the winning candidate has a majority judgement of %{winning}.") % { previous: previous, losing: losing, winning: winning } %>
|
|
||||||
<% end %>
|
|
||||||
<% end %>
|
|
||||||
<% previous = erb :rating_badge, :locals => { :value => settings.values.select { |e| e[:id] == a.mj }.first } %>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<% (1..a.n).each do |i| %>
|
|
||||||
<td class="p-0 text-center <% unless i == a.majority %>opacity-0<% end %>">↓</td>
|
|
||||||
<% end %>
|
|
||||||
<td colspan="<%= max - a.n - b.n %>"></td>
|
|
||||||
<% (1..b.n).each do |i| %>
|
|
||||||
<td class="p-0 text-center <% unless b.n - i + 1 == b.majority %>opacity-0<% end %>">↓</td>
|
|
||||||
<% end %>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<% i = 0 %>
|
|
||||||
<% settings.values.reverse.each do |v| %>
|
|
||||||
<% (1..a.count[v[:id]]).each do |r| %>
|
|
||||||
<% i = i + 1 %>
|
|
||||||
<td class="p-0 mj-cell mj-cell-<%= v[:id] %><% if i == a.majority and a.mj == b.mj %> mj-cell-majority<% end %>"> </td>
|
|
||||||
<% end %>
|
|
||||||
<% end %>
|
|
||||||
<td class="p-0 text-center fw-bold" colspan="<%= max - a.n - b.n %>">
|
|
||||||
<% if a.mj < b.mj %><<% end %>
|
|
||||||
<% if a.mj > b.mj %>><% end %>
|
|
||||||
<% if a.mj == b.mj %>=<% end %>
|
|
||||||
</td>
|
|
||||||
<% i = 0 %>
|
|
||||||
<% settings.values.each do |v| %>
|
|
||||||
<% (1..b.count[v[:id]]).each do |r| %>
|
|
||||||
<% i = i + 1 %>
|
|
||||||
<td class="p-0 mj-cell mj-cell-<%= v[:id] %><% if b.n - i + 1 == b.majority and a.mj == b.mj %> mj-cell-majority<% end %>"> </td>
|
|
||||||
<% end %>
|
|
||||||
<% end %>
|
|
||||||
</tr>
|
|
||||||
<% n = n + 1 %>
|
|
||||||
<% end %>
|
|
||||||
</table>
|
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% if r > 1 and c.mj.mj == @results.first.mj.mj %>
|
||||||
|
<div class="collapse" data-bs-parent="#content-wrapper-<%= r %>" id="tiebreak-<%= r %>">
|
||||||
|
<p>
|
||||||
|
<%= _("This candidate and the winning candidate have the same majority judgment.") %>
|
||||||
|
</p>
|
||||||
|
<p><%= _("To break the tie, we remove the vote that corresponds to the majority judgment one-by-one until one candidate has a better majority judgment than the other.") %></p>
|
||||||
|
<div class="row fw-bold">
|
||||||
|
<div class="col"><%= _("Votes for this candidate") %></div>
|
||||||
|
<div class="col text-end"><%= _("Votes for the winning candidate") %></div>
|
||||||
|
</div>
|
||||||
|
<table class="table table-borderless tiebreak">
|
||||||
|
<% n = 0 %>
|
||||||
|
<% previous = nil %>
|
||||||
|
<% max = @results.first.mj.n * 2 + 1 %>
|
||||||
|
<% c.mj.break_tie(@results.first.mj).each do |a, b| %>
|
||||||
|
<tr class="tiebreak-top">
|
||||||
|
<td colspan="<%= max %>"></td>
|
||||||
|
</tr>
|
||||||
|
<tr class="tiebreak-round">
|
||||||
|
<td colspan="<%= max %>">
|
||||||
|
<% if n == 0 %>
|
||||||
|
<% current = erb :rating_badge, :locals => { :value => settings.values.select { |e| e[:id] == a.mj }.first } %>
|
||||||
|
<%= _("Without removing any vote, both candidates have the same majority judgement of %{current}.") % { current: current } %>
|
||||||
|
<% end %>
|
||||||
|
<% if n == 1 %>
|
||||||
|
<% if a.mj == b.mj %>
|
||||||
|
<% current = erb :rating_badge, :locals => { :value => settings.values.select { |e| e[:id] == a.mj }.first } %>
|
||||||
|
<%= _("Removing a vote of rating %{previous}, both candidates still have the same majority judgement of %{current}.") % { previous: previous, current: current } %>
|
||||||
|
<% else %>
|
||||||
|
<% losing = erb :rating_badge, :locals => { :value => settings.values.select { |e| e[:id] == a.mj }.first } %>
|
||||||
|
<% winning = erb :rating_badge, :locals => { :value => settings.values.select { |e| e[:id] == b.mj }.first } %>
|
||||||
|
<%= _("Removing a vote of rating %{previous}, this candidate has a majority judgement of %{losing}, but the winning candidate has a majority judgement of %{winning}.") % { previous: previous, losing: losing, winning: winning } %>
|
||||||
|
<% end %>
|
||||||
|
<% end %>
|
||||||
|
<% if n > 1 %>
|
||||||
|
<% if a.mj == b.mj %>
|
||||||
|
<% current = erb :rating_badge, :locals => { :value => settings.values.select { |e| e[:id] == a.mj }.first } %>
|
||||||
|
<%= _("Removing another vote of rating %{previous}, both candidates still have the same majority judgement of %{current}.") % { previous: previous, current: current } %>
|
||||||
|
<% else %>
|
||||||
|
<% losing = erb :rating_badge, :locals => { :value => settings.values.select { |e| e[:id] == a.mj }.first } %>
|
||||||
|
<% winning = erb :rating_badge, :locals => { :value => settings.values.select { |e| e[:id] == b.mj }.first } %>
|
||||||
|
<%= _("Removing another vote of rating %{previous}, this candidate has a majority judgement of %{losing}, but the winning candidate has a majority judgement of %{winning}.") % { previous: previous, losing: losing, winning: winning } %>
|
||||||
|
<% end %>
|
||||||
|
<% end %>
|
||||||
|
<% previous = erb :rating_badge, :locals => { :value => settings.values.select { |e| e[:id] == a.mj }.first } %>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<% (1..a.n).each do |i| %>
|
||||||
|
<td class="p-0 text-center <% unless i == a.majority %>opacity-0<% end %>">↓</td>
|
||||||
|
<% end %>
|
||||||
|
<td colspan="<%= max - a.n - b.n %>"></td>
|
||||||
|
<% (1..b.n).each do |i| %>
|
||||||
|
<td class="p-0 text-center <% unless b.n - i + 1 == b.majority %>opacity-0<% end %>">↓</td>
|
||||||
|
<% end %>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<% i = 0 %>
|
||||||
|
<% settings.values.reverse.each do |v| %>
|
||||||
|
<% (1..a.count[v[:id]]).each do |r| %>
|
||||||
|
<% i = i + 1 %>
|
||||||
|
<td class="p-0 mj-cell mj-cell-<%= v[:id] %><% if i == a.majority and a.mj == b.mj %> mj-cell-majority<% end %>"> </td>
|
||||||
|
<% end %>
|
||||||
|
<% end %>
|
||||||
|
<td class="p-0 text-center fw-bold" colspan="<%= max - a.n - b.n %>">
|
||||||
|
<% if a.mj < b.mj %><<% end %>
|
||||||
|
<% if a.mj > b.mj %>><% end %>
|
||||||
|
<% if a.mj == b.mj %>=<% end %>
|
||||||
|
</td>
|
||||||
|
<% i = 0 %>
|
||||||
|
<% settings.values.each do |v| %>
|
||||||
|
<% (1..b.count[v[:id]]).each do |r| %>
|
||||||
|
<% i = i + 1 %>
|
||||||
|
<td class="p-0 mj-cell mj-cell-<%= v[:id] %><% if b.n - i + 1 == b.majority and a.mj == b.mj %> mj-cell-majority<% end %>"> </td>
|
||||||
|
<% end %>
|
||||||
|
<% end %>
|
||||||
|
</tr>
|
||||||
|
<% n = n + 1 %>
|
||||||
|
<% end %>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue