From d1c398deb6004513857a284d546571618f8150ac Mon Sep 17 00:00:00 2001 From: Kat Date: Mon, 24 Jun 2024 08:29:27 +0100 Subject: [PATCH] Refactor organisation label --- app/components/lettings_log_summary_component.html.erb | 4 ++-- app/components/lettings_log_summary_component.rb | 6 ------ app/components/sales_log_summary_component.html.erb | 4 ++-- app/components/sales_log_summary_component.rb | 6 ------ app/models/organisation.rb | 4 ++++ 5 files changed, 8 insertions(+), 16 deletions(-) diff --git a/app/components/lettings_log_summary_component.html.erb b/app/components/lettings_log_summary_component.html.erb index 5dcf6b280..7686e3559 100644 --- a/app/components/lettings_log_summary_component.html.erb +++ b/app/components/lettings_log_summary_component.html.erb @@ -33,13 +33,13 @@ <% if log.owning_organisation %>
- +
<% end %> <% if log.managing_organisation %>
- +
<% end %> diff --git a/app/components/lettings_log_summary_component.rb b/app/components/lettings_log_summary_component.rb index 886516612..995e53517 100644 --- a/app/components/lettings_log_summary_component.rb +++ b/app/components/lettings_log_summary_component.rb @@ -10,10 +10,4 @@ class LettingsLogSummaryComponent < ViewComponent::Base def log_status helpers.status_tag(log.status) end - - def organisation_label(organisation) - return unless organisation - - organisation.status == :deleted ? "#{organisation.name} (deleted)" : organisation.name - end end diff --git a/app/components/sales_log_summary_component.html.erb b/app/components/sales_log_summary_component.html.erb index fc6b0216d..1d376aa4a 100644 --- a/app/components/sales_log_summary_component.html.erb +++ b/app/components/sales_log_summary_component.html.erb @@ -26,13 +26,13 @@ <% if log.owning_organisation %>
- +
<% end %> <% if log.managing_organisation %>
- +
<% end %> diff --git a/app/components/sales_log_summary_component.rb b/app/components/sales_log_summary_component.rb index 637e1f2c8..07249ea6f 100644 --- a/app/components/sales_log_summary_component.rb +++ b/app/components/sales_log_summary_component.rb @@ -10,10 +10,4 @@ class SalesLogSummaryComponent < ViewComponent::Base def log_status helpers.status_tag(log.status) end - - def organisation_label(organisation) - return unless organisation - - organisation.status == :deleted ? "#{organisation.name} (deleted)" : organisation.name - end end diff --git a/app/models/organisation.rb b/app/models/organisation.rb index d56dd7afb..8f77df166 100644 --- a/app/models/organisation.rb +++ b/app/models/organisation.rb @@ -186,4 +186,8 @@ class Organisation < ApplicationRecord users.each(&:discard!) update!(discarded_at: Time.zone.now) end + + def label + status == :deleted ? "#{name} (deleted)" : name + end end