Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Small tweaks to delete confirmation pages #1660

Merged
merged 2 commits into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion app/controllers/pages_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ def delete
def destroy
@page = PageRepository.find(page_id: params[:page_id], form_id: current_form.id)
@url = destroy_page_path(current_form, @page.id)
@confirm_deletion_legend = t("forms_delete_confirmation_input.confirm_deletion_page")
@item_name = @page.question_text
@back_url = edit_question_path(current_form, @page.id)

Expand Down
16 changes: 10 additions & 6 deletions app/views/forms/delete_confirmation/delete.html.erb
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
<% set_page_title(title_with_error_prefix(@confirm_deletion_legend, @delete_confirmation_input.errors.any?)) %>
<% content_for :back_link, govuk_back_link_to(@back_url) %>

<%= render(
@delete_confirmation_input,
url: @url,
caption_text: @item_name,
legend_text: @confirm_deletion_legend,
) %>
<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
<%= render(
@delete_confirmation_input,
url: @url,
caption_text: @item_name,
legend_text: @confirm_deletion_legend,
) %>
</div>
</div>
20 changes: 12 additions & 8 deletions app/views/pages/delete.html.erb
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
<% set_page_title(title_with_error_prefix(@confirm_deletion_legend, @delete_confirmation_input.errors.any?)) %>
<% set_page_title(title_with_error_prefix(t(".title"), @delete_confirmation_input.errors.any?)) %>
<% content_for :back_link, govuk_back_link_to(@back_url) %>

<%= render(
@delete_confirmation_input,
url: @url,
caption_text: @item_name,
legend_text: @confirm_deletion_legend,
hint_text: nil,
) %>
<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
<%= render(
@delete_confirmation_input,
url: @url,
caption_text: @item_name,
legend_text: t(".title"),
hint_text: nil,
) %>
</div>
</div>
2 changes: 2 additions & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1132,6 +1132,8 @@ en:
your_form_is_live: Your form is live
pages:
answer_settings: Answer settings
delete:
title: Are you sure you want to delete this question?
delete_question: Delete question
go_to_your_questions: Back to your questions
heading: Edit question
Expand Down
5 changes: 2 additions & 3 deletions spec/views/pages/delete.html.erb_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
RSpec.describe "pages/delete" do
before do
assign(:back_url, edit_question_path(form_id: 1, page_id: 1))
assign(:confirm_deletion_legend, "Are you sure you want to delete this page?")
assign(:delete_confirmation_input, Forms::DeleteConfirmationInput.new)
assign(:item_name, "What’s your name?")
assign(:url, destroy_page_path(form_id: 1, page_id: 1))
Expand All @@ -12,11 +11,11 @@
end

it "has a page title" do
expect(view.content_for(:title)).to include "Are you sure you want to delete this page?"
expect(view.content_for(:title)).to include "Are you sure you want to delete this question?"
end

it "has a heading" do
expect(rendered).to have_css "h1", text: "Are you sure you want to delete this page?"
expect(rendered).to have_css "h1", text: "Are you sure you want to delete this question?"
end

it "has a heading caption with the question text" do
Expand Down
Loading