Skip to content

Commit b4bce95

Browse files
committed
Merge branch 'rollbackReleaseToTheLastChanges' into 'main'
Rollback release to the last changes See merge request softwares-pkp/plugins_ojs/doiscielo!29
2 parents 8928748 + 549c95e commit b4bce95

5 files changed

Lines changed: 114 additions & 0 deletions

File tree

ScieloScreeningPlugin.php

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ public function register($category, $path, $mainContextId = null)
4141

4242
if ($success && $this->getEnabled($mainContextId)) {
4343
Hook::add('Form::config::after', [$this, 'editFormComponents']);
44+
Hook::add('preprintgalleyform::display', [$this, 'modifyGalleyForm']);
45+
Hook::add('preprintgalleyform::validate', [$this, 'modifyGalleyFormValidation']);
4446
Hook::add('TemplateManager::display', [$this, 'modifySubmissionSteps']);
4547
Hook::add('Submission::validateSubmit', [$this, 'validateSubmissionFields']);
4648
Hook::add('Template::SubmissionWizard::Section::Review', [$this, 'modifyReviewSections']);
@@ -164,6 +166,52 @@ private function removePrefixAndSubtitleFields($formConfig)
164166
return $formConfig;
165167
}
166168

169+
public function modifyGalleyForm($hookName, $params)
170+
{
171+
$request = Application::get()->getRequest();
172+
$templateMgr = TemplateManager::getManager($request);
173+
174+
$templateMgr->registerFilter("output", [$this, 'removeFieldsFromGalleyFormFilter']);
175+
}
176+
177+
public function removeFieldsFromGalleyFormFilter($output, $templateMgr)
178+
{
179+
if (preg_match('/id="preprintGalleyForm"/', $output)) {
180+
preg_match('/<\/form>/', $output, $matches, PREG_OFFSET_CAPTURE);
181+
182+
$posMatch = $matches[0][1];
183+
$removeGalleyFields = $templateMgr->fetch($this->getTemplateResource('removeGalleyFields.tpl'));
184+
$output = substr_replace($output, $removeGalleyFields, $posMatch, 0);
185+
186+
$templateMgr->unregisterFilter('output', array($this, 'removeFieldsFromGalleyFormFilter'));
187+
}
188+
189+
return $output;
190+
}
191+
192+
public function modifyGalleyFormValidation($hookName, $params)
193+
{
194+
$form = &$params[0];
195+
$submission = $form->_submission;
196+
197+
if (!empty($submission->getData('submissionProgress')) || !empty($form->_preprintGalley)) {
198+
return Hook::CONTINUE;
199+
}
200+
201+
$checker = new ScreeningChecker();
202+
$galleys = $submission->getGalleys();
203+
$galleysFiletypes = array_map(function ($galley) {
204+
return ($galley->getFileType());
205+
}, $galleys);
206+
207+
if ($checker->checkNumberPdfs($galleysFiletypes)[0]) {
208+
$form->addErrorField('preprintGalleyFormNotification');
209+
$form->addError('preprintGalleyFormNotification', __("plugins.generic.scieloScreening.screeningRules.numPdfs"));
210+
}
211+
212+
return Hook::CONTINUE;
213+
}
214+
167215
public function modifySubmissionSteps($hookName, $params)
168216
{
169217
$request = Application::get()->getRequest();

cypress/support/commands.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,32 @@ Cypress.Commands.add('findSubmission', function(tab, title) {
44
.parent().parent().within(() => {
55
cy.get('.pkpButton:contains("View")').click();
66
});
7+
});
8+
9+
Cypress.Commands.add('addSubmissionGalleys', (files) => {
10+
files.forEach(file => {
11+
cy.get('a[id^=component-grid-preprintgalleys-preprintgalleygrid-addGalley-button-]').contains("Add File").click();
12+
cy.wait(2000); // Avoid occasional failure due to form init taking time
13+
cy.get('div.pkp_modal_panel').then($modalDiv => {
14+
cy.wait(3000);
15+
$modalDiv.find('div.header:contains("Add File")');
16+
cy.get('div.pkp_modal_panel input[id^="label-"]').type('PDF', {delay: 0});
17+
cy.get('div.pkp_modal_panel button:contains("Save")').click();
18+
cy.wait(2000); // Avoid occasional failure due to form init taking time
19+
});
20+
cy.get('select[id=genreId]').select(file.genre);
21+
cy.fixture(file.file, 'base64').then(fileContent => {
22+
cy.get('input[type=file]').attachFile(
23+
{fileContent, 'filePath': file.fileName, 'mimeType': 'application/pdf', 'encoding': 'base64'}
24+
);
25+
});
26+
cy.get('#continueButton').click();
27+
cy.wait(2000);
28+
for (const field in file.metadata) {
29+
cy.get('input[id^="' + Cypress.$.escapeSelector(field) + '"]:visible,textarea[id^="' + Cypress.$.escapeSelector(field) + '"]').type(file.metadata[field], {delay: 0});
30+
cy.get('input[id^="language"').click({force: true}); // Close multilingual and datepicker pop-overs
31+
}
32+
cy.get('#continueButton').click();
33+
cy.get('#continueButton').click();
34+
});
735
});

cypress/tests/Test1_submissionWizard.cy.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ function addContributor(contributorData, toUpperCase = false) {
2525
cy.get('select[name="country"]').select(contributorData.country);
2626

2727
if ('orcid' in contributorData) {
28+
cy.get('.pkpFormField__control_top > .pkpButton').contains("Override").click();
2829
cy.get('input[name="orcid"]').type(contributorData.orcid, {delay: 0});
2930
}
3031

@@ -194,6 +195,15 @@ describe('SciELO Screening Plugin - Submission wizard tests', function() {
194195
cy.contains('It was not possible to verify the scientific production of the ORCID records, since no PDF document was sent');
195196
cy.get('.pkpSteps__step button:contains("Upload Files")').click();
196197

198+
cy.get('a[id^=component-grid-preprintgalleys-preprintgalleygrid-addGalley-button-]').contains("Add File").click();
199+
cy.get('.pkp_modal_panel').within(() => {
200+
cy.contains('Add File');
201+
cy.get('label:contains("This galley will be available at a separate website")').should('not.exist');
202+
cy.get('input[name="remotelyHostedContent"]').should('not.exist');
203+
cy.get('input[name="urlPath"]').should('not.exist');
204+
cy.get('a.pkpModalCloseButton').click();
205+
});
206+
197207
cy.addSubmissionGalleys([files[0], files[0]]);
198208
cy.contains('button', 'Continue').click();
199209
cy.contains('button', 'Continue').click();

cypress/tests/Test2_workflowFeatures.cy.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,23 @@ describe('SciELO Screening Plugin - WorkFlow features tests', function() {
8686
cy.contains('.pkpFormFieldLabel', 'Prefix').should('not.exist');
8787
cy.contains('.pkpFormFieldLabel', 'Subtitle').should('not.exist');
8888
});
89+
it("Authors can not send multiple PDFs", function () {
90+
cy.login('dphillips', null, 'publicknowledge');
91+
cy.findSubmission('myQueue', screenedSubmissionTitle);
92+
93+
cy.contains('button', 'Preprint').click();
94+
cy.contains('button', 'Galleys').click();
95+
96+
cy.get('a[id^=component-grid-preprintgalleys-preprintgalleygrid-addGalley-button-]').contains("Add File").click();
97+
cy.wait(200);
98+
cy.get('#preprintGalleyForm').within(() => {
99+
cy.get('input[name="label"]').type('PDF', {delay: 0});
100+
cy.contains('.submitFormButton', 'Save').click();
101+
});
102+
cy.reload();
103+
104+
cy.contains("Only one PDF document should be sent");
105+
});
89106
it("Disables plugin temporarily", function () {
90107
cy.login('dbarnes', null, 'publicknowledge');
91108
cy.contains('a', 'Website').click();

templates/removeGalleyFields.tpl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<script>
2+
setTimeout(function () {
3+
document.getElementById('urlPathSection').remove();
4+
document.getElementById('remotelyHostedContent')
5+
.parentElement
6+
.parentElement
7+
.parentElement
8+
.parentElement
9+
.remove();
10+
}, 10);
11+
</script>

0 commit comments

Comments
 (0)