aboutsummaryrefslogtreecommitdiffstats
path: root/templates/poll_vote_table.html.j2
blob: 70d5b8db73d175f7b056b44365fb9a8bd24ae9fd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
<div class="vote-table-container">
<table class="vote-table">
  <thead>
    <tr>
      <th></th>
      {% for choice in choices %}
      <th {% if choice.id in most_voted_choice_ids %}class="most-voted"{% endif %}>
        {% include "poll_choice_datetime_range.html.j2" %}
        <span>
          {% if choice.id in most_voted_choice_ids %}👑{% endif %}
          <i>{{ choice.votes_with_value(1) | length }} votes</i>
        </span>
      </th>
      {% endfor %}
    </tr>
  </thead>
  <tbody>
    {% for voter_name in voter_names %}
    <tr>
      <td>
        {% if voter_name in managed_voter_names %}
        <form class="delete-voter-container"
              action="/poll/{{ poll.id }}/delete_voter"
              method="post">
          <input type="hidden" name="voter_code" value="{{ managed_voter_names[voter_name] }}">
          <span>{{ voter_name }}</span>
          <input aria-label="Delete voter {{ voter_name }}"
                 class="delete-voter-btn"
                 type="submit"
                 value="❌">
        </form>
        {% else %}
        {{ voter_name }}
        {% endif %}
      </td>
      {% for choice in choices %}
      {% if selections[(voter_name, choice.id)] == 1 %}
      <td>
        <input type="checkbox" checked disabled>
      </td>
      {% elif selections[(voter_name, choice.id)] == 0 %}
      <td>
        <input type="checkbox" disabled>
      </td>
      {% else %}
      <td>
        ??
      </td>
      {% endif %}
      {% endfor %}
    </tr>
    {% endfor %}

    <tr>
      <!-- Add a row for the current user -->
      <form action="/poll/{{ poll.id }}/vote" method="post">
      <td>
        <label for="voter_name" hidden>Your name</label>
        <input type="text"
               name="voter_name"
               id="voter_name"
               placeholder="Your name"
               required
               {% if prefill_voter_name %}value="{{ prefill_voter_name }}"{% endif %}>
        <input class="blue" type="submit" value="Submit">
      </td>
      {% for choice in choices %}
      <td>
        <input type="checkbox" name="choice_{{ choice.id }}">
      </td>
      {% endfor %}
    </form>
    </tr>
    <!-- End of the row for the current user -->
  </tbody>
</table>
</div>