Enable protocol template renaming [SCI-10851]

This commit is contained in:
Andrej 2024-07-30 10:41:06 +02:00
parent ab2f5c16b4
commit 452547564e
3 changed files with 0 additions and 10 deletions

View file

@ -909,7 +909,6 @@ class ProtocolsController < ApplicationController
end end
def set_inline_name_editing def set_inline_name_editing
return unless @protocol.initial_draft?
return unless can_manage_protocol_draft_in_repository?(@protocol) return unless can_manage_protocol_draft_in_repository?(@protocol)
@inline_editable_title_config = { @inline_editable_title_config = {

View file

@ -70,12 +70,10 @@ class Protocol < ApplicationRecord
with_options if: :in_repository_published_version? do with_options if: :in_repository_published_version? do
validates :parent, presence: true validates :parent, presence: true
validate :parent_type_constraint validate :parent_type_constraint
validate :versions_same_name_constraint
end end
with_options if: :in_repository_draft? do with_options if: :in_repository_draft? do
# Only one draft can exist for each protocol # Only one draft can exist for each protocol
validate :ensure_single_draft validate :ensure_single_draft
validate :versions_same_name_constraint
end end
with_options if: -> { in_repository? && !parent && !archived_changed?(from: false) } do |protocol| with_options if: -> { in_repository? && !parent && !archived_changed?(from: false) } do |protocol|
# Active protocol must have unique name inside its team # Active protocol must have unique name inside its team
@ -797,12 +795,6 @@ class Protocol < ApplicationRecord
end end
end end
def versions_same_name_constraint
if parent.present? && !parent.name.eql?(name)
errors.add(:base, I18n.t('activerecord.errors.models.protocol.wrong_version_name'))
end
end
def version_number_constraint def version_number_constraint
if Protocol.where(protocol_type: Protocol::REPOSITORY_TYPES) if Protocol.where(protocol_type: Protocol::REPOSITORY_TYPES)
.where.not(id: id) .where.not(id: id)

View file

@ -166,7 +166,6 @@ en:
protocol: protocol:
unchangable: "Published protocols can not be changed!" unchangable: "Published protocols can not be changed!"
wrong_parent_type: "Protocol can only be linked to published protocol!" wrong_parent_type: "Protocol can only be linked to published protocol!"
wrong_version_name: "Protocol versions should have same name!"
wrong_version_number: "Protocol version number should be sequential!" wrong_version_number: "Protocol version number should be sequential!"
wrong_parent_draft_number: "Procol can have only 1 draft" wrong_parent_draft_number: "Procol can have only 1 draft"
attributes: attributes: