mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-11-09 16:01:30 +08:00
Display all protocol templates for team admin [SCI-8379] (#5391)
This commit is contained in:
parent
d8945cc627
commit
c6f5219043
6 changed files with 44 additions and 17 deletions
|
|
@ -6,7 +6,7 @@
|
||||||
// Global variables
|
// Global variables
|
||||||
var ProtocolsIndex = (function() {
|
var ProtocolsIndex = (function() {
|
||||||
const ALL_VERSIONS_VALUE = 'All';
|
const ALL_VERSIONS_VALUE = 'All';
|
||||||
var PERMISSIONS = ['archivable', 'restorable', 'copyable'];
|
var PERMISSIONS = ['archivable', 'restorable', 'copyable', 'readable'];
|
||||||
var rowsSelected = [];
|
var rowsSelected = [];
|
||||||
var protocolsTableEl = null;
|
var protocolsTableEl = null;
|
||||||
var protocolsDatatable = null;
|
var protocolsDatatable = null;
|
||||||
|
|
|
||||||
|
|
@ -151,6 +151,10 @@
|
||||||
border: 2px solid $color-concrete;
|
border: 2px solid $color-concrete;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.not-clickable-record {
|
||||||
|
color: $color-alto;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.protocol-filters {
|
.protocol-filters {
|
||||||
|
|
|
||||||
|
|
@ -915,7 +915,8 @@ class ProtocolsController < ApplicationController
|
||||||
render json: {
|
render json: {
|
||||||
copyable: can_clone_protocol_in_repository?(@protocol),
|
copyable: can_clone_protocol_in_repository?(@protocol),
|
||||||
archivable: can_archive_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
|
||||||
end
|
end
|
||||||
|
|
@ -984,7 +985,8 @@ class ProtocolsController < ApplicationController
|
||||||
current_team_switch(@protocol.team) if current_team != @protocol.team
|
current_team_switch(@protocol.team) if current_team != @protocol.team
|
||||||
unless @protocol.present? &&
|
unless @protocol.present? &&
|
||||||
(can_read_protocol_in_module?(@protocol) ||
|
(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
|
render_403
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ class ProtocolsDatatable < CustomDatatable
|
||||||
include ActiveRecord::Sanitization::ClassMethods
|
include ActiveRecord::Sanitization::ClassMethods
|
||||||
include InputSanitizeHelper
|
include InputSanitizeHelper
|
||||||
include Rails.application.routes.url_helpers
|
include Rails.application.routes.url_helpers
|
||||||
|
include Canaid::Helpers::PermissionsHelper
|
||||||
|
|
||||||
PREFIXED_ID_SQL = "('#{Protocol::ID_PREFIX}' || COALESCE(\"protocols\".\"parent_id\", \"protocols\".\"id\"))"
|
PREFIXED_ID_SQL = "('#{Protocol::ID_PREFIX}' || COALESCE(\"protocols\".\"parent_id\", \"protocols\".\"id\"))"
|
||||||
|
|
||||||
|
|
@ -208,7 +209,13 @@ class ProtocolsDatatable < CustomDatatable
|
||||||
else
|
else
|
||||||
protocol_path(record)
|
protocol_path(record)
|
||||||
end
|
end
|
||||||
"<a href='#{path}'>#{escape_input(record.name)}</a>"
|
|
||||||
|
if can_read_protocol_in_repository?(@user, record)
|
||||||
|
"<a href='#{path}'>#{escape_input(record.name)}</a>"
|
||||||
|
else
|
||||||
|
# team admin can only see recod name
|
||||||
|
"<span class='not-clickable-record'>#{escape_input(record.name)}</span>"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def keywords_html(record)
|
def keywords_html(record)
|
||||||
|
|
@ -233,7 +240,8 @@ class ProtocolsDatatable < CustomDatatable
|
||||||
|
|
||||||
def versions_html(record)
|
def versions_html(record)
|
||||||
@view.controller
|
@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
|
end
|
||||||
|
|
||||||
def access_html(record)
|
def access_html(record)
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
<template id="protocolActionToolbar">
|
<template id="protocolActionToolbar">
|
||||||
<button id="protocolVersions" class="btn btn-light single-object-action hidden only-active">
|
<button id="protocolVersions" class="btn btn-light single-object-action hidden only-active" data-for="readable">
|
||||||
<%= image_tag 'icon/versions.svg' %>
|
<%= image_tag 'icon/versions.svg' %>
|
||||||
<span class="button-text"><%= t("protocols.index.action_toolbar.versions") %></span>
|
<span class="button-text"><%= t("protocols.index.action_toolbar.versions") %></span>
|
||||||
</button>
|
</button>
|
||||||
|
|
@ -11,7 +11,7 @@
|
||||||
<i class="fas fa-copy"></i>
|
<i class="fas fa-copy"></i>
|
||||||
<span class="button-text"><%= t("protocols.index.action_toolbar.duplicate") %></span>
|
<span class="button-text"><%= t("protocols.index.action_toolbar.duplicate") %></span>
|
||||||
</button>
|
</button>
|
||||||
<button id="exportProtocol" class="btn btn-light single-object-action hidden only-active" data-url="<%= export_protocols_path %>">
|
<button id="exportProtocol" class="btn btn-light single-object-action hidden only-active" data-url="<%= export_protocols_path %>" data-for="readable">
|
||||||
<i class="fas fa-download"></i>
|
<i class="fas fa-download"></i>
|
||||||
<span class="button-text"><%= t("protocols.index.action_toolbar.export") %></span>
|
<span class="button-text"><%= t("protocols.index.action_toolbar.export") %></span>
|
||||||
</button>
|
</button>
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,29 @@
|
||||||
<% if protocol.in_repository_published_original? || protocol.in_repository_published_version? %>
|
<% 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 %>
|
<%= link_to versions_modal_protocol_path(parent), class: 'protocol-versions-link', remote: true do %>
|
||||||
<%= protocol.nr_of_versions %>
|
<%= protocol.nr_of_versions %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% if parent.draft.present? %>
|
<% else %>
|
||||||
/
|
<span class="not-clickable-record"><%= protocol.nr_of_versions %></span>
|
||||||
<%= link_to protocol_path(parent.draft) do %>
|
<% end %>
|
||||||
<%= t("protocols.index.table.draft") %>
|
<% if parent.draft.present? %>
|
||||||
<% end %>
|
<% if readable %>
|
||||||
<% end %>
|
/
|
||||||
<% elsif protocol.in_repository_draft? %>
|
<%= link_to protocol_path(parent.draft) do %>
|
||||||
<%= link_to protocol_path(protocol) do %>
|
|
||||||
<%= t("protocols.index.table.draft") %>
|
<%= t("protocols.index.table.draft") %>
|
||||||
|
<% end %>
|
||||||
|
<% else %>
|
||||||
|
<span class="not-clickable-record">/</span>
|
||||||
|
<span class="not-clickable-record"><%= t("protocols.index.table.draft") %></span>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
<% end %>
|
||||||
|
<% elsif protocol.in_repository_draft? %>
|
||||||
|
<% if readable %>
|
||||||
|
<%= link_to protocol_path(protocol) do %>
|
||||||
|
<%= t("protocols.index.table.draft") %>
|
||||||
|
<% end %>
|
||||||
|
<% else %>
|
||||||
|
<span class="not-clickable-record"><%= t("protocols.index.table.draft") %></span>
|
||||||
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue