_poll.html.haml 1.32 KB
Newer Older
1
- show_results = (user_signed_in? && poll.voted?(current_account)) || poll.expired?
2
- own_votes = user_signed_in? ? poll.own_votes(current_account) : []
ThibG's avatar
ThibG committed
3
- total_votes_count = poll.voters_count || poll.votes_count
4
5
6

.poll
  %ul
7
    - poll.loaded_options.each_with_index do |option, index|
8
9
      %li
        - if show_results
ThibG's avatar
ThibG committed
10
          - percent = total_votes_count > 0 ? 100 * option.votes_count / total_votes_count : 0
11
          %span.poll__chart{ style: "width: #{percent}%" }
12

13
          %label.poll__text><
14
15
16
17
            %span.poll__number><
              - if own_votes.include?(index)
                %i.poll__vote__mark.fa.fa-check
              = percent.round
18
            = Formatter.instance.format_poll_option(status, option, autoplay: autoplay)
19
20
        - else
          %label.poll__text><
21
            %span.poll__input{ class: poll.multiple? ? 'checkbox' : nil}><
22
            = Formatter.instance.format_poll_option(status, option, autoplay: autoplay)
23
24
25
26
  .poll__footer
    - unless show_results
      %button.button.button-secondary{ disabled: true }
        = t('statuses.poll.vote')
27

ThibG's avatar
ThibG committed
28
29
30
31
    - if poll.voters_count.nil?
      %span= t('statuses.poll.total_votes', count: poll.votes_count)
    - else
      %span= t('statuses.poll.total_people', count: poll.voters_count)
32
33
34
35

    - unless poll.expires_at.nil?
      ·
      %span= l poll.expires_at