This commit is contained in:
Giga Chubinidze 2023-06-08 11:54:59 +04:00
parent ecf38de4d3
commit aa5caf3cc3
3 changed files with 10 additions and 1 deletions

View file

@ -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

View file

@ -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

View file

@ -18,7 +18,7 @@
<div class="dropdown-content">
<div class="dropdown-header">
<h2 class="protocol-name">
<%= t("labels.archived") if @protocol.archived? || @protocol.parent&.archived? %>&nbsp;<%= @protocol.parent&.name || @protocol.name %>
<%= @protocol.name_with_label %>&nbsp;<%= @protocol.parent&.name || @protocol.name %>
</h2>
<% if @protocol.linked? %>
<div class="protocol-header-info">