Browse Source
			
			
			
			
				
		* change housing provider -> stock owner * feat: add case and _ replacements * refactor: rename files * refactor: - changes * housing provider * refactor: registered ... renamingpull/1097/head
				 26 changed files with 221 additions and 221 deletions
			
			
		| @ -1,17 +1,17 @@ | |||||||
| class OrganisationRelationship < ApplicationRecord | class OrganisationRelationship < ApplicationRecord | ||||||
|   belongs_to :child_organisation, class_name: "Organisation" |   belongs_to :child_organisation, class_name: "Organisation" | ||||||
|   belongs_to :parent_organisation, class_name: "Organisation" |   belongs_to :parent_organisation, class_name: "Organisation" | ||||||
|   validates :parent_organisation_id, presence: { message: I18n.t("validations.organisation.housing_provider.blank") } |   validates :parent_organisation_id, presence: { message: I18n.t("validations.organisation.stock_owner.blank") } | ||||||
|   validates :child_organisation_id, presence: { message: I18n.t("validations.organisation.managing_agent.blank") } |   validates :child_organisation_id, presence: { message: I18n.t("validations.organisation.managing_agent.blank") } | ||||||
|   validates :parent_organisation_id, uniqueness: { scope: :child_organisation_id, message: I18n.t("validations.organisation.housing_provider.already_added") } |   validates :parent_organisation_id, uniqueness: { scope: :child_organisation_id, message: I18n.t("validations.organisation.stock_owner.already_added") } | ||||||
|   validates :child_organisation_id, uniqueness: { scope: :parent_organisation_id, message: I18n.t("validations.organisation.managing_agent.already_added") } |   validates :child_organisation_id, uniqueness: { scope: :parent_organisation_id, message: I18n.t("validations.organisation.managing_agent.already_added") } | ||||||
|   validate :validate_housing_provider_owns_stock, on: :housing_provider |   validate :validate_stock_owner_owns_stock, on: :stock_owner | ||||||
| 
 | 
 | ||||||
| private | private | ||||||
| 
 | 
 | ||||||
|   def validate_housing_provider_owns_stock |   def validate_stock_owner_owns_stock | ||||||
|     if parent_organisation_id.present? && !parent_organisation.holds_own_stock |     if parent_organisation_id.present? && !parent_organisation.holds_own_stock | ||||||
|       errors.add :parent_organisation_id, I18n.t("validations.organisation.housing_provider.does_not_own_stock") |       errors.add :parent_organisation_id, I18n.t("validations.organisation.stock_owner.does_not_own_stock") | ||||||
|     end |     end | ||||||
|   end |   end | ||||||
| end | end | ||||||
|  | |||||||
| @ -1,18 +1,18 @@ | |||||||
| <section class="app-table-group" tabindex="0" aria-labelledby="<%= title.dasherize %>"> | <section class="app-table-group" tabindex="0" aria-labelledby="<%= title.dasherize %>"> | ||||||
|   <%= govuk_table do |table| %> |   <%= govuk_table do |table| %> | ||||||
|     <%= table.caption(classes: %w[govuk-!-font-size-19 govuk-!-font-weight-regular]) do |caption| %> |     <%= table.caption(classes: %w[govuk-!-font-size-19 govuk-!-font-weight-regular]) do |caption| %> | ||||||
|       <%= render(SearchResultCaptionComponent.new(searched:, count: pagy.count, item_label:, total_count:, item: "housing providers", path: request.path)) %> |       <%= render(SearchResultCaptionComponent.new(searched:, count: pagy.count, item_label:, total_count:, item: "stock owners", path: request.path)) %> | ||||||
|     <% end %> |     <% end %> | ||||||
|     <% @housing_providers.each do |housing_provider| %> |     <% @stock_owners.each do |stock_owner| %> | ||||||
|       <%= table.body do |body| %> |       <%= table.body do |body| %> | ||||||
|         <%= body.row do |row| %> |         <%= body.row do |row| %> | ||||||
|           <% row.cell(text: housing_provider.name) %> |           <% row.cell(text: stock_owner.name) %> | ||||||
|           <% if current_user.data_coordinator? || current_user.support? %> |           <% if current_user.data_coordinator? || current_user.support? %> | ||||||
|             <% row.cell(html_attributes: { |             <% row.cell(html_attributes: { | ||||||
|               scope: "row", |               scope: "row", | ||||||
|               class: "govuk-!-text-align-right", |               class: "govuk-!-text-align-right", | ||||||
|             }) do %> |             }) do %> | ||||||
|               <%= govuk_link_to("Remove", housing_providers_remove_organisation_path(target_organisation_id: housing_provider.id)) %> |               <%= govuk_link_to("Remove", stock_owners_remove_organisation_path(target_organisation_id: stock_owner.id)) %> | ||||||
|             <% end %> |             <% end %> | ||||||
|           <% end %> |           <% end %> | ||||||
|         <% end %> |         <% end %> | ||||||
| @ -1,21 +1,21 @@ | |||||||
| <%= form_with url: housing_providers_organisation_path(target_organisation_id: @target_organisation.id), method: "delete", local: true do |f| %> | <%= form_with url: stock_owners_organisation_path(target_organisation_id: @target_organisation.id), method: "delete", local: true do |f| %> | ||||||
|   <% if current_user.support? %> |   <% if current_user.support? %> | ||||||
|     <%= render partial: "organisations/headings", locals: { main: @organisation.name, sub: nil } %> |     <%= render partial: "organisations/headings", locals: { main: @organisation.name, sub: nil } %> | ||||||
|     <%= render SubNavigationComponent.new(items: secondary_items(request.path, @organisation.id)) %> |     <%= render SubNavigationComponent.new(items: secondary_items(request.path, @organisation.id)) %> | ||||||
|     <h2 class="govuk-visually-hidden">Remove Housing Provider</h2> |     <h2 class="govuk-visually-hidden">Remove Stock Owner</h2> | ||||||
|   <% end %> |   <% end %> | ||||||
|   <% if current_user.support? %> |   <% if current_user.support? %> | ||||||
|     <%= govuk_back_link(href: :back) %> |     <%= govuk_back_link(href: :back) %> | ||||||
|     <%= render partial: "organisations/headings", locals: { main: "You are removing ‘#{@target_organisation.name}’ from this organisation's housing providers", sub: nil } %> |     <%= render partial: "organisations/headings", locals: { main: "You are removing ‘#{@target_organisation.name}’ from this organisation's stock owners", sub: nil } %> | ||||||
|   <% else %> |   <% else %> | ||||||
|     <% content_for :before_content do %> |     <% content_for :before_content do %> | ||||||
|       <%= govuk_back_link(href: :back) %> |       <%= govuk_back_link(href: :back) %> | ||||||
|     <% end %> |     <% end %> | ||||||
|     <%= render partial: "organisations/headings", locals: { main: "You are removing ‘#{@target_organisation.name}’ from your organisation's housing providers", sub: nil } %> |     <%= render partial: "organisations/headings", locals: { main: "You are removing ‘#{@target_organisation.name}’ from your organisation's stock owners", sub: nil } %> | ||||||
|   <% end %> |   <% end %> | ||||||
|   <%= govuk_warning_text text: "You will no longer be able to submit logs for #{@target_organisation.name}" %> |   <%= govuk_warning_text text: "You will no longer be able to submit logs for #{@target_organisation.name}" %> | ||||||
|   <div class="govuk-button-group"> |   <div class="govuk-button-group"> | ||||||
|       <%= f.govuk_submit "Confirm" %> |       <%= f.govuk_submit "Confirm" %> | ||||||
|       <%= govuk_button_link_to "Cancel", housing_providers_organisation_path(current_user.organisation), html: { method: :get }, secondary: true %> |       <%= govuk_button_link_to "Cancel", stock_owners_organisation_path(current_user.organisation), html: { method: :get }, secondary: true %> | ||||||
|   </div> |   </div> | ||||||
| <% end %> | <% end %> | ||||||
| @ -1,24 +1,24 @@ | |||||||
| <% item_label = format_label(@pagy.count, "housing providers") %> | <% item_label = format_label(@pagy.count, "stock owners") %> | ||||||
| <% if current_user.support? %> | <% if current_user.support? %> | ||||||
|   <%= render partial: "organisations/headings", locals: { main: @organisation.name, sub: nil } %> |   <%= render partial: "organisations/headings", locals: { main: @organisation.name, sub: nil } %> | ||||||
|   <%= render SubNavigationComponent.new(items: secondary_items(request.path, @organisation.id)) %> |   <%= render SubNavigationComponent.new(items: secondary_items(request.path, @organisation.id)) %> | ||||||
|   <h2 class="govuk-visually-hidden">Housing Providers</h2> |   <h2 class="govuk-visually-hidden">Stock Owners</h2> | ||||||
|   <p class="govuk-body">This organisation can submit logs for its housing providers.</p> |   <p class="govuk-body">This organisation can submit logs for its stock owners.</p> | ||||||
|   <% if @total_count == 0 %> |   <% if @total_count == 0 %> | ||||||
|     <p class="govuk-body">This organisation does not currently have any housing providers.</p> |     <p class="govuk-body">This organisation does not currently have any stock owners.</p> | ||||||
|   <% end %> |   <% end %> | ||||||
| <% else %> | <% else %> | ||||||
|   <%= render partial: "organisations/headings", locals: { main: "Your housing providers", sub: current_user.organisation.name } %> |   <%= render partial: "organisations/headings", locals: { main: "Your stock owners", sub: current_user.organisation.name } %> | ||||||
|   <p class="govuk-body">Your organisation can submit logs for its housing providers.</p> |   <p class="govuk-body">Your organisation can submit logs for its stock owners.</p> | ||||||
|   <% if @total_count == 0 %> |   <% if @total_count == 0 %> | ||||||
|     <p class="govuk-body">You do not currently have any housing providers.</p> |     <p class="govuk-body">You do not currently have any stock owners.</p> | ||||||
|   <% end %> |   <% end %> | ||||||
| <% end %> | <% end %> | ||||||
| <% if current_user.support? || current_user.data_coordinator? %> | <% if current_user.support? || current_user.data_coordinator? %> | ||||||
|   <%= govuk_button_link_to "Add a housing provider", housing_providers_add_organisation_path, html: { method: :get } %> |   <%= govuk_button_link_to "Add a stock owner", stock_owners_add_organisation_path, html: { method: :get } %> | ||||||
| <% end %> | <% end %> | ||||||
| <% if @total_count != 0 %> | <% if @total_count != 0 %> | ||||||
|   <%= render SearchComponent.new(current_user:, search_label: "Search for a housing provider", value: @searched) %> |   <%= render SearchComponent.new(current_user:, search_label: "Search for a stock owner", value: @searched) %> | ||||||
|   <%= render partial: "organisation_relationships/housing_provider_list", locals: { index: @housing_providers, title: "Housing providers", pagy: @pagy, searched: @searched, item_label:, total_count: @total_count } %> |   <%= render partial: "organisation_relationships/stock_owner_list", locals: { index: @stock_owners, title: "Stock owners", pagy: @pagy, searched: @searched, item_label:, total_count: @total_count } %> | ||||||
|   <%= render partial: "pagy/nav", locals: { pagy: @pagy, item_name: "housing providers" } %> |   <%= render partial: "pagy/nav", locals: { pagy: @pagy, item_name: "stock owners" } %> | ||||||
| <% end %> | <% end %> | ||||||
					Loading…
					
					
				
		Reference in new issue