mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-02-01 20:48:23 +08:00
Fix the issue with the published version number and refactor the code [SCI-8237]
This commit is contained in:
parent
0b76acbede
commit
4783ffcc4f
3 changed files with 11 additions and 11 deletions
|
@ -5,7 +5,7 @@
|
|||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
|
||||
<h4 class="modal-title">
|
||||
{{ i18n.t('protocols.publish_modal.title', { nr: protocol.attributes.version + 1 })}}
|
||||
{{ i18n.t('protocols.publish_modal.title', { nr: protocol.attributes.version })}}
|
||||
</h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
|
|
|
@ -103,17 +103,17 @@
|
|||
},
|
||||
computed: {
|
||||
titleVersion() {
|
||||
const version = this.protocol.attributes.version;
|
||||
const createdFromVersion = this.protocol.attributes.created_from_version;
|
||||
|
||||
if (this.protocol.attributes.published) {
|
||||
return version;
|
||||
return this.protocol.attributes.version;
|
||||
}
|
||||
|
||||
if (version === this.i18n.t('protocols.draft')) {
|
||||
return version;
|
||||
if (!createdFromVersion) {
|
||||
return this.i18n.t('protocols.draft');
|
||||
}
|
||||
|
||||
return this.i18n.t('protocols.header.draft_with_from_version', {nr: version});
|
||||
return this.i18n.t('protocols.header.draft_with_from_version', {nr: createdFromVersion});
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
|
|
|
@ -10,18 +10,18 @@ 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, :linked, :has_draft,
|
||||
:published_on_formatted, :published_by
|
||||
:published_on_formatted, :published_by, :created_from_version
|
||||
|
||||
def updated_at
|
||||
object.updated_at.to_i
|
||||
end
|
||||
|
||||
def version
|
||||
return object.version_number unless object.in_repository_draft?
|
||||
object.version_number
|
||||
end
|
||||
|
||||
return object.previous_version.version_number if object.previous_version
|
||||
|
||||
I18n.t('protocols.draft')
|
||||
def created_from_version
|
||||
object.previous_version&.version_number
|
||||
end
|
||||
|
||||
def published
|
||||
|
|
Loading…
Reference in a new issue