From 9871503c5e8a8bf33088fba5a00e1ca48958a8e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mar=C3=ADa=20Checa?= Date: Tue, 3 Oct 2017 21:00:40 +0200 Subject: [PATCH] Restored views --- app/views/admin/poll/questions/show.html.erb | 8 ------- app/views/polls/questions/_answers.html.erb | 22 ++++++++++++++++++++ app/views/polls/questions/_question.html.erb | 9 ++++++++ app/views/polls/questions/answer.js.erb | 1 + config/routes.rb | 6 +++++- 5 files changed, 37 insertions(+), 9 deletions(-) create mode 100644 app/views/polls/questions/_answers.html.erb create mode 100644 app/views/polls/questions/_question.html.erb create mode 100644 app/views/polls/questions/answer.js.erb diff --git a/app/views/admin/poll/questions/show.html.erb b/app/views/admin/poll/questions/show.html.erb index 3f776c5c0..438ee3a40 100644 --- a/app/views/admin/poll/questions/show.html.erb +++ b/app/views/admin/poll/questions/show.html.erb @@ -34,12 +34,6 @@ <% end %> -

- <%= t("admin.questions.show.description") %> -
- <%= @question.description %> -

- <% if @question.video_url.present? %>

<%= t("admin.questions.show.video_url") %> @@ -55,7 +49,5 @@ <%= @question.documents.first.title %>

<% end %> - - <%= link_to t("admin.questions.show.preview"), question_path(@question) %> diff --git a/app/views/polls/questions/_answers.html.erb b/app/views/polls/questions/_answers.html.erb new file mode 100644 index 000000000..c88156b68 --- /dev/null +++ b/app/views/polls/questions/_answers.html.erb @@ -0,0 +1,22 @@ +
+ <% if can? :answer, question %> + <% question.valid_answers.each do |answer| %> + <% if @answers_by_question_id[question.id] == answer %> + "> + <%= answer %> + + <% else %> + <%= link_to answer, + answer_question_path(question, answer: answer), + method: :post, + remote: true, + title: t("poll_questions.show.vote_answer", answer: answer), + class: "button secondary hollow" %> + <% end %> + <% end %> + <% else %> + <% question.valid_answers.each do |answer| %> + <%= answer %> + <% end %> + <% end %> +
diff --git a/app/views/polls/questions/_question.html.erb b/app/views/polls/questions/_question.html.erb new file mode 100644 index 000000000..982d0a070 --- /dev/null +++ b/app/views/polls/questions/_question.html.erb @@ -0,0 +1,9 @@ +
+

+ <%= question.title %> +

+ +
+ <%= render 'polls/questions/answers', question: question %> +
+
diff --git a/app/views/polls/questions/answer.js.erb b/app/views/polls/questions/answer.js.erb new file mode 100644 index 000000000..aabbd8d89 --- /dev/null +++ b/app/views/polls/questions/answer.js.erb @@ -0,0 +1 @@ +$("#<%= dom_id(@question) %>_answers").html('<%= j render("polls/questions/answers", question: @question) %>'); diff --git a/config/routes.rb b/config/routes.rb index 6c893c24a..9e7c8d307 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -112,7 +112,11 @@ Rails.application.routes.draw do get :search, on: :collection end - resources :polls, only: [:show, :index] + resources :polls, only: [:show, :index] do + resources :questions, controller: 'polls/questions', shallow: true do + post :answer, on: :member + end + end namespace :legislation do resources :processes, only: [:index, :show] do