Skip to content

Commit

Permalink
#5885 Review remainder update (#9612)
Browse files Browse the repository at this point in the history
* #5885 Review remainder update

* #5885 Review remainder update issues fixed

* #5885 typo fixed

* #5885 update remainder calculation

* #5885 removed unnecessary select from migration

* #5885 updated and added new from component to handle reminder

* #5885 removed unnecessary fields and controls with field range component enhancement

* #5885 updated using new slider component

* #5885 updated job class properties to public

* #5885 updated date validation rules to enum

* #5885 fixed displaying error on date comparison validation failure

* #5885 test added for queue job

* #5885 added mocked context service and context class for job testing

* #5885 added context checking first if available to resolve context path before resolving from request

* #5885 job test update

* #5885 job test update

* #5885 removed mistakenly pulled BaseInvitation during rebase

* #5885 updated job and test based on new inviation functionality implementation

* #5885 updated task

* #5885 translation update

* #5885 tests updated and removed reference of deprecated Services class

* #5885 test update

* #5885 test update
  • Loading branch information
touhidurabir authored Aug 30, 2024
1 parent a1f2666 commit 41b38eb
Show file tree
Hide file tree
Showing 21 changed files with 804 additions and 150 deletions.
15 changes: 3 additions & 12 deletions classes/components/forms/FieldSlider.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,27 +20,20 @@ class FieldSlider extends Field
/** @copydoc Field::$component */
public $component = 'field-slider';


/**
* Range min value
*
* @var int|float
*/
public $min;
public int|float $min;

/**
* Range max value
*
* @var int|float
*/
public $max;
public int|float $max;

/**
* Range step value
*
* @var int|float
*/
public $step = 1;
public int|float $step = 1;

/**
* Label for min value, it displays actual value when not present
Expand All @@ -67,8 +60,6 @@ class FieldSlider extends Field
*/
public ?string $valueLabelMax = null;



/**
* @copydoc Field::getConfig()
*/
Expand Down
125 changes: 100 additions & 25 deletions classes/components/forms/context/PKPReviewSetupForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
/**
* @file classes/components/form/context/PKPReviewSetupForm.php
*
* Copyright (c) 2014-2021 Simon Fraser University
* Copyright (c) 2000-2021 John Willinsky
* Copyright (c) 2014-2024 Simon Fraser University
* Copyright (c) 2000-2024 John Willinsky
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
*
* @class PKPReviewSetupForm
Expand All @@ -17,10 +17,11 @@
namespace PKP\components\forms\context;

use PKP\components\forms\FieldHTML;
use PKP\context\Context;
use PKP\components\forms\FieldOptions;
use PKP\components\forms\FieldSlider;
use PKP\components\forms\FieldText;
use PKP\components\forms\FormComponent;
use PKP\config\Config;
use PKP\submission\reviewAssignment\ReviewAssignment;

class PKPReviewSetupForm extends FormComponent
Expand All @@ -29,6 +30,12 @@ class PKPReviewSetupForm extends FormComponent
public $id = self::FORM_REVIEW_SETUP;
public $method = 'PUT';

protected const REVIEW_SETTINGS_GROUP = 'reviewSettingsGroup';
protected const REVIEW_REMINDER_GROUP = 'reviewReminderGroup';

public const MIN_REMINDER_NOTIFICATION_SEND_IN_DAYS = 0;
public const MAX_REMINDER_NOTIFICATION_SEND_IN_DAYS = 14;

/**
* Constructor
*
Expand All @@ -41,23 +48,39 @@ public function __construct($action, $locales, $context)
$this->action = $action;
$this->locales = $locales;

$this->addField(new FieldOptions('defaultReviewMode', [
'label' => __('manager.setup.reviewOptions.reviewMode'),
'type' => 'radio',
'value' => $context->getData('defaultReviewMode'),
'options' => [
['value' => ReviewAssignment::SUBMISSION_REVIEW_METHOD_DOUBLEANONYMOUS, 'label' => __('editor.submissionReview.doubleAnonymous')],
['value' => ReviewAssignment::SUBMISSION_REVIEW_METHOD_ANONYMOUS, 'label' => __('editor.submissionReview.anonymous')],
['value' => ReviewAssignment::SUBMISSION_REVIEW_METHOD_OPEN, 'label' => __('editor.submissionReview.open')],
],
]))
$this
->addDefaultFields($context)
->addReminderFields($context);
}

/**
* Add the default review control fields
*/
protected function addDefaultFields(Context $context): static
{
$this
->addGroup([
'id' => self::REVIEW_SETTINGS_GROUP
])
->addField(new FieldOptions('defaultReviewMode', [
'label' => __('manager.setup.reviewOptions.reviewMode'),
'type' => 'radio',
'value' => $context->getData('defaultReviewMode'),
'options' => [
['value' => ReviewAssignment::SUBMISSION_REVIEW_METHOD_DOUBLEANONYMOUS, 'label' => __('editor.submissionReview.doubleAnonymous')],
['value' => ReviewAssignment::SUBMISSION_REVIEW_METHOD_ANONYMOUS, 'label' => __('editor.submissionReview.anonymous')],
['value' => ReviewAssignment::SUBMISSION_REVIEW_METHOD_OPEN, 'label' => __('editor.submissionReview.open')],
],
'groupId' => self::REVIEW_SETTINGS_GROUP,
]))
->addField(new FieldOptions('restrictReviewerFileAccess', [
'label' => __('manager.setup.reviewOptions.restrictReviewerFileAccess'),
'type' => 'checkbox',
'value' => $context->getData('restrictReviewerFileAccess'),
'options' => [
['value' => true, 'label' => __('manager.setup.reviewOptions.restrictReviewerFileAccess.description')],
]
],
'groupId' => self::REVIEW_SETTINGS_GROUP,
]))
->addField(new FieldOptions('reviewerAccessKeysEnabled', [
'label' => __('manager.setup.reviewOptions.reviewerAccessKeysEnabled'),
Expand All @@ -66,37 +89,89 @@ public function __construct($action, $locales, $context)
'value' => $context->getData('reviewerAccessKeysEnabled'),
'options' => [
['value' => true, 'label' => __('manager.setup.reviewOptions.reviewerAccessKeysEnabled.label')],
]
],
'groupId' => self::REVIEW_SETTINGS_GROUP,
]))
->addField(new FieldText('numWeeksPerResponse', [
'label' => __('manager.setup.reviewOptions.defaultReviewResponseTime'),
'description' => __('manager.setup.reviewOptions.numWeeksPerResponse'),
'value' => $context->getData('numWeeksPerResponse'),
'size' => 'small',
'groupId' => self::REVIEW_SETTINGS_GROUP,
]))
->addField(new FieldText('numWeeksPerReview', [
'label' => __('manager.setup.reviewOptions.defaultReviewCompletionTime'),
'description' => __('manager.setup.reviewOptions.numWeeksPerReview'),
'value' => $context->getData('numWeeksPerReview'),
'size' => 'small',
'groupId' => self::REVIEW_SETTINGS_GROUP,
]))
->addField(new FieldText('numReviewersPerSubmission', [
'label' => __('manager.setup.reviewOptions.numReviewersPerSubmission'),
'description' => __('manager.setup.reviewOptions.numReviewersPerSubmission.description'),
'value' => $context->getData('numReviewersPerSubmission'),
'size' => 'small',
'groupId' => self::REVIEW_SETTINGS_GROUP,
]));

return $this;
}

/**
* Add the review reminder control fields
*/
protected function addReminderFields(Context $context): static
{
$this
->addGroup([
'id' => self::REVIEW_REMINDER_GROUP,
])
->addField(new FieldHTML('reminderForReview', [
'label' => __('manager.setup.reviewOptions.reminders'),
'description' => __('manager.setup.reviewOptions.reminders.description'),
'groupId' => self::REVIEW_REMINDER_GROUP,
]))
->addField(new FieldText('numDaysBeforeInviteReminder', [
'label' => __('manager.setup.reviewOptions.reminders.response'),
'description' => __('manager.setup.reviewOptions.reminders.response.description'),
'value' => $context->getData('numDaysBeforeInviteReminder'),
'size' => 'small',
->addField(new FieldSlider('numDaysBeforeReviewResponseReminderDue', [
'label' => __('manager.setup.reviewOptions.reminders.response.before'),
'value' => $context->getData('numDaysBeforeReviewResponseReminderDue'),
'min' => static::MIN_REMINDER_NOTIFICATION_SEND_IN_DAYS,
'max' => static::MAX_REMINDER_NOTIFICATION_SEND_IN_DAYS,
'minLabel' => __('manager.setup.reviewOptions.reminders.min.label'),
'valueLabel' => __('manager.setup.reviewOptions.reminders.label.before.days'),
'valueLabelMin' => __('manager.setup.reviewOptions.reminders.disbale.label'),
'groupId' => self::REVIEW_REMINDER_GROUP,
]))
->addField(new FieldText('numDaysBeforeSubmitReminder', [
'label' => __('manager.setup.reviewOptions.reminders.submit'),
'description' => __('manager.setup.reviewOptions.reminders.submit.description'),
'value' => $context->getData('numDaysBeforeSubmitReminder'),
'size' => 'small',
->addField(new FieldSlider('numDaysAfterReviewResponseReminderDue', [
'label' => __('manager.setup.reviewOptions.reminders.response.after'),
'value' => $context->getData('numDaysAfterReviewResponseReminderDue'),
'min' => static::MIN_REMINDER_NOTIFICATION_SEND_IN_DAYS,
'max' => static::MAX_REMINDER_NOTIFICATION_SEND_IN_DAYS,
'minLabel' => __('manager.setup.reviewOptions.reminders.min.label'),
'valueLabel' => __('manager.setup.reviewOptions.reminders.label.after.days'),
'valueLabelMin' => __('manager.setup.reviewOptions.reminders.disbale.label'),
'groupId' => self::REVIEW_REMINDER_GROUP,
]))
->addField(new FieldSlider('numDaysBeforeReviewSubmitReminderDue', [
'label' => __('manager.setup.reviewOptions.reminders.submit.before'),
'value' => $context->getData('numDaysBeforeReviewSubmitReminderDue'),
'min' => static::MIN_REMINDER_NOTIFICATION_SEND_IN_DAYS,
'max' => static::MAX_REMINDER_NOTIFICATION_SEND_IN_DAYS,
'minLabel' => __('manager.setup.reviewOptions.reminders.min.label'),
'valueLabel' => __('manager.setup.reviewOptions.reminders.label.before.days'),
'valueLabelMin' => __('manager.setup.reviewOptions.reminders.disbale.label'),
'groupId' => self::REVIEW_REMINDER_GROUP,
]))
->addField(new FieldSlider('numDaysAfterReviewSubmitReminderDue', [
'label' => __('manager.setup.reviewOptions.reminders.submit.after'),
'value' => $context->getData('numDaysAfterReviewSubmitReminderDue'),
'min' => static::MIN_REMINDER_NOTIFICATION_SEND_IN_DAYS,
'max' => static::MAX_REMINDER_NOTIFICATION_SEND_IN_DAYS,
'minLabel' => __('manager.setup.reviewOptions.reminders.min.label'),
'valueLabel' => __('manager.setup.reviewOptions.reminders.label.after.days'),
'valueLabelMin' => __('manager.setup.reviewOptions.reminders.disbale.label'),
'groupId' => self::REVIEW_REMINDER_GROUP,
]));

return $this;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -409,15 +409,16 @@ public function updateReviewer($args, $request)
// Form handling
$reviewerForm = new $formClassName($this->getSubmission(), $this->getReviewRound());
$reviewerForm->readInputData();

if ($reviewerForm->validate()) {
$reviewAssignment = $reviewerForm->execute();
$json = DAO::getDataChangedEvent($reviewAssignment->getId());
$json->setGlobalEvent('update:decisions');
return $json;
} else {
// There was an error, redisplay the form
return new JSONMessage(true, $reviewerForm->fetch($request));
}

// There was an error, redisplay the form
return new JSONMessage(false);
}

/**
Expand Down
44 changes: 44 additions & 0 deletions classes/form/validation/FormValidatorDateCompare.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php

/**
* @file classes/form/validation/FormValidatorDateCompare.php
*
* Copyright (c) 2014-2024 Simon Fraser University
* Copyright (c) 2000-2024 John Willinsky
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
*
* @class FormValidatorDateCompare
*
* @ingroup form_validation
*
* @see FormValidator
*
* @brief Form validation to validation comparison rule for a date field
*/

namespace PKP\form\validation;

use PKP\form\Form;
use PKP\validation\ValidatorDateComparison;
use PKP\validation\enums\DateComparisonRule;
use Carbon\Carbon;
use DateTimeInterface;

class FormValidatorDateCompare extends FormValidator
{
/**
* Constructor.
*
* @param Form $form the associated form
* @param string $field the name of the associated field
* @param DateTimeInterface|Carbon $comparingDate the comparing date
* @param DateComparisonRule $comparingRule the comparing rule
* @param string $type the type of check, either "required" or "optional"
* @param string $message the error message for validation failures (i18n key)
*/
public function __construct(&$form, $field, $comparingDate, $comparingRule, $type = 'optional', $message = 'validator.date.comparison')
{
$validator = new ValidatorDateComparison($comparingDate, $comparingRule);
parent::__construct($form, $field, $type, $message, $validator);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ class UnableToCreateJATSContentException extends Exception
{
public function __construct(public ?Throwable $innerException = null)
{
parent::__construct(__('publication.jats.defaultContentCreationError'), null, $innerException);
parent::__construct(
__('publication.jats.defaultContentCreationError'),
$innerException?->getCode() ?? 0,
$innerException
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<?php

/**
* @file classes/migration/upgrade/v3_5_0/I5885_RenameReviewReminderSettingsName.php
*
* Copyright (c) 2014-2024 Simon Fraser University
* Copyright (c) 2000-2024 John Willinsky
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
*
* @class I5885_RenameReviewReminderSettingsName
*
* @brief Rename the review reminder settings name
*/

namespace PKP\migration\upgrade\v3_5_0;

use Illuminate\Support\Facades\DB;
use PKP\migration\Migration;

abstract class I5885_RenameReviewReminderSettingsName extends Migration
{
abstract protected function getContextSettingsTable(): string;

/**
* Run the migration.
*/
public function up(): void
{
DB::table($this->getContextSettingsTable())
->where('setting_name', 'numDaysBeforeInviteReminder')
->update([
'setting_name' => 'numDaysAfterReviewResponseReminderDue'
]);

DB::table($this->getContextSettingsTable())
->where('setting_name', 'numDaysBeforeSubmitReminder')
->update([
'setting_name' => 'numDaysAfterReviewSubmitReminderDue'
]);
}

/**
* Reverse the migration
*/
public function down(): void
{
DB::table($this->getContextSettingsTable())
->where('setting_name', 'numDaysAfterReviewResponseReminderDue')
->update([
'setting_name' => 'numDaysBeforeInviteReminder'
]);

DB::table($this->getContextSettingsTable())
->where('setting_name', 'numDaysAfterReviewSubmitReminderDue')
->update([
'setting_name' => 'numDaysBeforeSubmitReminder'
]);
}
}
Loading

0 comments on commit 41b38eb

Please sign in to comment.