diff --git a/app/controllers/admin/poll/questions/answers_controller.rb b/app/controllers/admin/poll/questions/answers_controller.rb index 9dbeeab1a..6d6b8a759 100644 --- a/app/controllers/admin/poll/questions/answers_controller.rb +++ b/app/controllers/admin/poll/questions/answers_controller.rb @@ -18,9 +18,6 @@ class Admin::Poll::Questions::AnswersController < Admin::Poll::BaseController end end - def show - end - def edit end diff --git a/app/views/admin/poll/questions/answers/show.html.erb b/app/views/admin/poll/questions/answers/show.html.erb deleted file mode 100644 index 00bc72b02..000000000 --- a/app/views/admin/poll/questions/answers/show.html.erb +++ /dev/null @@ -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" %> - - - -
- - - - - - - - - - - - - - - - -
<%= t("admin.answers.show.title") %><%= t("admin.answers.show.description") %><%= t("admin.answers.show.images") %>
<%= @answer.title %><%= wysiwyg(@answer.description) %> - (<%= @answer.images.count %>)
- <%= link_to t("admin.answers.show.images_list"), admin_answer_images_path(@answer) %> -
diff --git a/app/views/admin/poll/questions/show.html.erb b/app/views/admin/poll/questions/show.html.erb index 33992f421..f4e80e14d 100644 --- a/app/views/admin/poll/questions/show.html.erb +++ b/app/views/admin/poll/questions/show.html.erb @@ -43,13 +43,14 @@ <%= t("admin.questions.show.answers.images") %> <%= t("admin.questions.show.answers.documents") %> <%= t("admin.questions.show.answers.videos") %> + <%= t("admin.actions.actions") %> <% @question.question_answers.each do |answer| %> - <%= link_to answer.title, admin_question_answer_path(@question, answer) %> + <%= answer.title %> <%= wysiwyg(answer.description) %> (<%= answer.images.count %>) @@ -69,6 +70,9 @@ <%= link_to t("admin.questions.show.answers.video_list"), admin_answer_videos_path(answer) %> + + <%= render Admin::TableActionsComponent.new(answer, actions: [:edit]) %> + <% end %> diff --git a/config/initializers/routes_hierarchy.rb b/config/initializers/routes_hierarchy.rb index 7fda048ff..e66c8386c 100644 --- a/config/initializers/routes_hierarchy.rb +++ b/config/initializers/routes_hierarchy.rb @@ -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 diff --git a/config/locales/en/admin.yml b/config/locales/en/admin.yml index d0fe1c394..cfc5bf653 100644 --- a/config/locales/en/admin.yml +++ b/config/locales/en/admin.yml @@ -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: diff --git a/config/locales/es/admin.yml b/config/locales/es/admin.yml index 47399d97d..8e997a466 100644 --- a/config/locales/es/admin.yml +++ b/config/locales/es/admin.yml @@ -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: diff --git a/config/routes/admin.rb b/config/routes/admin.rb index f61ab41a8..f3471c58c 100644 --- a/config/routes/admin.rb +++ b/config/routes/admin.rb @@ -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 diff --git a/spec/system/admin/poll/questions/answers/answers_spec.rb b/spec/system/admin/poll/questions/answers/answers_spec.rb index 76d936fc8..1b9722e69 100644 --- a/spec/system/admin/poll/questions/answers/answers_spec.rb +++ b/spec/system/admin/poll/questions/answers/answers_spec.rb @@ -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"