Browse Source

feat: user flash notices instead of explicit notification banners

pull/957/head
natdeanlewissoftwire 3 years ago
parent
commit
0d153dadad
  1. 6
      app/controllers/organisation_relationships_controller.rb
  2. 37
      app/views/organisation_relationships/housing_providers.html.erb

6
app/controllers/organisation_relationships_controller.rb

@ -53,7 +53,8 @@ class OrganisationRelationshipsController < ApplicationController
return
end
create!(child_organisation_id:, parent_organisation_id:, relationship_type:)
redirect_to housing_providers_organisation_path(related_organisation_id:)
flash[:notice] = "#{Organisation.find(related_organisation_id).name} is now one of #{current_user.data_coordinator? ? 'your' : "this organisation's"} housing providers"
redirect_to housing_providers_organisation_path
end
def create_managing_agent
@ -84,7 +85,8 @@ class OrganisationRelationshipsController < ApplicationController
def delete_housing_provider
organisation_relationship_to_remove = OrganisationRelationship.find_by!(child_organisation_id: @organisation.id, parent_organisation_id: target_organisation_id, relationship_type: OrganisationRelationship::OWNING)
organisation_relationship_to_remove.destroy!
redirect_to housing_providers_organisation_path(removed_organisation_id: target_organisation_id)
flash[:notice] = "#{Organisation.find(target_organisation_id).name} is no longer one of #{current_user.data_coordinator? ? 'your' : "this organisation's"} housing providers"
redirect_to housing_providers_organisation_path
end
private

37
app/views/organisation_relationships/housing_providers.html.erb

@ -1,45 +1,8 @@
<% item_label = format_label(@pagy.count, "housing providers") %>
<% if current_user.data_coordinator? %>
<% if params["related_organisation_id"] %>
<%= govuk_notification_banner(
title_text: "Success",
success: true, title_heading_level: 3,
title_id: "swanky-notifications"
) do |notification_banner|
notification_banner.heading(text: "#{Organisation.find(params['related_organisation_id']).name} is now one of your housing providers")
end %>
<% elsif params["removed_organisation_id"] %>
<%= govuk_notification_banner(
title_text: "Success",
success: true, title_heading_level: 3,
title_id: "swanky-notifications"
) do |notification_banner|
notification_banner.heading(text: "#{Organisation.find(params['removed_organisation_id']).name} is no longer one of your housing providers")
end %>
<% end %>
<% end %>
<% if current_user.support? %>
<%= render partial: "organisations/headings", locals: { main: @organisation.name, sub: nil } %>
<%= render SubNavigationComponent.new(items: secondary_items(request.path, @organisation.id)) %>
<h2 class="govuk-visually-hidden">Housing Providers</h2>
<% if params["related_organisation_id"] %>
<%= govuk_notification_banner(
title_text: "Success",
success: true, title_heading_level: 3,
title_id: "swanky-notifications"
) do |notification_banner|
notification_banner.heading(text: "#{Organisation.find(params['related_organisation_id']).name} is now one of this organisation's housing providers")
end %>
<% elsif params["removed_organisation_id"] %>
<%= govuk_notification_banner(
title_text: "Success",
success: true, title_heading_level: 3,
title_id: "swanky-notifications"
) do |notification_banner|
notification_banner.heading(text: "#{Organisation.find(params['removed_organisation_id']).name} is no longer one of this organisation's housing providers")
end %>
<% end %>
<p class="govuk-body">This organisation can submit logs for its housing providers.</p>
<% if @total_count == 0 %>
<p class="govuk-body">This organisation does not currently have any housing providers.</p>

Loading…
Cancel
Save