mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-01-05 23:25:46 +08:00
Merge pull request #5107 from G-Chubinidze/gc_SCI_8058
Protocol permissions - button display [SCI-8058]
This commit is contained in:
commit
f6ee2e821c
6 changed files with 35 additions and 23 deletions
|
@ -19,6 +19,7 @@
|
|||
<button class="btn btn-light" @click="openVersionsModal">{{ i18n.t("protocols.header.versions") }}</button>
|
||||
<button v-if="protocol.attributes.urls.publish_url" @click="$emit('publish')" class="btn btn-primary">{{ i18n.t("protocols.header.publish") }}</button>
|
||||
<button v-if="protocol.attributes.urls.save_as_draft_url" @click="saveAsdraft" class="btn btn-secondary">{{ i18n.t("protocols.header.save_as_draft") }}</button>
|
||||
<button v-bind:disabled="protocol.attributes.disabled_drafting" v-if="protocol.attributes.disabled_drafting" @click="saveAsdraft" class="btn btn-secondary">{{ i18n.t("protocols.header.save_as_draft") }}</button>
|
||||
</div>
|
||||
</div>
|
||||
<div id="details-container" class="protocol-details collapse in">
|
||||
|
|
|
@ -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|
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -1,25 +1,25 @@
|
|||
<template id="protocolGeneralToolbar">
|
||||
<div class="left-general-toolbar">
|
||||
<button data-toggle="modal"
|
||||
data-target="#newProtocolModal"
|
||||
<%= 'disabled' if !can_create_protocols_in_repository?(@current_team) %>
|
||||
class="btn btn-primary only-active"
|
||||
>
|
||||
<span class="fas fa-plus"></span>
|
||||
<span class="hidden-xs"><%= t("protocols.index.create_new") %></span>
|
||||
</button>
|
||||
<% if can_create_protocols_in_repository?(@current_team) %>
|
||||
|
||||
<div id="protocol-import-group" class="sci-btn-group only-active" role="group">
|
||||
<button class="btn btn-light btn-open-file <%= 'disabled' unless can_create_protocols_in_repository?(@current_team) %>"
|
||||
data-toggle="dropdown"
|
||||
aria-haspopup="true"
|
||||
aria-expanded="false">
|
||||
<span class="fas fa-upload"></span><span class="hidden-xs"><%= t("protocols.index.import") %></span>
|
||||
<button data-toggle="modal"
|
||||
data-target="#newProtocolModal"
|
||||
class="btn btn-primary only-active"
|
||||
>
|
||||
<span class="fas fa-plus"></span>
|
||||
<span class="hidden-xs"><%= t("protocols.index.create_new") %></span>
|
||||
</button>
|
||||
<% if can_create_protocols_in_repository?(@current_team) %>
|
||||
|
||||
<div id="protocol-import-group" class="sci-btn-group only-active" role="group">
|
||||
<button class="btn btn-light btn-open-file"
|
||||
data-toggle="dropdown"
|
||||
aria-haspopup="true"
|
||||
aria-expanded="false">
|
||||
<span class="fas fa-upload"></span><span class="hidden-xs"><%= t("protocols.index.import") %></span>
|
||||
</button>
|
||||
<ul class="dropdown-menu">
|
||||
<li>
|
||||
<a class="btn-link-alt btn-default-link btn-open-file" <%= can_create_protocols_in_repository?(@current_team) ? 'data-action="import"' : 'disabled="disabled"' %>>
|
||||
<a class="btn-link-alt btn-default-link btn-open-file" data-action="import">
|
||||
<span><%= t("protocols.index.import_alt") %></span>
|
||||
<input type="file" value="" accept=".eln" data-role="import-file-input"
|
||||
data-team-id="<%= @current_team.id %>" data-import-url="<%= import_protocols_path %>"
|
||||
|
@ -30,7 +30,7 @@
|
|||
<%= link_to t("protocols.index.import_protocols_io"), '', data: { target: '#protocolsioModal', toggle: 'modal' } %>
|
||||
</li>
|
||||
</ul>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
</template>
|
||||
|
|
|
@ -56,7 +56,7 @@
|
|||
>
|
||||
<div class="protocol-comment-message">
|
||||
<div class="view-mode" data-placeholder="<%= t('protocols.index.versions.comment_placeholder') %>"><%= draft.version_comment %></div>
|
||||
<%= text_area_tag 'version_comment', draft.version_comment, disabled: true, class: 'smart-text-area hidden' %>
|
||||
<%= text_area_tag 'version_comment', draft.version_comment, disabled: can_publish_protocol_in_repository?(@protocol), class: 'smart-text-area hidden' %>
|
||||
</div>
|
||||
<div class="edit-buttons">
|
||||
<span class="cancel-button btn btn-secondary"><%= t('general.cancel') %></span>
|
||||
|
|
|
@ -19,6 +19,9 @@ module PermissionExtends
|
|||
%w(
|
||||
READ
|
||||
READ_ARCHIVED
|
||||
ARCHIVE
|
||||
RESTORE
|
||||
PUBLISH
|
||||
MANAGE
|
||||
USERS_MANAGE
|
||||
MANAGE_DRAFT
|
||||
|
|
Loading…
Reference in a new issue