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

(828) Reorder content block editing screens #9869

Merged
merged 5 commits into from
Feb 3, 2025
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<div class="govuk-button-group govuk-!-margin-bottom-6">
<div>
<%= render "govuk_publishing_components/components/button", {
text: button_text,
name: "confirm",
type: "submit",
form: form_id,
} %>
</div>
<div>
<%= render ContentBlockManager::Shared::CancelAndDeleteButtonComponent.new(
url: helpers.content_block_manager.content_block_manager_content_block_edition_path(
content_block_edition,
redirect_path:,
),
) %>
</div>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
class ContentBlockManager::Shared::ContinueOrCancelButtonGroup < ViewComponent::Base
def initialize(form_id:, content_block_edition:, button_text: "Save and continue")
@button_text = button_text
@form_id = form_id
@content_block_edition = content_block_edition
end

private

attr_reader :button_text, :form_id, :content_block_edition

def redirect_path
if is_editing?
helpers.content_block_manager.content_block_manager_content_block_document_path(content_block_edition.document)
else
helpers.content_block_manager.content_block_manager_content_block_documents_path
end
end

def is_editing?
content_block_edition.document.editions.count > 1
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
<%= form_with url: form_url, method: :put do %>
<%= form_with url: form_url, method: :put, id: "schedule_publishing" do %>

<%= render "govuk_publishing_components/components/radio", {
name: "schedule_publishing",
Expand Down Expand Up @@ -79,35 +79,36 @@
},
],
} %>

<div class="govuk-button-group">
<div>
<%= render "govuk_publishing_components/components/button", {
text: "Save and continue",
name: "save_and_continue",
value: "Save and continue",
type: "submit",
} %>
<% end %>
</div>
<div>
<% if is_rescheduling %>

<div class="govuk-button-group">
<div>
<%= render "govuk_publishing_components/components/button", {
text: "Cancel",
name: "Cancel",
value: "Cancel",
href: back_link,
secondary_solid: true,
text: "Save and continue",
name: "save_and_continue",
value: "Save and continue",
type: "submit",
form: "schedule_publishing",
} %>
<% else %>
<%= render ContentBlockManager::Shared::CancelAndDeleteButtonComponent.new(url: helpers.content_block_manager.
content_block_manager_content_block_edition_path(
content_block_edition, redirect_path:
helpers.content_block_manager.content_block_manager_content_block_document_path(content_block_edition.document)
),
) %>
<% end %>
</div>
</div>
<div>
<% if is_rescheduling %>
<%= render "govuk_publishing_components/components/button", {
text: "Cancel",
name: "Cancel",
value: "Cancel",
href: back_link,
secondary_solid: true,
} %>
<% else %>
<%= render ContentBlockManager::Shared::CancelAndDeleteButtonComponent.new(url: helpers.content_block_manager.
content_block_manager_content_block_edition_path(
content_block_edition, redirect_path:
helpers.content_block_manager.content_block_manager_content_block_document_path(content_block_edition.document)
),
) %>
<% end %>
</div>
</div>
</div>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ class Step < Data.define(:name, :show_action, :update_action)
ALL = [
Step.new(:edit_draft, :edit_draft, nil),
Step.new(:review_links, :review_links, :redirect_to_next_step),
Step.new(:schedule_publishing, :schedule_publishing, :validate_schedule),
Step.new(:internal_note, :internal_note, :update_internal_note),
Step.new(:change_note, :change_note, :update_change_note),
Step.new(:schedule_publishing, :schedule_publishing, :validate_schedule),
Step.new(:review, :review, :validate_review_page),
Step.new(:confirmation, :confirmation, nil),
].freeze
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<%= form_with url: content_block_manager.content_block_manager_content_block_workflow_path(
@content_block_edition,
step: :change_note,
), method: :put do %>
), method: :put, id: "change_note" do %>

<%= render "govuk_publishing_components/components/radio", {
name: "content_block/edition[major_change]",
Expand Down Expand Up @@ -48,20 +48,11 @@
},
],
} %>

<div class="govuk-button-group govuk-!-margin-bottom-6">
<%= render "govuk_publishing_components/components/button", {
text: "Save and continue",
name: "save_and_continue",
value: "Save and continue",
type: "submit",
} %>
<%= render "govuk_publishing_components/components/button", {
text: "Cancel",
href: @back_path,
secondary_solid: true,
} %>
</div>
<% end %>

<%= render ContentBlockManager::Shared::ContinueOrCancelButtonGroup.new(
form_id: "change_note",
content_block_edition: @content_block_edition,
) %>
</div>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<%= form_with url: content_block_manager.content_block_manager_content_block_workflow_path(
@content_block_edition,
step: :internal_note,
), method: :put do %>
), method: :put, id: "internal_note" do %>
<%= render "govuk_publishing_components/components/textarea", {
label: {
text: "Describe the change for internal users",
Expand All @@ -21,20 +21,11 @@
id: "content_block_manager_content_block_edition_title",
value: @content_block_edition.internal_change_note,
} %>

<div class="govuk-button-group govuk-!-margin-bottom-6">
<%= render "govuk_publishing_components/components/button", {
text: "Save and continue",
name: "save_and_continue",
value: "Save and continue",
type: "submit",
} %>
<%= render "govuk_publishing_components/components/button", {
text: "Cancel",
href: @back_path,
secondary_solid: true,
} %>
</div>
<% end %>

<%= render ContentBlockManager::Shared::ContinueOrCancelButtonGroup.new(
form_id: "internal_note",
content_block_edition: @content_block_edition,
) %>
</div>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -24,45 +24,37 @@
</div>
</div>

<%= form_with(
url: content_block_manager.content_block_manager_content_block_workflow_path(@content_block_edition, step: :review),
method: :put,
) do %>
<div class="govuk-grid-row">
<div class="govuk-grid-column-full">
<%= render "govuk_publishing_components/components/checkboxes", {
name: "is_confirmed",
id: "is_confirmed",
heading: "Confirm",
visually_hide_heading: true,
no_hint_text: true,
error: @confirm_error_copy,
items: [
{
label: "By creating this content block you are confirming that, to the best of your knowledge, the details you are providing are correct.",
value: true,
},
],
} %>
<%= form_with(
url: content_block_manager.content_block_manager_content_block_workflow_path(@content_block_edition, step: :review),
method: :put,
id: "review",
) do %>
<%= render "govuk_publishing_components/components/checkboxes", {
name: "is_confirmed",
id: "is_confirmed",
heading: "Confirm",
visually_hide_heading: true,
no_hint_text: true,
error: @confirm_error_copy,
items: [
{
label: "By creating this content block you are confirming that, to the best of your knowledge, the details you are providing are correct.",
value: true,
},
],
} %>
<% end %>
</div>
</div>

<div class="govuk-grid-row">
<div class="govuk-grid-column-full">
<div class="govuk-button-group govuk-!-margin-bottom-6">
<div>
<%= render "govuk_publishing_components/components/button", {
text: is_scheduling? ? "Schedule" : "Publish",
name: "confirm",
type: "submit",
} %>
<% end %>
</div>
<div>
<%= render ContentBlockManager::Shared::CancelAndDeleteButtonComponent.new(url: content_block_manager.
content_block_manager_content_block_edition_path(@content_block_edition),
) %>
</div>
</div>
<%= render ContentBlockManager::Shared::ContinueOrCancelButtonGroup.new(
form_id: "review",
button_text: is_scheduling? ? "Schedule" : "Publish",
content_block_edition: @content_block_edition,
) %>
</div>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -21,47 +21,37 @@

<div class="govuk-grid-row">
<div class="govuk-grid-column-full">
<%= render(
ContentBlockManager::ContentBlock::Document::Show::HostEditionsTableComponent.new(
is_preview: true,
caption: "List of locations",
host_content_items: @host_content_items,
current_page: @page,
order: @order,
content_block_edition: @content_block_edition,
),
) %>
<%= form_with(
url: content_block_manager.content_block_manager_content_block_workflow_path(
edition_id: @content_block_edition.id,
step: :review_links,
),
id: "review_links",
method: :put,
) do %>
<%= render(
ContentBlockManager::ContentBlock::Document::Show::HostEditionsTableComponent.new(
is_preview: true,
caption: "List of locations",
host_content_items: @host_content_items,
current_page: @page,
order: @order,
content_block_edition: @content_block_edition,
),
) %>
<% end %>
</div>
</div>

<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
<div class="govuk-grid-row">
<div class="govuk-grid-column-full">
<div class="govuk-button-group">
<%= form_with(
url: content_block_manager.content_block_manager_content_block_workflow_path(
edition_id: @content_block_edition.id,
step: :review_links,
),
method: :put,
) do %>
<%= render "govuk_publishing_components/components/button", {
text: "Save and continue",
name: "save_and_continue",
value: "Save and continue",
type: "submit",
} %>
<% end %>
<%= render ContentBlockManager::Shared::CancelAndDeleteButtonComponent.new(url: content_block_manager.
content_block_manager_content_block_edition_path(
@content_block_edition, redirect_path:
content_block_manager.content_block_manager_content_block_document_path(@content_block_edition.document)
),
) %>
</div>
<%= render ContentBlockManager::Shared::ContinueOrCancelButtonGroup.new(
form_id: "review_links",
content_block_edition: @content_block_edition,
) %>
</div>
</div>

</div>
</div>
20 changes: 10 additions & 10 deletions lib/engines/content_block_manager/features/edit_object.feature
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,17 @@ Feature: Edit a content object
Then I should be on the "review_links" step
And I should see a back link to the "edit_draft" step
When I continue after reviewing the links
Then I should be on the "schedule_publishing" step
And I should see a back link to the "review_links" step
When I choose to publish the change now
Then I should be on the "internal_note" step
And I should see a back link to the "schedule_publishing" step
And I should see a back link to the "review_links" step
When I add an internal note
Then I should be on the "change_note" step
And I should see a back link to the "internal_note" step
When I add a change note
Then I should be on the "review" step
Then I should be on the "schedule_publishing" step
And I should see a back link to the "change_note" step
When I choose to publish the change now
Then I should be on the "review" step
And I should see a back link to the "schedule_publishing" step
When I review and confirm my answers are correct
Then I should be taken to the confirmation page for a published block
When I click to view the content block
Expand Down Expand Up @@ -63,11 +63,11 @@ Feature: Edit a content object
When I click the first edit link
And I fill out the form
And I continue after reviewing the links
When I choose to publish the change now
And I add an internal note
When I add an internal note
And I add a change note
And I choose to publish the change now
When I click cancel
Then I am taken back to Content Block Manager home page
Then I should be taken back to the document page
And no draft Content Block Edition has been created

Scenario: GDS editor sees validation errors for missing fields
Expand Down Expand Up @@ -100,9 +100,9 @@ Feature: Edit a content object
When I click the first edit link
When I fill out the form
And I continue after reviewing the links
And I choose to publish the change now
And I add an internal note
And I add a change note
And I choose to publish the change now
Then I am asked to review my answers
When I click publish without confirming my details
Then I should see a message that I need to confirm the details are correct
Expand All @@ -113,9 +113,9 @@ Feature: Edit a content object
When I revisit the edit page
Then I should see a warning telling me there is a scheduled change
When I make the changes
And I choose to publish the change now
And I add an internal note
And I add a change note
And I choose to publish the change now
When I review and confirm my answers are correct
Then I should be taken to the confirmation page for a published block
When I click to view the content block
Expand Down
Loading