Skip to content

Commit 81171aa

Browse files
Merge branch 'changesInGalleyForm-844' into 'main'
Faz adaptações no envio da composição final See merge request softwares-pkp/plugins_ojs/doiscielo!27
2 parents d99ff5f + 46329d7 commit 81171aa

5 files changed

Lines changed: 87 additions & 2 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'))) {
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/tests/Test1_submissionWizard.cy.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,15 @@ describe('SciELO Screening Plugin - Submission wizard tests', function() {
194194
cy.contains('It was not possible to verify the scientific production of the ORCID records, since no PDF document was sent');
195195
cy.get('.pkpSteps__step button:contains("Upload Files")').click();
196196

197+
cy.get('a:contains("Add File")').click();
198+
cy.get('.pkp_modal_panel').within(() => {
199+
cy.contains('Add File');
200+
cy.get('label:contains("This galley will be available at a separate website")').should('not.exist');
201+
cy.get('input[name="remotelyHostedContent"]').should('not.exist');
202+
cy.get('input[name="urlPath"]').should('not.exist');
203+
cy.get('a.pkpModalCloseButton').click();
204+
});
205+
197206
cy.addSubmissionGalleys([files[0], files[0]]);
198207
cy.contains('button', 'Continue').click();
199208
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.contains('a', '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>

version.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
<version>
99
<application>scieloScreening</application>
1010
<type>plugins.generic</type>
11-
<release>2.1.3.0</release>
12-
<date>2025-09-12</date>
11+
<release>2.1.4.0</release>
12+
<date>2025-10-19</date>
1313
<lazy-load>1</lazy-load>
1414
<class>ScieloScreeningPlugin</class>
1515
</version>

0 commit comments

Comments
 (0)