foodsoft/plugins/polls/app/views/polls/vote.html.haml
Patrick Gansterer d476993321 Add polls plugin
2020-02-24 14:27:22 +01:00

49 lines
1.9 KiB
Text

- title @poll.name
%p= simple_format @poll.description
= form_tag(vote_poll_path(@poll)) do
- if @poll.event?
%table.table.table-striped
%thead
%tr
%th
%th= "\u2714"
%th= "?"
%th= "\u2715"
%tbody
- @poll.choices.each_with_index do |choice, idx|
%tr
%td= @poll.choices[idx]
%td= radio_button_tag "choices[#{idx}]", '1', @poll_vote.poll_choices.where(choice: idx, value: '1').any?
%td= radio_button_tag "choices[#{idx}]", '2', @poll_vote.poll_choices.where(choice: idx, value: '2').any?
%td= radio_button_tag "choices[#{idx}]", '0', @poll_vote.poll_choices.where(choice: idx, value: '0').any?
- elsif @poll.single_select?
- @poll.choices.each_with_index do |choice, idx|
= radio_button_tag 'choice', idx, @poll_vote.poll_choices.where(choice: idx, value: 1).any?, style: 'float:left'
= label_tag "choices[#{idx}]", choice
- elsif @poll.multi_select?
- @poll.choices.each_with_index do |choice, idx|
= check_box_tag "choices[#{idx}]", '1', @poll_vote.poll_choices.where(choice: idx, value: 1).any?, style: 'float:left'
= label_tag "choices[#{idx}]", choice
- elsif @poll.points? || @poll.resistance_points?
%table.table.table-striped
%thead
%tr
%th
- @poll.available_points.each do |point|
%th= point
%tbody
- @poll.choices.each_with_index do |choice, idx|
%tr
%td= @poll.choices[idx]
- @poll.available_points.each do |point|
%th= radio_button_tag "choices[#{idx}]", point, @poll_vote.poll_choices.where(choice: idx, value: point).any?
%p
%b= heading_helper(PollVote, :note) + ':'
%p
= text_area_tag 'note', @poll_vote.note
%p
= submit_tag t('.submit'), class: 'btn btn-success'
= link_to t('ui.back'), @poll, class: 'btn'