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> <title><%= _("Vote") %></title>
<script src="/chartkick.js"></script> <script src="/chartkick.js"></script>
<script src="/Chart.bundle.js"></script> <script src="/Chart.bundle.js"></script>
<link rel="stylesheet" href="/style.css">
</head> </head>
<body> <body>
<% if current_user %> <% if current_user %>

View file

@ -16,7 +16,8 @@
<td><%= user.email %></td> <td><%= user.email %></td>
<% @vote.candidates.each do |candidate| %> <% @vote.candidates.each do |candidate| %>
<% if rating = @vote.ratings.find { |rating| rating.user == user and rating.candidate == 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 %>
<% end %> <% end %>
</tr> </tr>
@ -39,7 +40,8 @@
<tr> <tr>
<td><%= i %></td> <td><%= i %></td>
<td><%= candidate.name %></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.proponents %></td>
<td><%= candidate.mj.opponents %></td> <td><%= candidate.mj.opponents %></td>
</tr> </tr>

View file

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

View file

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