diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss index c14949e5f..e3e12a967 100644 --- a/app/assets/stylesheets/application.scss +++ b/app/assets/stylesheets/application.scss @@ -7,6 +7,7 @@ $govuk-page-width: 1140px; @import 'govuk_publishing_components/components/button'; @import 'govuk_publishing_components/components/checkboxes'; @import 'govuk_publishing_components/components/date-input'; +@import 'govuk_publishing_components/components/details'; @import 'govuk_publishing_components/components/document-list'; @import 'govuk_publishing_components/components/error-alert'; @import 'govuk_publishing_components/components/error-message'; @@ -37,6 +38,6 @@ $govuk-page-width: 1140px; @import 'govuk_publishing_components/components/title'; @import "tags"; @import "downtimes"; +@import "options_sidebar"; @import "publications"; -@import "popular_links"; @import "editions"; diff --git a/app/assets/stylesheets/popular_links.scss b/app/assets/stylesheets/options_sidebar.scss similarity index 89% rename from app/assets/stylesheets/popular_links.scss rename to app/assets/stylesheets/options_sidebar.scss index 4ce310c3e..69a301522 100644 --- a/app/assets/stylesheets/popular_links.scss +++ b/app/assets/stylesheets/options_sidebar.scss @@ -1,4 +1,4 @@ -.popular-links__sidebar { +.options-sidebar { .govuk-button { width: 100%; } diff --git a/app/controllers/editions_controller.rb b/app/controllers/editions_controller.rb index cd12f371e..7c7eb5a49 100644 --- a/app/controllers/editions_controller.rb +++ b/app/controllers/editions_controller.rb @@ -11,7 +11,7 @@ class EditionsController < InheritedResources::Base before_action only: %i[unpublish confirm_unpublish process_unpublish] do require_govuk_editor(redirect_path: edition_path(resource)) end - before_action only: %i[progress admin] do + before_action only: %i[progress admin update] do require_editor_permissions end @@ -31,6 +31,22 @@ def show alias_method :unpublish, :show alias_method :admin, :show + def update + @resource.assign_attributes(permitted_params) + + if @resource.save + UpdateWorker.perform_async(resource.id.to_s) + flash.now[:success] = "Edition updated successfully." + else + @artefact = @resource.artefact + end + rescue StandardError => e + Rails.logger.error "Error #{e.class} #{e.message}" + @resource.errors.add(:show, "Due to a service problem, the edition couldn't be updated") + ensure + render "show" + end + def history render action: "show" end @@ -133,4 +149,8 @@ def progress_action_param rescue StandardError nil end + + def permitted_params + params.require(:edition).permit(%i[title overview in_beta body major_change change_note]) + end end diff --git a/app/helpers/editions_helper.rb b/app/helpers/editions_helper.rb index 0fe663a63..cb15433f8 100644 --- a/app/helpers/editions_helper.rb +++ b/app/helpers/editions_helper.rb @@ -6,7 +6,7 @@ def activity_forms_required? params[:action] == "diff" end - def resource_form(resource, &form_definition) + def legacy_resource_form(resource, &form_definition) html_options = { id: "edition-form" } unless resource.locked_for_edits? || resource.archived? if resource.is_a?(Parted) || resource.is_a?(Varianted) diff --git a/app/helpers/tabbed_nav_helper.rb b/app/helpers/tabbed_nav_helper.rb index 07c5c4dac..22033d6ef 100644 --- a/app/helpers/tabbed_nav_helper.rb +++ b/app/helpers/tabbed_nav_helper.rb @@ -15,6 +15,8 @@ def current_tab_name current_tab = (request.path.split("/") & all_tab_names).first case current_tab + when nil + "edit" when "metadata" "metadata" when "unpublish" diff --git a/app/views/editions/secondary_nav_tabs/_edit.html.erb b/app/views/editions/secondary_nav_tabs/_edit.html.erb new file mode 100644 index 000000000..dba5656ae --- /dev/null +++ b/app/views/editions/secondary_nav_tabs/_edit.html.erb @@ -0,0 +1,128 @@ +
Tell users what has changed, where and why. Write in full sentences, leading with the most important words. For example, \"College A has been removed from the registered sponsors list because its licence has been suspended.\"
Guidance on change notes (opens in a new tab)").html_safe, + }), + }, + { + value: false, + text: "No", + bold: true, + checked: !@resource.major_change, + }, + ], + } %> + <% end %> + <% end %> +