mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-12-26 09:42:46 +08:00
Merge branch 'features/protocol-template-renaming' into develop
This commit is contained in:
commit
4fb54535ad
3 changed files with 0 additions and 25 deletions
|
@ -909,7 +909,6 @@ class ProtocolsController < ApplicationController
|
|||
end
|
||||
|
||||
def set_inline_name_editing
|
||||
return unless @protocol.initial_draft?
|
||||
return unless can_manage_protocol_draft_in_repository?(@protocol)
|
||||
|
||||
@inline_editable_title_config = {
|
||||
|
|
|
@ -70,27 +70,10 @@ class Protocol < ApplicationRecord
|
|||
with_options if: :in_repository_published_version? do
|
||||
validates :parent, presence: true
|
||||
validate :parent_type_constraint
|
||||
validate :versions_same_name_constraint
|
||||
end
|
||||
with_options if: :in_repository_draft? do
|
||||
# Only one draft can exist for each protocol
|
||||
validate :ensure_single_draft
|
||||
validate :versions_same_name_constraint
|
||||
end
|
||||
with_options if: -> { in_repository? && !parent && !archived_changed?(from: false) } do |protocol|
|
||||
# Active protocol must have unique name inside its team
|
||||
protocol
|
||||
.validates_uniqueness_of :name, case_sensitive: false,
|
||||
scope: :team,
|
||||
conditions: lambda {
|
||||
where(
|
||||
protocol_type: [
|
||||
Protocol.protocol_types[:in_repository_published_original],
|
||||
Protocol.protocol_types[:in_repository_draft]
|
||||
],
|
||||
parent_id: nil
|
||||
)
|
||||
}
|
||||
end
|
||||
with_options if: -> { in_repository? && archived? && !previous_version } do |protocol|
|
||||
protocol.validates :archived_by, presence: true
|
||||
|
@ -796,12 +779,6 @@ class Protocol < ApplicationRecord
|
|||
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
|
||||
if Protocol.where(protocol_type: Protocol::REPOSITORY_TYPES)
|
||||
.where.not(id: id)
|
||||
|
|
|
@ -164,7 +164,6 @@ en:
|
|||
protocol:
|
||||
unchangable: "Published protocols can not be changed!"
|
||||
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_parent_draft_number: "Procol can have only 1 draft"
|
||||
attributes:
|
||||
|
|
Loading…
Reference in a new issue