Use buttons to destroy drafts and questions
As mentioned in commits5311daadfandbb958daf0, using links combined with JavaScript to generate POST (or, in this case, DELETE) requests to the server has a few issues.
This commit is contained in:
@@ -15,10 +15,12 @@
|
||||
<h3 class="inline-block"><%= @draft_version.title %></h3>
|
||||
|
||||
<div class="float-right">
|
||||
<%= link_to t("admin.legislation.draft_versions.index.delete"),
|
||||
admin_legislation_process_draft_version_path(@process, @draft_version),
|
||||
<%= render Admin::ActionComponent.new(
|
||||
:destroy,
|
||||
@draft_version,
|
||||
method: :delete,
|
||||
class: "button hollow alert" %>
|
||||
class: "button hollow alert"
|
||||
) %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -15,9 +15,12 @@
|
||||
<h3 class="inline-block"><%= t("admin.legislation.questions.edit.title", question_title: @question.title) %></h3>
|
||||
|
||||
<div class="float-right">
|
||||
<%= link_to t("admin.legislation.questions.index.delete"), admin_legislation_process_question_path(@process, @question),
|
||||
<%= render Admin::ActionComponent.new(
|
||||
:destroy,
|
||||
@question,
|
||||
method: :delete,
|
||||
class: "button hollow alert" %>
|
||||
class: "button hollow alert"
|
||||
) %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -24,9 +24,9 @@ module ActionDispatch::Routing::UrlFor
|
||||
end
|
||||
|
||||
def namespaced_polymorphic_path(namespace, resource, options = {})
|
||||
if %w[Budget::Group Budget::Heading Poll::Booth Poll::BoothAssignment Poll::Officer
|
||||
Poll::Question Poll::Question::Answer Poll::Question::Answer::Video Poll::Shift
|
||||
SDG::LocalTarget].include?(resource.class.name)
|
||||
if %w[Budget::Group Budget::Heading Legislation::DraftVersion Legislation::Question
|
||||
Poll::Booth Poll::BoothAssignment Poll::Officer 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
|
||||
|
||||
|
||||
@@ -664,7 +664,6 @@ en:
|
||||
index:
|
||||
title: Draft versions
|
||||
create: Create version
|
||||
delete: Delete
|
||||
preview: Preview
|
||||
new:
|
||||
back: Back
|
||||
@@ -697,7 +696,6 @@ en:
|
||||
back: Back
|
||||
title: Questions associated to this process
|
||||
create: Create question
|
||||
delete: Delete
|
||||
new:
|
||||
back: Back
|
||||
title: Create new question
|
||||
|
||||
@@ -664,7 +664,6 @@ es:
|
||||
index:
|
||||
title: Versiones del borrador
|
||||
create: Crear versión
|
||||
delete: Borrar
|
||||
preview: Previsualizar
|
||||
new:
|
||||
back: Volver
|
||||
@@ -697,7 +696,6 @@ es:
|
||||
back: Volver
|
||||
title: Preguntas asociadas a este proceso
|
||||
create: Crear pregunta
|
||||
delete: Borrar
|
||||
new:
|
||||
back: Volver
|
||||
title: Crear nueva pregunta
|
||||
|
||||
@@ -346,3 +346,7 @@ end
|
||||
resolve "Poll::Question::Answer::Video" do |video, options|
|
||||
[:answer, :video, options.merge(answer_id: video.answer, id: video)]
|
||||
end
|
||||
|
||||
resolve "Legislation::DraftVersion" do |version, options|
|
||||
[version.process, :draft_version, options.merge(id: version)]
|
||||
end
|
||||
|
||||
@@ -78,7 +78,7 @@ describe "Admin legislation draft versions", :admin do
|
||||
version = create(:legislation_draft_version, body: "Version 1")
|
||||
|
||||
visit edit_admin_legislation_process_draft_version_path(version.process, version)
|
||||
click_link "Delete"
|
||||
click_button "Delete"
|
||||
|
||||
expect(page).to have_content "Draft deleted successfully"
|
||||
end
|
||||
|
||||
@@ -75,7 +75,7 @@ describe "Admin legislation questions", :admin do
|
||||
|
||||
visit edit_admin_legislation_process_question_path(process, question)
|
||||
|
||||
click_link "Delete"
|
||||
click_button "Delete"
|
||||
|
||||
expect(page).to have_content "Questions"
|
||||
expect(page).to have_content "Question 1"
|
||||
|
||||
Reference in New Issue
Block a user