Add color to ratings

This commit is contained in:
ricola 2025-04-06 17:04:31 -06:00
parent c4ebe12408
commit 058b512b7d
4 changed files with 13 additions and 5 deletions

View file

@ -5,6 +5,7 @@
<title><%= _("Vote") %></title>
<script src="/chartkick.js"></script>
<script src="/Chart.bundle.js"></script>
<link rel="stylesheet" href="/style.css">
</head>
<body>
<% if current_user %>

View file

@ -16,7 +16,8 @@
<td><%= user.email %></td>
<% @vote.candidates.each do |candidate| %>
<% if rating = @vote.ratings.find { |rating| rating.user == user and rating.candidate == candidate } %>
<td><%= settings.values.select { |e| e[:id] == rating.value }.first[:label] %></td>
<% value = settings.values.select { |e| e[:id] == rating.value }.first %>
<td class="value-<%= value[:id] %>"><%= value[:label] %></td>
<% end %>
<% end %>
</tr>
@ -39,7 +40,8 @@
<tr>
<td><%= i %></td>
<td><%= candidate.name %></td>
<td><%= settings.values.select { |e| e[:id] == candidate.mj.mj }.first[:label] %></td>
<% value = settings.values.select { |e| e[:id] == candidate.mj.mj }.first %>
<td class="value-<%= value[:id] %>"><%= value[:label] %></td>
<td><%= candidate.mj.proponents %></td>
<td><%= candidate.mj.opponents %></td>
</tr>

View file

@ -12,11 +12,11 @@
<li>
<p><%= candidate.name %></p>
<p><%= candidate.description %></p>
<ol>
<ul>
<% settings.values.reverse.each do |v| %>
<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] %>"><%= v[:label] %></label>
<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 %>
</ol>
</ul>
</li>
<% end %>
</ul>

View file

@ -71,6 +71,11 @@ get '/' do
erb :home
end
get '/style.css' do
content_type 'text/css'
erb :style, :layout => false
end
get '/signup' do
erb :signup
end