_poll.html.haml 1.5 KB

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