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| %> +
+
+

+ <%= content_for(:title) %> +

+ + <%= f.govuk_text_field :name, autocomplete: "name", label: { size: "m" } %> + + <%= f.govuk_submit "Save changes" %> +
+
+<% end %> diff --git a/app/views/organisations/edit.html.erb b/app/views/organisations/edit.html.erb index b0bd05bf6..cf9033180 100644 --- a/app/views/organisations/edit.html.erb +++ b/app/views/organisations/edit.html.erb @@ -11,10 +11,6 @@ <%= content_for(:title) %> - <% if current_user.support? %> - <%= f.govuk_text_field :name, autocomplete: "name", label: { size: "m" } %> - <% end %> - <%= f.govuk_text_field :address_line1, label: { text: "Address line 1", size: "m" }, autocomplete: "address-line1" %> diff --git a/config/routes.rb b/config/routes.rb index 6b1b6458b..e9b94c0bb 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -156,6 +156,7 @@ Rails.application.routes.draw do get "details", to: "organisations#details" get "data-sharing-agreement", to: "organisations#data_sharing_agreement" post "data-sharing-agreement", to: "organisations#confirm_data_sharing_agreement" + get "change-name", to: "organisations#change_name", as: "change_name" get "users", to: "organisations#users" get "lettings-logs", to: "organisations#lettings_logs"