Skip to content

Commit

Permalink
Merge branch 'editJustificationOnlyPosted-594' into 'main'
Browse files Browse the repository at this point in the history
Impede edição da justificativa após postagem da versão

See merge request softwares-pkp/plugins_ojs/authorVersion!8
  • Loading branch information
JhonathanLepidus committed Sep 26, 2023
2 parents 436d930 + b7f539b commit 4e17b2a
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 12 deletions.
9 changes: 6 additions & 3 deletions api/v1/authorVersion/AuthorVersionHandler.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,10 @@ public function submitVersion($slimRequest, $response, $args)
$submission = $this->getSubmission($slimRequest);
$publication = $submission->getLatestPublication();

if(!is_null($publication->getData('versionJustification'))) {
if(!is_null($publication->getData('versionJustification'))
|| $publication->getData('status') == STATUS_PUBLISHED
|| $publication->getData('version') == 1
) {
return $response->withStatus(400);
}

Expand All @@ -66,8 +69,8 @@ public function updateVersionJustification($slimRequest, $response, $args)
$submission = $this->getSubmission($slimRequest);
$publication = $submission->getLatestPublication();

if(is_null($publication->getData('versionJustification'))) {
$publication = $submission->getCurrentPublication();
if($publication->getData('status') == STATUS_PUBLISHED || $publication->getData('version') == 1) {
return $response->withStatus(400);
}

$publicationService = Services::get('publication');
Expand Down
3 changes: 0 additions & 3 deletions classes/components/forms/VersionJustificationForm.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@ public function __construct($action, $submission)
$this->method = 'POST';

$publication = $submission->getLatestPublication();
if(is_null($publication->getData('versionJustification'))) {
$publication = $submission->getCurrentPublication();
}

$this->addField(new FieldText('versionJustification', [
'label' => __('plugins.generic.authorVersion.lastVersionJustification'),
Expand Down
8 changes: 6 additions & 2 deletions cypress/tests/Test3_submitVersion.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,21 @@ describe('Author Version - Submit new version', function () {
cy.get('input[name="versionJustification"]').clear().type(finalVersionJustification, {delay: 0});
cy.get('.pkpWorkflow__versionJustificationForm button:contains("Save")').click();
});
it('Version justification is displayed in preprint landing page', function () {
it('After posting new version - Cant edit justification; Justification shown in landing page', function () {
cy.login('dbarnes', null, 'publicknowledge');
cy.get('#newVersion-button').click();
cy.contains('View Woods').click({force: true});

cy.get('#publication-button').click();
cy.get('.pkpHeader .pkpHeader__actions button:contains("Post")').click();
cy.get('.pkp_modal_panel button:contains("Post")').click();
cy.reload();

cy.get('.pkpHeader__actions a:contains("View")').click();
cy.get('button:contains("Version justification")').click();
cy.get('input[name="versionJustification"]').should('not.exist');
cy.contains(finalVersionJustification);

cy.get('.pkpHeader__actions a:contains("View")').click();
cy.get('h2:contains("Version justification")');
cy.contains(finalVersionJustification);
});
Expand Down
10 changes: 8 additions & 2 deletions templates/versionJustificationWorkflow.tpl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<span
class="pkpPublication__versionJustification"
v-if="workingPublication.version > 1 && (workingPublication.versionJustification || currentPublication.versionJustification)"
v-if="workingPublication.versionJustification"
>
<dropdown
class="pkpWorkflow__versionJustification"
Expand All @@ -9,8 +9,14 @@
>
<pkp-form
class="pkpWorkflow__versionJustificationForm"
v-if="workingPublication.id === latestPublication.id && latestPublication.status != getConstant('STATUS_PUBLISHED')"
v-bind="components.{$smarty.const.FORM_VERSION_JUSTIFICATION}"
@set="set"
/>
></pkp-form>
<span
v-if="workingPublication.status === getConstant('STATUS_PUBLISHED') || workingPublication.id != latestPublication.id"
>
{{ workingPublication.versionJustification }}
</span>
</dropdown>
</span>
4 changes: 2 additions & 2 deletions version.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
<version>
<application>authorVersion</application>
<type>plugins.generic</type>
<release>1.3.0.0</release>
<date>2023-09-21</date>
<release>1.3.1.0</release>
<date>2023-09-26</date>
<lazy-load>1</lazy-load>
<class>AuthorVersionPlugin</class>
</version>

0 comments on commit 4e17b2a

Please sign in to comment.