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
|
||||
|
||||
def show
|
||||
end
|
||||
|
||||
def edit
|
||||
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.documents") %></th>
|
||||
<th scope="col" class="text-center"><%= t("admin.questions.show.answers.videos") %></th>
|
||||
<th><%= t("admin.actions.actions") %></th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody class="sortable" data-js-url="<%= admin_question_answers_order_answers_path(@question.id) %>">
|
||||
<% @question.question_answers.each do |answer| %>
|
||||
<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 text-center">
|
||||
(<%= answer.images.count %>)
|
||||
@@ -69,6 +70,9 @@
|
||||
<%= link_to t("admin.questions.show.answers.video_list"),
|
||||
admin_answer_videos_path(answer) %>
|
||||
</td>
|
||||
<td>
|
||||
<%= render Admin::TableActionsComponent.new(answer, actions: [:edit]) %>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
|
||||
@@ -25,7 +25,7 @@ module ActionDispatch::Routing::UrlFor
|
||||
|
||||
def namespaced_polymorphic_path(namespace, resource, options = {})
|
||||
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)
|
||||
resolve = resolve_for(resource)
|
||||
resolve_options = resolve.pop
|
||||
|
||||
@@ -1154,12 +1154,6 @@ en:
|
||||
answers:
|
||||
new:
|
||||
title: New answer
|
||||
show:
|
||||
title: Title
|
||||
description: Description
|
||||
images: Images
|
||||
images_list: Images list
|
||||
edit: Edit answer
|
||||
edit:
|
||||
title: Edit answer
|
||||
videos:
|
||||
|
||||
@@ -1153,12 +1153,6 @@ es:
|
||||
answers:
|
||||
new:
|
||||
title: Nueva respuesta
|
||||
show:
|
||||
title: Título
|
||||
description: Descripción
|
||||
images: Imágenes
|
||||
images_list: Lista de imágenes
|
||||
edit: Editar respuesta
|
||||
edit:
|
||||
title: Editar respuesta
|
||||
videos:
|
||||
|
||||
@@ -169,7 +169,7 @@ namespace :admin do
|
||||
end
|
||||
|
||||
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 :images, controller: "questions/answers/images"
|
||||
resources :videos, controller: "questions/answers/videos"
|
||||
@@ -323,6 +323,10 @@ resolve "Poll::Officer" do |officer, options|
|
||||
[:officer, options.merge(id: officer)]
|
||||
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|
|
||||
[:video, options.merge(id: video)]
|
||||
end
|
||||
|
||||
@@ -33,15 +33,13 @@ describe "Answers", :admin do
|
||||
|
||||
scenario "Update" do
|
||||
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)
|
||||
|
||||
visit admin_question_answer_path(question, answer)
|
||||
|
||||
click_link "Edit answer"
|
||||
visit admin_question_path(question)
|
||||
within("tr", text: "Answer title") { click_link "Edit" }
|
||||
|
||||
fill_in "Answer", with: "New title"
|
||||
|
||||
click_button "Save"
|
||||
|
||||
expect(page).to have_content "Changes saved"
|
||||
|
||||
Reference in New Issue
Block a user