diff --git a/app/javascript/vue/protocol/protocolMetadata.vue b/app/javascript/vue/protocol/protocolMetadata.vue
index 50354b0ef..4ccdac5d5 100644
--- a/app/javascript/vue/protocol/protocolMetadata.vue
+++ b/app/javascript/vue/protocol/protocolMetadata.vue
@@ -19,6 +19,7 @@
+
diff --git a/app/permissions/team.rb b/app/permissions/team.rb
index b827d96e8..1e9733027 100644
--- a/app/permissions/team.rb
+++ b/app/permissions/team.rb
@@ -105,11 +105,11 @@ Canaid::Permissions.register_for(Protocol) do
# protocol in repository: restore
can :restore_protocol_in_repository do |user, protocol|
- protocol.archived? && protocol.permission_granted?(user, ProtocolPermissions::MANAGE)
+ protocol.archived? && protocol.permission_granted?(user, ProtocolPermissions::RESTORE)
end
can :archive_protocol_in_repository do |user, protocol|
- protocol.active? && protocol.permission_granted?(user, ProtocolPermissions::MANAGE)
+ protocol.active? && protocol.permission_granted?(user, ProtocolPermissions::ARCHIVE)
end
# protocol in repository: copy
@@ -119,7 +119,7 @@ Canaid::Permissions.register_for(Protocol) do
can :publish_protocol_in_repository do |user, protocol|
protocol.in_repository_draft? &&
- protocol.permission_granted?(user, ProtocolPermissions::MANAGE)
+ protocol.permission_granted?(user, ProtocolPermissions::PUBLISH)
end
can :delete_protocol_draft_in_repository do |user, protocol|
diff --git a/app/serializers/protocol_serializer.rb b/app/serializers/protocol_serializer.rb
index 167ff01f7..f6a66a6c8 100644
--- a/app/serializers/protocol_serializer.rb
+++ b/app/serializers/protocol_serializer.rb
@@ -8,7 +8,7 @@ class ProtocolSerializer < ActiveModel::Serializer
attributes :name, :id, :urls, :description, :description_view, :updated_at, :in_repository,
:created_at_formatted, :updated_at_formatted, :added_by, :authors, :keywords, :version, :code,
- :published, :version_comment, :archived
+ :published, :version_comment, :archived, :disabled_drafting
def updated_at
object.updated_at.to_i
@@ -84,6 +84,14 @@ class ProtocolSerializer < ActiveModel::Serializer
!object.in_module?
end
+ def disabled_drafting
+ protocol_types = Protocol.where(name: object.name).pluck(:protocol_type)
+ object.protocol_type != 'in_repository_draft' &&
+ !object.archived &&
+ protocol_types.length > 1 &&
+ protocol_types.include?('in_repository_draft')
+ end
+
private
def load_from_repo_url
diff --git a/app/views/protocols/index/_general_toolbar.html.erb b/app/views/protocols/index/_general_toolbar.html.erb
index 8612e84b5..d5163c840 100644
--- a/app/views/protocols/index/_general_toolbar.html.erb
+++ b/app/views/protocols/index/_general_toolbar.html.erb
@@ -1,25 +1,25 @@
diff --git a/app/views/protocols/index/_protocol_versions_modal.html.erb b/app/views/protocols/index/_protocol_versions_modal.html.erb
index aef8738c8..7ef19f6f8 100644
--- a/app/views/protocols/index/_protocol_versions_modal.html.erb
+++ b/app/views/protocols/index/_protocol_versions_modal.html.erb
@@ -56,7 +56,7 @@
>
<%= t('general.cancel') %>
diff --git a/config/initializers/extends/permission_extends.rb b/config/initializers/extends/permission_extends.rb
index 943755476..f21c26707 100644
--- a/config/initializers/extends/permission_extends.rb
+++ b/config/initializers/extends/permission_extends.rb
@@ -19,6 +19,9 @@ module PermissionExtends
%w(
READ
READ_ARCHIVED
+ ARCHIVE
+ RESTORE
+ PUBLISH
MANAGE
USERS_MANAGE
MANAGE_DRAFT