From aa5caf3cc356f615bb82a8a17bcfb78c8a273e8f Mon Sep 17 00:00:00 2001 From: Giga Chubinidze Date: Thu, 8 Jun 2023 11:54:59 +0400 Subject: [PATCH] refactor --- app/models/concerns/archivable_model.rb | 5 +++++ app/models/protocol.rb | 4 ++++ app/views/my_modules/protocols/_protocol_status_bar.html.erb | 2 +- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/app/models/concerns/archivable_model.rb b/app/models/concerns/archivable_model.rb index 355240e05..7e15eeac8 100644 --- a/app/models/concerns/archivable_model.rb +++ b/app/models/concerns/archivable_model.rb @@ -48,6 +48,11 @@ module ArchivableModel save! end + def name_with_label + raise NotImplementedError, "Archivable model must implement the '.archived_branch?' method!" unless respond_to?(:archived_branch?) + I18n.t("labels.archived") if self.archived_branch? + end + protected def set_archive_timestamp diff --git a/app/models/protocol.rb b/app/models/protocol.rb index 1b27b9727..1a3ee2122 100644 --- a/app/models/protocol.rb +++ b/app/models/protocol.rb @@ -385,6 +385,10 @@ class Protocol < ApplicationRecord steps.count end + def archived_branch? + archived? || parent&.archived? + end + def completed_steps steps.where(completed: true) end diff --git a/app/views/my_modules/protocols/_protocol_status_bar.html.erb b/app/views/my_modules/protocols/_protocol_status_bar.html.erb index 573223a4e..d2549b317 100644 --- a/app/views/my_modules/protocols/_protocol_status_bar.html.erb +++ b/app/views/my_modules/protocols/_protocol_status_bar.html.erb @@ -18,7 +18,7 @@