You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

35 lines
1.3 KiB

  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. %span.poll__chart{ style: "width: #{percent}%" }
  11. %label.poll__text><
  12. %span.poll__number><
  13. - if own_votes.include?(index)
  14. %i.poll__vote__mark.fa.fa-check
  15. = percent.round
  16. = Formatter.instance.format_poll_option(status, option, autoplay: autoplay)
  17. - else
  18. %label.poll__text><
  19. %span.poll__input{ class: poll.multiple? ? 'checkbox' : nil}><
  20. = Formatter.instance.format_poll_option(status, option, autoplay: autoplay)
  21. .poll__footer
  22. - unless show_results
  23. %button.button.button-secondary{ disabled: true }
  24. = t('statuses.poll.vote')
  25. - if poll.voters_count.nil?
  26. %span= t('statuses.poll.total_votes', count: poll.votes_count)
  27. - else
  28. %span= t('statuses.poll.total_people', count: poll.voters_count)
  29. - unless poll.expires_at.nil?
  30. ·
  31. %span= l poll.expires_at