_poll.html.haml 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. - show_results = (user_signed_in? && poll.voted?(current_account)) || poll.expired?
  2. - own_votes = user_signed_in? ? poll.own_votes(current_account) : []
  3. - total_votes_count = poll.voters_count || poll.votes_count
  4. .poll
  5. %ul
  6. - poll.loaded_options.each_with_index do |option, index|
  7. %li
  8. - if show_results
  9. - percent = total_votes_count > 0 ? 100 * option.votes_count / total_votes_count : 0
  10. %label.poll__option><
  11. %span.poll__number><
  12. = "#{percent.round}%"
  13. %span.poll__option__text
  14. = Formatter.instance.format_poll_option(status, option, autoplay: autoplay)
  15. - if own_votes.include?(index)
  16. %span.poll__voted
  17. %i.poll__voted__mark.fa.fa-check
  18. %progress{ max: 100, value: percent < 1 ? 1 : percent, 'aria-hidden': 'true' }
  19. %span.poll__chart
  20. - else
  21. %label.poll__option><
  22. %span.poll__input{ class: poll.multiple? ? 'checkbox' : nil}><
  23. %span.poll__option__text
  24. = Formatter.instance.format_poll_option(status, option, autoplay: autoplay)
  25. .poll__footer
  26. - unless show_results
  27. %button.button.button-secondary{ disabled: true }
  28. = t('statuses.poll.vote')
  29. - if poll.voters_count.nil?
  30. %span= t('statuses.poll.total_votes', count: poll.votes_count)
  31. - else
  32. %span= t('statuses.poll.total_people', count: poll.voters_count)
  33. - unless poll.expires_at.nil?
  34. ·
  35. %span= l poll.expires_at