From 349146aa44fd88eb911cb0088ad6f2616f047b19 Mon Sep 17 00:00:00 2001 From: Manny Dinssa <44172848+Dinssa@users.noreply.github.com> Date: Wed, 9 Apr 2025 13:28:06 +0100 Subject: [PATCH] Separate change organisations name from organisation edit view --- app/controllers/organisations_controller.rb | 8 ++++++++ app/helpers/organisations_helper.rb | 2 +- app/views/organisations/change_name.html.erb | 19 +++++++++++++++++++ app/views/organisations/edit.html.erb | 4 ---- config/routes.rb | 1 + 5 files changed, 29 insertions(+), 5 deletions(-) create mode 100644 app/views/organisations/change_name.html.erb diff --git a/app/controllers/organisations_controller.rb b/app/controllers/organisations_controller.rb index ea0b154e5..9c6690e8c 100644 --- a/app/controllers/organisations_controller.rb +++ b/app/controllers/organisations_controller.rb @@ -113,6 +113,14 @@ class OrganisationsController < ApplicationController end end + def change_name + if current_user.support? + render "change_name", layout: "application" + else + head :unauthorized + end + end + def deactivate authorize @organisation diff --git a/app/helpers/organisations_helper.rb b/app/helpers/organisations_helper.rb index 19c77b357..1467d7c2e 100644 --- a/app/helpers/organisations_helper.rb +++ b/app/helpers/organisations_helper.rb @@ -30,7 +30,7 @@ module OrganisationsHelper if user.support? row.with_action( visually_hidden_text: organisation.name.humanize.downcase, - href: edit_organisation_path(organisation), + href: change_name_organisation_path(organisation), html_attributes: { "data-qa": "change-#{organisation.name.downcase}" }, ) else diff --git a/app/views/organisations/change_name.html.erb b/app/views/organisations/change_name.html.erb new file mode 100644 index 000000000..7b118c1eb --- /dev/null +++ b/app/views/organisations/change_name.html.erb @@ -0,0 +1,19 @@ +<% content_for :title, "Change #{@organisation.name}’s name" %> + +<% content_for :before_content do %> + <%= govuk_back_link(href: :back) %> +<% end %> + +<%= form_for(@organisation, as: :organisation, html: { method: :patch }) do |f| %> +