-
Notifications
You must be signed in to change notification settings - Fork 193
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9837 from alphagov/content-modelling/828-add-inte…
…rnal-and-external-change-notes-when-editing-blocks (828) Add internal and external change notes when editing blocks
- Loading branch information
Showing
27 changed files
with
631 additions
and
237 deletions.
There are no files selected for viewing
5 changes: 5 additions & 0 deletions
5
db/migrate/20250121102923_add_internal_change_note_to_content_block_editions.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class AddInternalChangeNoteToContentBlockEditions < ActiveRecord::Migration[7.1] | ||
def change | ||
add_column :content_block_editions, :internal_change_note, :string | ||
end | ||
end |
15 changes: 15 additions & 0 deletions
15
db/migrate/20250122155447_add_change_note_and_major_change_to_content_block_editions.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
class AddChangeNoteAndMajorChangeToContentBlockEditions < ActiveRecord::Migration[7.1] | ||
def up | ||
change_table :content_block_editions, bulk: true do |t| | ||
t.string "change_note" | ||
t.boolean "major_change" | ||
end | ||
end | ||
|
||
def down | ||
change_table :content_block_editions, bulk: true do |t| | ||
t.remove "change_note" | ||
t.remove "major_change" | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
93 changes: 93 additions & 0 deletions
93
lib/engines/content_block_manager/app/controllers/concerns/workflow/show_methods.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
module Workflow::ShowMethods | ||
extend ActiveSupport::Concern | ||
|
||
SHOW_ACTIONS = { | ||
edit_draft: :edit_draft, | ||
review_links: :review_links, | ||
schedule_publishing: :schedule_publishing, | ||
internal_note: :internal_note, | ||
change_note: :change_note, | ||
review: :review, | ||
review_update: :review_update, | ||
confirmation: :confirmation, | ||
}.freeze | ||
|
||
def edit_draft | ||
@content_block_edition = ContentBlockManager::ContentBlock::Edition.find(params[:id]) | ||
@form = ContentBlockManager::ContentBlock::EditionForm.for( | ||
content_block_edition: @content_block_edition, | ||
schema: @schema, | ||
) | ||
|
||
render "content_block_manager/content_block/editions/new" | ||
end | ||
|
||
def review_links | ||
@content_block_document = @content_block_edition.document | ||
@order = params[:order] | ||
@page = params[:page] | ||
|
||
@host_content_items = ContentBlockManager::HostContentItem.for_document( | ||
@content_block_document, | ||
order: @order, | ||
page: @page, | ||
) | ||
|
||
render :review_links | ||
end | ||
|
||
def schedule_publishing | ||
@content_block_document = @content_block_edition.document | ||
|
||
render :schedule_publishing | ||
end | ||
|
||
def internal_note | ||
@content_block_document = @content_block_edition.document | ||
@back_path = content_block_manager.content_block_manager_content_block_workflow_path( | ||
@content_block_edition, | ||
step: :schedule_publishing, | ||
) | ||
|
||
render :internal_note | ||
end | ||
|
||
def change_note | ||
@content_block_document = @content_block_edition.document | ||
@back_path = content_block_manager.content_block_manager_content_block_workflow_path( | ||
@content_block_edition, | ||
step: :internal_note, | ||
) | ||
|
||
render :change_note | ||
end | ||
|
||
def review_update | ||
@content_block_edition = ContentBlockManager::ContentBlock::Edition.find(params[:id]) | ||
|
||
@url = review_update_url | ||
@back_path = content_block_manager.content_block_manager_content_block_workflow_path( | ||
@content_block_edition, | ||
step: :change_note, | ||
) | ||
|
||
render :review | ||
end | ||
|
||
def review | ||
@content_block_edition = ContentBlockManager::ContentBlock::Edition.find(params[:id]) | ||
@back_path = content_block_manager.content_block_manager_content_block_documents_path | ||
|
||
@url = review_url | ||
|
||
render :review | ||
end | ||
|
||
def confirmation | ||
@content_block_edition = ContentBlockManager::ContentBlock::Edition.find(params[:id]) | ||
|
||
@confirmation_copy = ContentBlockManager::ConfirmationCopyPresenter.new(@content_block_edition) | ||
|
||
render :confirmation | ||
end | ||
end |
76 changes: 76 additions & 0 deletions
76
lib/engines/content_block_manager/app/controllers/concerns/workflow/update_methods.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
module Workflow::UpdateMethods | ||
extend ActiveSupport::Concern | ||
|
||
REVIEW_ERROR = Data.define(:attribute, :full_message) | ||
|
||
UPDATE_ACTIONS = { | ||
review_links: :redirect_to_schedule, | ||
schedule_publishing: :validate_schedule, | ||
internal_note: :update_internal_note, | ||
change_note: :update_change_note, | ||
review_update: :validate_review_page, | ||
review: :validate_review_page, | ||
}.freeze | ||
|
||
def redirect_to_schedule | ||
redirect_to content_block_manager.content_block_manager_content_block_workflow_path( | ||
id: @content_block_edition.id, | ||
step: :schedule_publishing, | ||
) | ||
end | ||
|
||
def validate_schedule | ||
@content_block_edition = ContentBlockManager::ContentBlock::Edition.find(params[:id]) | ||
|
||
validate_scheduled_edition | ||
|
||
redirect_to content_block_manager.content_block_manager_content_block_workflow_path( | ||
id: @content_block_edition.id, | ||
step: :internal_note, | ||
) | ||
rescue ActiveRecord::RecordInvalid | ||
render "content_block_manager/content_block/editions/workflow/schedule_publishing" | ||
end | ||
|
||
def update_internal_note | ||
@content_block_edition.update!(internal_change_note: edition_params[:internal_change_note]) | ||
|
||
redirect_to content_block_manager.content_block_manager_content_block_workflow_path( | ||
id: @content_block_edition.id, | ||
step: :change_note, | ||
) | ||
end | ||
|
||
def update_change_note | ||
@content_block_edition.assign_attributes(change_note: edition_params[:change_note], major_change: edition_params[:major_change]) | ||
@content_block_edition.save!(context: :change_note) | ||
|
||
redirect_to content_block_manager.content_block_manager_content_block_workflow_path( | ||
id: @content_block_edition.id, | ||
step: :review_update, | ||
) | ||
rescue ActiveRecord::RecordInvalid | ||
render :change_note | ||
end | ||
|
||
def validate_review_page | ||
if params[:is_confirmed].blank? | ||
@confirm_error_copy = I18n.t("content_block_edition.review_page.errors.confirm") | ||
@error_summary_errors = [{ text: @confirm_error_copy, href: "#is_confirmed-0" }] | ||
@url = on_review_page? ? review_url : review_update_url | ||
render "content_block_manager/content_block/editions/workflow/review" | ||
else | ||
schedule_or_publish | ||
end | ||
end | ||
|
||
private | ||
|
||
def on_review_page? | ||
params[:step] == :review | ||
end | ||
|
||
def on_review_update_page? | ||
params[:step] == :review_update | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.