mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-09-04 04:04:36 +08:00
Add published view for protocol [SCI-7617]
This commit is contained in:
parent
3902310463
commit
743d901310
6 changed files with 14 additions and 6 deletions
|
@ -78,7 +78,6 @@ class ProtocolsController < ApplicationController
|
||||||
only: %i(protocolsio_import_create protocolsio_import_save)
|
only: %i(protocolsio_import_create protocolsio_import_save)
|
||||||
|
|
||||||
before_action :set_importer, only: %i(load_from_file import)
|
before_action :set_importer, only: %i(load_from_file import)
|
||||||
|
|
||||||
before_action :set_inline_name_editing, only: :show
|
before_action :set_inline_name_editing, only: :show
|
||||||
|
|
||||||
layout 'fluid'
|
layout 'fluid'
|
||||||
|
|
|
@ -226,7 +226,7 @@
|
||||||
this.protocol.attributes.name = newName;
|
this.protocol.attributes.name = newName;
|
||||||
this.refreshProtocolStatus();
|
this.refreshProtocolStatus();
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: 'PUT',
|
type: 'PATCH',
|
||||||
url: this.urls.update_protocol_name_url,
|
url: this.urls.update_protocol_name_url,
|
||||||
data: { protocol: { name: newName } }
|
data: { protocol: { name: newName } }
|
||||||
});
|
});
|
||||||
|
|
|
@ -17,7 +17,8 @@
|
||||||
<span class="fas fa-print" aria-hidden="true"></span>
|
<span class="fas fa-print" aria-hidden="true"></span>
|
||||||
</a>
|
</a>
|
||||||
<button class="btn btn-light">{{ i18n.t("protocols.header.versions") }}</button>
|
<button class="btn btn-light">{{ i18n.t("protocols.header.versions") }}</button>
|
||||||
<button class="btn btn-primary">{{ i18n.t("protocols.header.publish") }}</button>
|
<button v-if="!protocol.attributes.published" class="btn btn-primary">{{ i18n.t("protocols.header.publish") }}</button>
|
||||||
|
<button v-else class="btn btn-secondary">{{ i18n.t("protocols.header.save_as_draft") }}</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div id="details-container" class="protocol-details collapse in">
|
<div id="details-container" class="protocol-details collapse in">
|
||||||
|
|
|
@ -86,7 +86,8 @@ Canaid::Permissions.register_for(Protocol) do
|
||||||
# protocol in repository: update, create/update/delete/reorder step,
|
# protocol in repository: update, create/update/delete/reorder step,
|
||||||
# toggle private/public visibility, archive
|
# toggle private/public visibility, archive
|
||||||
can :manage_protocol_in_repository do |user, protocol|
|
can :manage_protocol_in_repository do |user, protocol|
|
||||||
protocol.permission_granted?(user, ProtocolPermissions::MANAGE)
|
protocol.protocol_type.in_repository_draft? &&
|
||||||
|
protocol.permission_granted?(user, ProtocolPermissions::MANAGE)
|
||||||
end
|
end
|
||||||
|
|
||||||
can :manage_protocol_draft_in_repository do |user, protocol|
|
can :manage_protocol_draft_in_repository do |user, protocol|
|
||||||
|
|
|
@ -7,14 +7,19 @@ class ProtocolSerializer < ActiveModel::Serializer
|
||||||
include ActionView::Helpers::TextHelper
|
include ActionView::Helpers::TextHelper
|
||||||
|
|
||||||
attributes :name, :id, :urls, :description, :description_view, :updated_at, :in_repository,
|
attributes :name, :id, :urls, :description, :description_view, :updated_at, :in_repository,
|
||||||
:created_at_formatted, :updated_at_formatted, :added_by, :authors, :keywords, :version, :code
|
:created_at_formatted, :updated_at_formatted, :added_by, :authors, :keywords, :version, :code,
|
||||||
|
:published
|
||||||
|
|
||||||
def updated_at
|
def updated_at
|
||||||
object.updated_at.to_i
|
object.updated_at.to_i
|
||||||
end
|
end
|
||||||
|
|
||||||
def version
|
def version
|
||||||
object.protocol_type == 'in_repository_draft' ? I18n.t('protocols.header.draft') : object.version_number
|
object.in_repository_draft? ? I18n.t('protocols.draft') : object.version_number
|
||||||
|
end
|
||||||
|
|
||||||
|
def published
|
||||||
|
object.in_repository_published?
|
||||||
end
|
end
|
||||||
|
|
||||||
def added_by
|
def added_by
|
||||||
|
|
|
@ -2427,6 +2427,7 @@ en:
|
||||||
unchangable_error_message: "Predefined roles can not be changed!"
|
unchangable_error_message: "Predefined roles can not be changed!"
|
||||||
|
|
||||||
protocols:
|
protocols:
|
||||||
|
draft: "Draft"
|
||||||
no_text_placeholder: 'No protocol description'
|
no_text_placeholder: 'No protocol description'
|
||||||
reorder_steps:
|
reorder_steps:
|
||||||
button: "Rearrange steps"
|
button: "Rearrange steps"
|
||||||
|
@ -2535,6 +2536,7 @@ en:
|
||||||
protocol_description: 'Protocol description'
|
protocol_description: 'Protocol description'
|
||||||
protocol_steps: 'Protocol steps'
|
protocol_steps: 'Protocol steps'
|
||||||
publish: 'Publish'
|
publish: 'Publish'
|
||||||
|
save_as_draft: 'Save as draft'
|
||||||
version: "Version:"
|
version: "Version:"
|
||||||
draft: 'Draft'
|
draft: 'Draft'
|
||||||
created_at: "Created at:"
|
created_at: "Created at:"
|
||||||
|
|
Loading…
Add table
Reference in a new issue