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

pkp/pkp-lib#7191 Implement new submission wizard #371

Draft
wants to merge 16 commits into
base: main
Choose a base branch
from
Draft
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
6 changes: 2 additions & 4 deletions api/v1/submissions/SubmissionHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/

namespace APP\API\v1\submissions;

use APP\core\Services;
use APP\facades\Repo;
use PKP\db\DAORegistry;
Expand Down Expand Up @@ -103,10 +103,8 @@ public function relatePublication($slimRequest, $response, $args)
if (!$submissionContext || $submissionContext->getId() !== $submission->getData('contextId')) {
$submissionContext = Services::get('context')->get($submission->getData('contextId'));
}
$primaryLocale = $publication->getData('locale');
$allowedLocales = $submissionContext->getData('supportedSubmissionLocales');

$errors = Repo::publication()->validate($publication, $params, $allowedLocales, $primaryLocale);
$errors = Repo::publication()->validate($publication, $params, $submission, $submissionContext);

if (!empty($errors)) {
return $response->withStatus(400)->withJson($errors);
Expand Down
64 changes: 0 additions & 64 deletions classes/components/forms/context/ScreeningForm.php

This file was deleted.

22 changes: 22 additions & 0 deletions classes/components/forms/publication/ContributorForm.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php
/**
* @file classes/components/form/publication/ContributorForm.php
*
* Copyright (c) 2014-2022 Simon Fraser University
* Copyright (c) 2000-2022 John Willinsky
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
*
* @class ContributorForm
* @ingroup classes_controllers_form
*
* @brief A preset form for adding and editing a contributor for a publication.
*/

namespace APP\components\forms\publication;

use PKP\components\forms\publication\PKPContributorForm;

class ContributorForm extends PKPContributorForm
{
//
}
61 changes: 61 additions & 0 deletions classes/components/forms/publication/LicenseUrlForm.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<?php
/**
* @file classes/components/form/context/PKPLicenseForm.php
*
* Copyright (c) 2014-2021 Simon Fraser University
* Copyright (c) 2000-2021 John Willinsky
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
*
* @class PKPLicenseForm
* @ingroup classes_controllers_form
*
* @brief A preset form for configuring a pubication's license URL.
*/

namespace APP\components\forms\publication;

use APP\core\Application;
use APP\publication\Publication;
use PKP\components\forms\FieldRadioInput;
use PKP\components\forms\FormComponent;
use PKP\context\Context;

class LicenseUrlForm extends FormComponent
{
public Context $context;
public Publication $publication;
public array $licenseOptions = [];

public function __construct(string $id, string $method, string $action, Publication $publication, Context $context)
{
parent::__construct($id, $method, $action, []);

$this->context = $context;
$this->publication = $publication;

$this->addLicenseField();
}

protected function addLicenseField(): void
{
$licenseOptions = Application::getCCLicenseOptions();
foreach ($licenseOptions as $url => $label) {
$this->licenseOptions[] = [
'value' => $url,
'label' => __($label),
];
}
$this->licenseOptions[] = [
'value' => 'other',
'label' => __('manager.distribution.license.other'),
'isInput' => true,
];

$this->addField(new FieldRadioInput('licenseUrl', [
'label' => __('manager.distribution.license'),
'type' => 'radio',
'options' => $this->licenseOptions,
'value' => $this->publication->getData('licenseUrl') ?? $this->context->getData('licenseUrl'),
]));
}
}
5 changes: 2 additions & 3 deletions classes/components/forms/publication/RelationForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,12 @@ class RelationForm extends FormComponent
* Constructor
*
* @param string $action URL to submit the form to
* @param array $locales Supported locales
* @param Publication $publication The publication to change settings for
*/
public function __construct($action, $locales, $publication)
public function __construct($action, $publication)
{
$this->action = $action;
$this->locales = $locales;
$this->locales = [];

// Relation options
$this->addField(new FieldOptions('relationStatus', [
Expand Down
35 changes: 35 additions & 0 deletions classes/components/forms/publication/TitleAbstractForm.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php
/**
* @file classes/components/form/publication/TitleAbstractForm.inc.php
*
* Copyright (c) 2014-2022 Simon Fraser University
* Copyright (c) 2000-2022 John Willinsky
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
*
* @class TitleAbstractForm
* @ingroup classes_controllers_form
*
* @brief A preset form for setting a publication's title and abstract
*/

namespace APP\components\forms\publication;

use APP\publication\Publication;
use APP\server\Section;
use PKP\components\forms\publication\TitleAbstractForm as PKPTitleAbstractForm;

class TitleAbstractForm extends PKPTitleAbstractForm
{
public Section $section;

public function __construct(string $action, array $locales, Publication $publication, Section $section, bool $isSubmissionWizard = false)
{
$this->section = $section;
$this->abstractWordLimit = $section->getData('wordCount')
? (int) $section->getData('wordCount')
: 0;
$this->isAbstractRequired = !$section->getData('abstractsNotRequired');

parent::__construct($action, $locales, $publication, $isSubmissionWizard);
}
}
82 changes: 82 additions & 0 deletions classes/components/forms/submission/ReconfigureSubmission.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
<?php
/**
* @file classes/components/form/submission/ReconfigureSubmission.inc.php
*
* Copyright (c) 2014-2022 Simon Fraser University
* Copyright (c) 2000-2022 John Willinsky
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
*
* @class ReconfigureSubmission
* @ingroup classes_controllers_form
*
* @brief A preset form for configuring the submission wizard, such as the
* submission's section or language, after the submission was started.
*/

namespace APP\components\forms\submission;

use APP\publication\Publication;
use APP\server\Section;
use APP\submission\Submission;
use PKP\components\forms\FieldHTML;
use PKP\components\forms\FieldOptions;
use PKP\components\forms\submission\ReconfigureSubmission as BaseReconfigureSubmission;
use PKP\context\Context;
use PKP\core\PKPString;

class ReconfigureSubmission extends BaseReconfigureSubmission
{
public array $sections;

/**
* @param Section[] $sections
*/
public function __construct(string $action, Submission $submission, Publication $publication, Context $context, array $sections)
{
parent::__construct($action, $submission, $publication, $context);

$this->sections = $sections;

if (count($this->sections) > 1) {
$this->addSectionsField();
}
}

protected function addSectionsField(): void
{
$this->addField(new FieldOptions('sectionId', [
'type' => 'radio',
'label' => __('section.section'),
'description' => __('author.submit.serverSectionDescription'),
'options' => $this->getSectionOptions(),
'isRequired' => true,
'value' => $this->publication->getData('sectionId'),
]));

foreach ($this->sections as $section) {
if (!trim(PKPString::html2text($section->getLocalizedPolicy()))) {
continue;
}
$this->addField(new FieldHTML('sectionDescription' . $section->getId(), [
'label' => $section->getLocalizedTitle(),
'description' => $section->getLocalizedPolicy(),
'showWhen' => ['sectionId', $section->getId()],
]));
}
}

/**
* Convert sections to options prop for a FieldOption
*/
protected function getSectionOptions(): array
{
$options = [];
foreach ($this->sections as $section) {
$options[] = [
'value' => $section->getId(),
'label' => $section->getLocalizedTitle(),
];
}
return $options;
}
}
75 changes: 75 additions & 0 deletions classes/components/forms/submission/StartSubmission.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
<?php
/**
* @file classes/components/form/submission/StartSubmission.inc.php
*
* Copyright (c) 2014-2022 Simon Fraser University
* Copyright (c) 2000-2022 John Willinsky
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
*
* @class StartSubmission
* @ingroup classes_controllers_form
*
* @brief The form to begin the submission wizard
*/

namespace APP\components\forms\submission;

use APP\server\Section;
use Illuminate\Support\Enumerable;
use PKP\components\forms\FieldHTML;
use PKP\components\forms\FieldOptions;
use PKP\components\forms\submission\StartSubmission as BaseStartSubmission;
use PKP\context\Context;
use PKP\core\PKPString;

class StartSubmission extends BaseStartSubmission
{
/**
* @param Section[] $sections The sections that this user can submit to
*/
public function __construct(string $action, Context $context, Enumerable $userGroups, array $sections)
{
parent::__construct($action, $context, $userGroups);

if (count($sections) === 1) {
$this->addHiddenField('sectionId', $sections[0]->getId());
} else {
$this->addField(new FieldOptions('sectionId', [
'type' => 'radio',
'label' => __('section.section'),
'description' => __('author.submit.serverSectionDescription'),
'options' => $this->getSectionOptions($sections),
'value' => '',
'isRequired' => true,
]), [FIELD_POSITION_AFTER, 'title']);

foreach ($sections as $section) {
if (!trim(PKPString::html2text($section->getLocalizedPolicy()))) {
continue;
}
$this->addField(new FieldHTML('sectionDescription' . $section->getId(), [
'label' => $section->getLocalizedTitle(),
'description' => $section->getLocalizedPolicy(),
'showWhen' => ['sectionId', $section->getId()],
]), [FIELD_POSITION_AFTER, 'sectionId']);
}
}
}

/**
* Convert sections to options prop for a FieldOption
*
* @param Section[] $sections
*/
protected function getSectionOptions(array $sections): array
{
$options = [];
foreach ($sections as $section) {
$options[] = [
'value' => $section->getId(),
'label' => $section->getLocalizedTitle(),
];
}
return $options;
}
}
2 changes: 1 addition & 1 deletion classes/mail/mailables/PostedAcknowledgement.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* @class PostedAcknowledgement
* @ingroup mail_mailables
*
* @brief Email sent to all authors when their preprint is posted
* @brief Email sent to submitting author when their preprint is posted.
*/

namespace APP\mail\mailables;
Expand Down
Loading