diff --git a/app/assets/javascripts/protocols/index.js b/app/assets/javascripts/protocols/index.js
index 9a78d5d74..d538b4a4e 100644
--- a/app/assets/javascripts/protocols/index.js
+++ b/app/assets/javascripts/protocols/index.js
@@ -6,7 +6,7 @@
// Global variables
var ProtocolsIndex = (function() {
const ALL_VERSIONS_VALUE = 'All';
- var PERMISSIONS = ['archivable', 'restorable', 'copyable'];
+ var PERMISSIONS = ['archivable', 'restorable', 'copyable', 'readable'];
var rowsSelected = [];
var protocolsTableEl = null;
var protocolsDatatable = null;
diff --git a/app/assets/stylesheets/protocols/index.scss b/app/assets/stylesheets/protocols/index.scss
index 8ab373011..13a317f2f 100644
--- a/app/assets/stylesheets/protocols/index.scss
+++ b/app/assets/stylesheets/protocols/index.scss
@@ -151,6 +151,10 @@
border: 2px solid $color-concrete;
}
}
+
+ .not-clickable-record {
+ color: $color-alto;
+ }
}
.protocol-filters {
diff --git a/app/controllers/protocols_controller.rb b/app/controllers/protocols_controller.rb
index 409ce35f7..cff328d6d 100644
--- a/app/controllers/protocols_controller.rb
+++ b/app/controllers/protocols_controller.rb
@@ -915,7 +915,8 @@ class ProtocolsController < ApplicationController
render json: {
copyable: can_clone_protocol_in_repository?(@protocol),
archivable: can_archive_protocol_in_repository?(@protocol),
- restorable: can_restore_protocol_in_repository?(@protocol)
+ restorable: can_restore_protocol_in_repository?(@protocol),
+ readable: can_read_protocol_in_repository?(@protocol)
}
end
end
@@ -984,7 +985,8 @@ class ProtocolsController < ApplicationController
current_team_switch(@protocol.team) if current_team != @protocol.team
unless @protocol.present? &&
(can_read_protocol_in_module?(@protocol) ||
- can_read_protocol_in_repository?(@protocol))
+ can_read_protocol_in_repository?(@protocol) ||
+ (@protocol.in_repository? && can_manage_team?(@protocol.team)))
render_403
end
end
diff --git a/app/datatables/protocols_datatable.rb b/app/datatables/protocols_datatable.rb
index e9a3b02e3..0cf418dbf 100644
--- a/app/datatables/protocols_datatable.rb
+++ b/app/datatables/protocols_datatable.rb
@@ -5,6 +5,7 @@ class ProtocolsDatatable < CustomDatatable
include ActiveRecord::Sanitization::ClassMethods
include InputSanitizeHelper
include Rails.application.routes.url_helpers
+ include Canaid::Helpers::PermissionsHelper
PREFIXED_ID_SQL = "('#{Protocol::ID_PREFIX}' || COALESCE(\"protocols\".\"parent_id\", \"protocols\".\"id\"))"
@@ -208,7 +209,13 @@ class ProtocolsDatatable < CustomDatatable
else
protocol_path(record)
end
- "#{escape_input(record.name)}"
+
+ if can_read_protocol_in_repository?(@user, record)
+ "#{escape_input(record.name)}"
+ else
+ # team admin can only see recod name
+ "#{escape_input(record.name)}"
+ end
end
def keywords_html(record)
@@ -233,7 +240,8 @@ class ProtocolsDatatable < CustomDatatable
def versions_html(record)
@view.controller
- .render_to_string(partial: 'protocols/index/protocol_versions.html.erb', locals: { protocol: record })
+ .render_to_string(partial: 'protocols/index/protocol_versions.html.erb',
+ locals: { protocol: record, readable: can_read_protocol_in_repository?(@user, record) })
end
def access_html(record)
diff --git a/app/views/protocols/index/_action_toolbar.html.erb b/app/views/protocols/index/_action_toolbar.html.erb
index b990c8920..d99a83c54 100644
--- a/app/views/protocols/index/_action_toolbar.html.erb
+++ b/app/views/protocols/index/_action_toolbar.html.erb
@@ -1,5 +1,5 @@
-
-
+
<%= t("protocols.index.action_toolbar.export") %>
diff --git a/app/views/protocols/index/_protocol_versions.html.erb b/app/views/protocols/index/_protocol_versions.html.erb
index f80184f1f..d8f7c41a8 100644
--- a/app/views/protocols/index/_protocol_versions.html.erb
+++ b/app/views/protocols/index/_protocol_versions.html.erb
@@ -1,16 +1,29 @@
<% if protocol.in_repository_published_original? || protocol.in_repository_published_version? %>
- <% parent = protocol.parent || protocol %>
+ <% parent = protocol.parent || protocol %>
+ <% if readable %>
<%= link_to versions_modal_protocol_path(parent), class: 'protocol-versions-link', remote: true do %>
- <%= protocol.nr_of_versions %>
+ <%= protocol.nr_of_versions %>
<% end %>
- <% if parent.draft.present? %>
- /
- <%= link_to protocol_path(parent.draft) do %>
- <%= t("protocols.index.table.draft") %>
- <% end %>
- <% end %>
-<% elsif protocol.in_repository_draft? %>
- <%= link_to protocol_path(protocol) do %>
+ <% else %>
+ <%= protocol.nr_of_versions %>
+ <% end %>
+ <% if parent.draft.present? %>
+ <% if readable %>
+ /
+ <%= link_to protocol_path(parent.draft) do %>
<%= t("protocols.index.table.draft") %>
+ <% end %>
+ <% else %>
+ /
+ <%= t("protocols.index.table.draft") %>
<% end %>
+ <% end %>
+<% elsif protocol.in_repository_draft? %>
+ <% if readable %>
+ <%= link_to protocol_path(protocol) do %>
+ <%= t("protocols.index.table.draft") %>
+ <% end %>
+ <% else %>
+ <%= t("protocols.index.table.draft") %>
+ <% end %>
<% end %>