Remove useless answers show view
Until now, in order to edit an answer, we had to click on its title on the table and then on the "Edit answer" link. That was tedious and different from what we usually do in the admin section. Furthermore, the code for the answers table was written twice and when we modified it we forgot to update the one in the `show` action, meaning the table here provided less information than the information present in the answers tables. Co-Authored-By: Javi Martín <javim@elretirao.net>
This commit is contained in:
@@ -18,9 +18,6 @@ class Admin::Poll::Questions::AnswersController < Admin::Poll::BaseController
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def show
|
|
||||||
end
|
|
||||||
|
|
||||||
def edit
|
def edit
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -1,31 +0,0 @@
|
|||||||
<%= back_link_to %>
|
|
||||||
|
|
||||||
<%= link_to t("admin.answers.show.edit"), edit_admin_question_answer_path(@answer.question, @answer),
|
|
||||||
class: "button hollow float-right" %>
|
|
||||||
|
|
||||||
<ul class="breadcrumbs margin-top">
|
|
||||||
<li><%= @answer.question.title %></li>
|
|
||||||
<li><%= @answer.title %></li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
<div class="clear"></div>
|
|
||||||
|
|
||||||
<table>
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th scope="col"><%= t("admin.answers.show.title") %></th>
|
|
||||||
<th scope="col"><%= t("admin.answers.show.description") %></th>
|
|
||||||
<th scope="col" class="text-center"><%= t("admin.answers.show.images") %></th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
<tr>
|
|
||||||
<td><%= @answer.title %></td>
|
|
||||||
<td><%= wysiwyg(@answer.description) %></td>
|
|
||||||
<td class="text-center">
|
|
||||||
(<%= @answer.images.count %>)<br>
|
|
||||||
<%= link_to t("admin.answers.show.images_list"), admin_answer_images_path(@answer) %>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
@@ -43,13 +43,14 @@
|
|||||||
<th scope="col" class="text-center"><%= t("admin.questions.show.answers.images") %></th>
|
<th scope="col" class="text-center"><%= t("admin.questions.show.answers.images") %></th>
|
||||||
<th scope="col" class="text-center"><%= t("admin.questions.show.answers.documents") %></th>
|
<th scope="col" class="text-center"><%= t("admin.questions.show.answers.documents") %></th>
|
||||||
<th scope="col" class="text-center"><%= t("admin.questions.show.answers.videos") %></th>
|
<th scope="col" class="text-center"><%= t("admin.questions.show.answers.videos") %></th>
|
||||||
|
<th><%= t("admin.actions.actions") %></th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
|
|
||||||
<tbody class="sortable" data-js-url="<%= admin_question_answers_order_answers_path(@question.id) %>">
|
<tbody class="sortable" data-js-url="<%= admin_question_answers_order_answers_path(@question.id) %>">
|
||||||
<% @question.question_answers.each do |answer| %>
|
<% @question.question_answers.each do |answer| %>
|
||||||
<tr id="<%= dom_id(answer) %>" class="poll_question_answer" data-answer-id="<%= answer.id %>">
|
<tr id="<%= dom_id(answer) %>" class="poll_question_answer" data-answer-id="<%= answer.id %>">
|
||||||
<td class="align-top"><%= link_to answer.title, admin_question_answer_path(@question, answer) %></td>
|
<td class="align-top"><%= answer.title %></td>
|
||||||
<td class="align-top break"><%= wysiwyg(answer.description) %></td>
|
<td class="align-top break"><%= wysiwyg(answer.description) %></td>
|
||||||
<td class="align-top text-center">
|
<td class="align-top text-center">
|
||||||
(<%= answer.images.count %>)
|
(<%= answer.images.count %>)
|
||||||
@@ -69,6 +70,9 @@
|
|||||||
<%= link_to t("admin.questions.show.answers.video_list"),
|
<%= link_to t("admin.questions.show.answers.video_list"),
|
||||||
admin_answer_videos_path(answer) %>
|
admin_answer_videos_path(answer) %>
|
||||||
</td>
|
</td>
|
||||||
|
<td>
|
||||||
|
<%= render Admin::TableActionsComponent.new(answer, actions: [:edit]) %>
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<% end %>
|
<% end %>
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ module ActionDispatch::Routing::UrlFor
|
|||||||
|
|
||||||
def namespaced_polymorphic_path(namespace, resource, options = {})
|
def namespaced_polymorphic_path(namespace, resource, options = {})
|
||||||
if %w[Budget::Group Budget::Heading Poll::Booth Poll::BoothAssignment Poll::Officer
|
if %w[Budget::Group Budget::Heading Poll::Booth Poll::BoothAssignment Poll::Officer
|
||||||
Poll::Question Poll::Question::Answer::Video Poll::Shift
|
Poll::Question Poll::Question::Answer Poll::Question::Answer::Video Poll::Shift
|
||||||
SDG::LocalTarget].include?(resource.class.name)
|
SDG::LocalTarget].include?(resource.class.name)
|
||||||
resolve = resolve_for(resource)
|
resolve = resolve_for(resource)
|
||||||
resolve_options = resolve.pop
|
resolve_options = resolve.pop
|
||||||
|
|||||||
@@ -1154,12 +1154,6 @@ en:
|
|||||||
answers:
|
answers:
|
||||||
new:
|
new:
|
||||||
title: New answer
|
title: New answer
|
||||||
show:
|
|
||||||
title: Title
|
|
||||||
description: Description
|
|
||||||
images: Images
|
|
||||||
images_list: Images list
|
|
||||||
edit: Edit answer
|
|
||||||
edit:
|
edit:
|
||||||
title: Edit answer
|
title: Edit answer
|
||||||
videos:
|
videos:
|
||||||
|
|||||||
@@ -1153,12 +1153,6 @@ es:
|
|||||||
answers:
|
answers:
|
||||||
new:
|
new:
|
||||||
title: Nueva respuesta
|
title: Nueva respuesta
|
||||||
show:
|
|
||||||
title: Título
|
|
||||||
description: Descripción
|
|
||||||
images: Imágenes
|
|
||||||
images_list: Lista de imágenes
|
|
||||||
edit: Editar respuesta
|
|
||||||
edit:
|
edit:
|
||||||
title: Editar respuesta
|
title: Editar respuesta
|
||||||
videos:
|
videos:
|
||||||
|
|||||||
@@ -169,7 +169,7 @@ namespace :admin do
|
|||||||
end
|
end
|
||||||
|
|
||||||
resources :questions, shallow: true do
|
resources :questions, shallow: true do
|
||||||
resources :answers, except: [:index, :destroy], controller: "questions/answers", shallow: false
|
resources :answers, except: [:index, :show, :destroy], controller: "questions/answers", shallow: false
|
||||||
resources :answers, only: [], controller: "questions/answers" do
|
resources :answers, only: [], controller: "questions/answers" do
|
||||||
resources :images, controller: "questions/answers/images"
|
resources :images, controller: "questions/answers/images"
|
||||||
resources :videos, controller: "questions/answers/videos"
|
resources :videos, controller: "questions/answers/videos"
|
||||||
@@ -323,6 +323,10 @@ resolve "Poll::Officer" do |officer, options|
|
|||||||
[:officer, options.merge(id: officer)]
|
[:officer, options.merge(id: officer)]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
resolve "Poll::Question::Answer" do |answer, options|
|
||||||
|
[:question, :answer, options.merge(question_id: answer.question, id: answer)]
|
||||||
|
end
|
||||||
|
|
||||||
resolve "Poll::Question::Answer::Video" do |video, options|
|
resolve "Poll::Question::Answer::Video" do |video, options|
|
||||||
[:video, options.merge(id: video)]
|
[:video, options.merge(id: video)]
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -33,15 +33,13 @@ describe "Answers", :admin do
|
|||||||
|
|
||||||
scenario "Update" do
|
scenario "Update" do
|
||||||
question = create(:poll_question)
|
question = create(:poll_question)
|
||||||
answer = create(:poll_question_answer, question: question, title: "Answer title", given_order: 2)
|
create(:poll_question_answer, question: question, title: "Answer title", given_order: 2)
|
||||||
create(:poll_question_answer, question: question, title: "Another title", given_order: 1)
|
create(:poll_question_answer, question: question, title: "Another title", given_order: 1)
|
||||||
|
|
||||||
visit admin_question_answer_path(question, answer)
|
visit admin_question_path(question)
|
||||||
|
within("tr", text: "Answer title") { click_link "Edit" }
|
||||||
click_link "Edit answer"
|
|
||||||
|
|
||||||
fill_in "Answer", with: "New title"
|
fill_in "Answer", with: "New title"
|
||||||
|
|
||||||
click_button "Save"
|
click_button "Save"
|
||||||
|
|
||||||
expect(page).to have_content "Changes saved"
|
expect(page).to have_content "Changes saved"
|
||||||
|
|||||||
Reference in New Issue
Block a user