Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[OJS][main] #10669 Change Version support for publications #4604

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions classes/components/forms/publication/PublishForm.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* @file classes/components/form/publication/PublishForm.php
*
Expand All @@ -23,6 +24,7 @@
use PKP\core\Core;
use PKP\core\PKPString;
use PKP\facades\Locale;
use PKP\publication\enums\VersionStage;

class PublishForm extends FormComponent
{
Expand Down Expand Up @@ -84,6 +86,23 @@ public function __construct($action, $publication, $submissionContext, $requirem
);
$submitLabel = __('publication.publish');
}

// If publication does not have a version stage assigned
$publicationVersion = $publication->getCurrentVersionData();
if (!isset($publicationVersion)) {
$submission = Repo::submission()->get($publication->getData('submissionId'));
$nextVersionData = Repo::submission()->getNextAvailableVersionData($submission, VersionStage::VERSION_OF_RECORD, false);

$msg .= '<p>' . __('publication.required.versionStage') . '</p>';
$msg .= '<p>' . __('publication.required.versionStage.assignment', [
'versionDataDisplay' => $nextVersionData->display()
]) . '</p>';
} else {
$msg .= '<p>' . __('publication.required.versionStage.alreadyAssignment', [
'versionDataDisplay' => $publicationVersion->display()
]) . '</p>';
}

$this->addPage([
'id' => 'default',
'submitButton' => [
Expand Down
8 changes: 6 additions & 2 deletions classes/publication/DAO.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* @file classes/publication/DAO.php
*
Expand Down Expand Up @@ -29,8 +30,11 @@ class DAO extends \PKP\publication\DAO
'submissionId' => 'submission_id',
'status' => 'status',
'urlPath' => 'url_path',
'version' => 'version',
'doiId' => 'doi_id'
'doiId' => 'doi_id',
'versionStage' => 'version_stage',
'versionMinor' => 'version_minor',
'versionMajor' => 'version_major',

];

/**
Expand Down
6 changes: 4 additions & 2 deletions classes/publication/Repository.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* @file classes/publication/Repository.php
*
Expand All @@ -24,6 +25,7 @@
use PKP\core\PKPString;
use PKP\db\DAORegistry;
use PKP\publication\Collector;
use PKP\publication\enums\VersionStage;

class Repository extends \PKP\publication\Repository
{
Expand Down Expand Up @@ -128,9 +130,9 @@ public function validatePublish(Publication $publication, Submission $submission
}

/** @copydoc \PKP\publication\Repository::version() */
public function version(Publication $publication): int
public function version(Publication $publication, ?VersionStage $versionStage = null, bool $isMinorVersion = true): int
{
$newId = parent::version($publication);
$newId = parent::version($publication, $versionStage, $isMinorVersion);

$context = Application::get()->getRequest()->getContext();

Expand Down
1 change: 1 addition & 0 deletions dbscripts/xml/upgrade.xml
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@
<migration class="PKP\migration\upgrade\v3_5_0\I10292_UpdateControlledVocabAssocId"/>
<migration class="PKP\migration\upgrade\v3_5_0\I10292_UpdateControlledVocabEntrySettingName"/>
<migration class="PKP\migration\upgrade\v3_5_0\FilterClassNames"/>
<migration class="PKP\migration\upgrade\v3_5_0\I4860_MigratePublicationVersion"/>
<note file="docs/release-notes/README-3.5.0" />
</upgrade>

Expand Down
4 changes: 2 additions & 2 deletions templates/authorDashboard/authorDashboard.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
<span v-else class="pkpPublication__statusUnpublished">{translate key="publication.status.unpublished"}</span>
</span>
<span v-if="publicationList.length > 1" class="pkpPublication__version">
<strong tabindex="0">{{ versionLabel }}</strong> {{ workingPublication.version }}
<strong tabindex="0">{{ versionLabel }}</strong> {{ workingPublication.versionDataDisplay }}
<dropdown
class="pkpPublication__versions"
label="{translate key="publication.version.all"}"
Expand All @@ -107,7 +107,7 @@
:disabled="publication.id === workingPublication.id"
@click="setWorkingPublicationById(publication.id)"
>
{{ publication.version }} /
{{ publication.versionDataDisplay }} /
<template v-if="publication.status === getConstant('STATUS_QUEUED') && publication.id === currentPublication.id">{translate key="publication.status.unscheduled"}</template>
<template v-else-if="publication.status === getConstant('STATUS_SCHEDULED')">{translate key="publication.status.scheduled"}</template>
<template v-else-if="publication.status === getConstant('STATUS_PUBLISHED')">{translate key="publication.status.published"}</template>
Expand Down
2 changes: 1 addition & 1 deletion templates/frontend/objects/article_details.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@
</h2>
<ul class="value">
{foreach from=array_reverse($article->getPublishedPublications()) item=iPublication}
{capture assign="name"}{translate key="submission.versionIdentity" datePublished=$iPublication->getData('datePublished')|date_format:$dateFormatShort version=$iPublication->getData('version')}{/capture}
{capture assign="name"}{translate key="submission.versionIdentity" datePublished=$iPublication->getData('datePublished')|date_format:$dateFormatShort version=$iPublication->getData('versionDataDisplay')}{/capture}
<li>
{if $iPublication->getId() === $publication->getId()}
{$name}
Expand Down
4 changes: 2 additions & 2 deletions templates/workflow/workflow.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@
<span v-else class="pkpPublication__statusUnpublished">{translate key="publication.status.unpublished"}</span>
</span>
<span v-if="publicationList.length > 1" class="pkpPublication__version">
<strong tabindex="0">{{ versionLabel }}</strong> {{ workingPublication.version }}
<strong tabindex="0">{{ versionLabel }}</strong> {{ workingPublication.versionDataDisplay }}
<dropdown
class="pkpPublication__versions"
label="{translate key="publication.version.all"}"
Expand All @@ -137,7 +137,7 @@
:disabled="publication.id === workingPublication.id"
@click="setWorkingPublicationById(publication.id)"
>
{{ publication.version }} /
{{ publication.versionDataDisplay }} /
<template v-if="publication.status === getConstant('STATUS_QUEUED') && publication.id === currentPublication.id">{translate key="publication.status.unscheduled"}</template>
<template v-else-if="publication.status === getConstant('STATUS_SCHEDULED')">{translate key="publication.status.scheduled"}</template>
<template v-else-if="publication.status === getConstant('STATUS_PUBLISHED')">{{ publication.datePublished }}</template>
Expand Down