Merge pull request #5280 from sboursen-scinote/sb_SCI-8237-alternative-solution

Title for publishing template protocol draft must include next version value (Alt) [SCI-8237]
This commit is contained in:
aignatov-bio 2023-04-14 10:37:51 +02:00 committed by GitHub
commit 134e7373c7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 25 additions and 5 deletions

View file

@ -5,7 +5,7 @@
<div class="modal-header"> <div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button> <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<h4 class="modal-title"> <h4 class="modal-title">
{{ i18n.t('protocols.publish_modal.title')}} {{ i18n.t('protocols.publish_modal.title', { nr: protocol.attributes.version })}}
</h4> </h4>
</div> </div>
<div class="modal-body"> <div class="modal-body">

View file

@ -25,7 +25,7 @@
<div class="protocol-metadata"> <div class="protocol-metadata">
<p class="data-block"> <p class="data-block">
<span>{{ i18n.t("protocols.header.version") }}</span> <span>{{ i18n.t("protocols.header.version") }}</span>
<b>{{ protocol.attributes.version }}</b> <b>{{ titleVersion }}</b>
</p> </p>
<p class="data-block" v-if="protocol.attributes.published"> <p class="data-block" v-if="protocol.attributes.published">
<span>{{ i18n.t("protocols.header.published_on") }}</span> <span>{{ i18n.t("protocols.header.published_on") }}</span>
@ -101,6 +101,21 @@
required: true required: true
}, },
}, },
computed: {
titleVersion() {
const createdFromVersion = this.protocol.attributes.created_from_version;
if (this.protocol.attributes.published) {
return this.protocol.attributes.version;
}
if (!createdFromVersion) {
return this.i18n.t('protocols.draft');
}
return this.i18n.t('protocols.header.draft_with_from_version', {nr: createdFromVersion});
}
},
methods: { methods: {
saveAsdraft() { saveAsdraft() {
$.post(this.protocol.attributes.urls.save_as_draft_url) $.post(this.protocol.attributes.urls.save_as_draft_url)

View file

@ -10,14 +10,18 @@ class ProtocolSerializer < ActiveModel::Serializer
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, :created_at_formatted, :updated_at_formatted, :added_by, :authors, :keywords, :version,
:code, :published, :version_comment, :archived, :linked, :has_draft, :code, :published, :version_comment, :archived, :linked, :has_draft,
:published_on_formatted, :published_by :published_on_formatted, :published_by, :created_from_version
def updated_at def updated_at
object.updated_at.to_i object.updated_at.to_i
end end
def version def version
object.in_repository_draft? ? I18n.t('protocols.draft') : object.version_number object.version_number
end
def created_from_version
object.previous_version&.version_number
end end
def published def published

View file

@ -2696,7 +2696,7 @@ en:
description_2: "Are you sure?" description_2: "Are you sure?"
confirm: "Yes, delete" confirm: "Yes, delete"
publish_modal: publish_modal:
title: "Publish protocol template" title: "Publish version %{nr} of the protocol template"
name: "Protocol template name" name: "Protocol template name"
comment: "Revision notes" comment: "Revision notes"
comment_placeholder: "What's new in this version?" comment_placeholder: "What's new in this version?"
@ -2714,6 +2714,7 @@ en:
header: header:
details: 'Details' details: 'Details'
versions: 'Versions' versions: 'Versions'
draft_with_from_version: 'Draft (from Version %{nr})'
protocol_description: 'Protocol description' protocol_description: 'Protocol description'
protocol_steps: 'Protocol steps' protocol_steps: 'Protocol steps'
publish: 'Publish' publish: 'Publish'