diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss index d403b16d5..c24594d38 100644 --- a/app/assets/stylesheets/application.scss +++ b/app/assets/stylesheets/application.scss @@ -23,6 +23,7 @@ $govuk-page-width: 1140px; @import 'govuk_publishing_components/components/lead-paragraph'; @import 'govuk_publishing_components/components/notice'; @import 'govuk_publishing_components/components/previous-and-next-navigation'; +@import 'govuk_publishing_components/components/radio'; @import 'govuk_publishing_components/components/search'; @import 'govuk_publishing_components/components/secondary-navigation'; @import 'govuk_publishing_components/components/select'; diff --git a/app/controllers/artefacts_controller.rb b/app/controllers/artefacts_controller.rb index f4ca8f26f..cd369cf76 100644 --- a/app/controllers/artefacts_controller.rb +++ b/app/controllers/artefacts_controller.rb @@ -18,10 +18,11 @@ def update artefact = Artefact.find(updatable_params[:id]) if artefact.update_as(current_user, updatable_params) UpdateWorker.perform_async(artefact.latest_edition_id) - flash[:notice] = "Metadata updated" + show_success_message else flash[:danger] = artefact.errors.full_messages.join("\n") end + redirect_to metadata_artefact_path(artefact) end @@ -29,6 +30,14 @@ def update private + def show_success_message + if FeatureConstraint.new("design_system_edit") + flash[:success] = "Metadata has successfully updated".html_safe + else + flash[:notice] = "Metadata updated" + end + end + def formats Artefact::FORMATS_BY_DEFAULT_OWNING_APP["publisher"] - Artefact::RETIRED_FORMATS end diff --git a/app/controllers/editions_controller.rb b/app/controllers/editions_controller.rb index ddbb55dd5..d89e13cca 100644 --- a/app/controllers/editions_controller.rb +++ b/app/controllers/editions_controller.rb @@ -1,7 +1,5 @@ -require "edition_duplicator" -require "edition_progressor" - class EditionsController < InheritedResources::Base + include TabbedNavHelper layout "design_system" defaults resource_class: Edition, collection_name: "editions", instance_name: "resource" @@ -13,13 +11,12 @@ def index def show @artefact = @resource.artefact - render action: "show" - end - def metadata render action: "show" end + alias_method :metadata, :show + def history render action: "show" end diff --git a/app/helpers/tabbed_nav_helper.rb b/app/helpers/tabbed_nav_helper.rb index e733afd7d..13d95b6e8 100644 --- a/app/helpers/tabbed_nav_helper.rb +++ b/app/helpers/tabbed_nav_helper.rb @@ -1,9 +1,8 @@ module TabbedNavHelper def edition_nav_items(edition) nav_items = [] - items = %w[edit tagging metadata history admin related_external_links unpublish] - items.each do |item| + all_tab_names.each do |item| nav_items << standard_nav_items(item, edition) end @@ -29,4 +28,15 @@ def edit_nav_item(label, href, current) }, ] end + + def current_tab_name + current_tab = (request.path.split("/") & all_tab_names).first + current_tab == "metadata" ? "metadata" : "temp_nav_text" + end + +private + + def all_tab_names + %w[edit tagging metadata history admin related_external_links unpublish] + end end diff --git a/app/views/editions/secondary_nav_tabs/_metadata.html.erb b/app/views/editions/secondary_nav_tabs/_metadata.html.erb new file mode 100644 index 000000000..01f29bab9 --- /dev/null +++ b/app/views/editions/secondary_nav_tabs/_metadata.html.erb @@ -0,0 +1,44 @@ +<%= render "govuk_publishing_components/components/heading", { + text: "Metadata", + heading_level: 2, + margin_bottom: 5, +} %> + +<% if Edition::PUBLISHING_API_DRAFT_STATES.include? publication.state %> + <%= form_for(@artefact, :html => { :class => "artefact", :id => "edit_artefact" }) do |f| %> + <%= f.hidden_field :id, value: @artefact.id %> + + <%= render "govuk_publishing_components/components/input", { + label: { + text: "Slug", + }, + hint: "If you change the slug of a published page, the old slug will automatically redirect to the new one.", + name: "artefact[slug]", + value: publication.slug, + heading_level: 2, + heading_size: "m", + } %> + + <%= render "govuk_publishing_components/components/radio", { + heading: "Language", + name: "artefact[language]", + inline: true, + items: [ + { + value: "en", + text: "English", + checked: publication.artefact.language == "en" ? true : false, + }, + { + value: "cy", + text: "Welsh", + checked: publication.artefact.language == "cy" ? true : false, + }, + ], + } %> + <%= render "govuk_publishing_components/components/button", { + text: "Update", + } %> + <% end %> +<% else %> +<% end %> diff --git a/app/views/editions/secondary_nav_tabs/_temp_nav_text.html.erb b/app/views/editions/secondary_nav_tabs/_temp_nav_text.html.erb new file mode 100644 index 000000000..58e0b9c8a --- /dev/null +++ b/app/views/editions/secondary_nav_tabs/_temp_nav_text.html.erb @@ -0,0 +1 @@ +