Skip to content

Commit

Permalink
pkp#4789 Due date fields added for declined review request resending
Browse files Browse the repository at this point in the history
  • Loading branch information
touhidurabir committed Sep 20, 2024
1 parent 5f0413d commit c2792b2
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 15 deletions.
42 changes: 38 additions & 4 deletions controllers/grid/users/reviewer/form/ResendRequestReviewerForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
/**
* @file controllers/grid/users/reviewer/form/ResendRequestReviewerForm.php
*
* Copyright (c) 2014-2022 Simon Fraser University
* Copyright (c) 2003-2022 John Willinsky
* Copyright (c) 2014-2024 Simon Fraser University
* Copyright (c) 2003-2024 John Willinsky
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
*
* @class ResendRequestReviewerForm
Expand Down Expand Up @@ -35,7 +35,6 @@ class ResendRequestReviewerForm extends ReviewerNotifyActionForm
{
/**
* Constructor
*
*/
public function __construct(ReviewAssignment $reviewAssignment, ReviewRound $reviewRound, Submission $submission)
{
Expand All @@ -45,21 +44,54 @@ public function __construct(ReviewAssignment $reviewAssignment, ReviewRound $rev
$submission,
'controllers/grid/users/reviewer/form/resendRequestReviewerForm.tpl'
);

// Validation checks for this form
$this->addCheck(new \PKP\form\validation\FormValidator($this, 'responseDueDate', 'required', 'editor.review.errorAddingReviewer'));
$this->addCheck(new \PKP\form\validation\FormValidator($this, 'reviewDueDate', 'required', 'editor.review.errorAddingReviewer'));
}

/**
* @copydoc \PKP\controllers\grid\users\reviewer\form\ReviewerNotifyActionForm::getMailable()
*/
protected function getMailable(Context $context, Submission $submission, ReviewAssignment $reviewAssignment): Mailable
{
return new ReviewerResendRequest($context, $submission, $reviewAssignment);
}

/**
* @copydoc ReviewerNotifyActionForm::getEmailKey()
* @copydoc \PKP\controllers\grid\users\reviewer\form\ReviewerNotifyActionForm::getEmailKey()
*/
protected function getEmailKey()
{
return 'REVIEW_RESEND_REQUEST';
}

/**
* @copydoc \PKP\controllers\grid\users\reviewer\form\ReviewerNotifyActionForm::initData()
*/
public function initData()
{
parent::initData();

[$reviewDueDate, $responseDueDate] = ReviewerForm::getDueDates(Application::get()->getRequest()->getContext());

$this->setData('responseDueDate', $responseDueDate);
$this->setData('reviewDueDate', $reviewDueDate);
}

/**
* @copydoc \PKP\controllers\grid\users\reviewer\form\ReviewerNotifyActionForm::readInputData()
*/
public function readInputData()
{
parent::readInputData();

$this->readUserVars([
'responseDueDate',
'reviewDueDate',
]);
}

/**
* @copydoc Form::execute()
*
Expand All @@ -84,6 +116,8 @@ public function execute(...$functionArgs)
'declined' => false,
'requestResent' => true,
'dateConfirmed' => null,
'dateDue' => $this->getData('reviewDueDate'), // Set the review due date
'dateResponseDue' => $this->getData('responseDueDate'), // Set the response due date
]);

// Stamp the modification date
Expand Down
32 changes: 21 additions & 11 deletions controllers/grid/users/reviewer/form/ReviewerForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,26 @@ public function __construct($submission, $reviewRound)
$this->addCheck(new \PKP\form\validation\FormValidatorCSRF($this));
}

/**
* Get the review submit and response due dates
*/
public static function getDueDates(Context $context): array
{
$numWeeks = (int) $context->getData('numWeeksPerReview');
if ($numWeeks <= 0) {
$numWeeks = 4;
}
$reviewDueDate = strtotime('+' . $numWeeks . ' week');

$numWeeks = (int) $context->getData('numWeeksPerResponse');
if ($numWeeks <= 0) {
$numWeeks = 3;
}
$responseDueDate = strtotime('+' . $numWeeks . ' week');

return [$reviewDueDate, $responseDueDate];
}

//
// Getters and Setters
//
Expand Down Expand Up @@ -211,17 +231,7 @@ public function initData()
$reviewFormId = null;
}

$numWeeks = (int) $context->getData('numWeeksPerReview');
if ($numWeeks <= 0) {
$numWeeks = 4;
}
$reviewDueDate = strtotime('+' . $numWeeks . ' week');

$numWeeks = (int) $context->getData('numWeeksPerResponse');
if ($numWeeks <= 0) {
$numWeeks = 3;
}
$responseDueDate = strtotime('+' . $numWeeks . ' week');
[$reviewDueDate, $responseDueDate] = static::getDueDates($context);

// Get the currently selected reviewer selection type to show the correct tab if we're re-displaying the form
$selectionType = (int) $request->getUserVar('selectionType');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@
{fbvElement type="checkbox" id="skipEmail" name="skipEmail" label="editor.review.skipEmail"}
{/fbvFormSection}

{fbvFormSection title="editor.review.importantDates"}
{fbvElement type="text" id="responseDueDate" name="responseDueDate" label="submission.task.responseDueDate" value=$responseDueDate inline=true size=$fbvStyles.size.MEDIUM class="datepicker"}
{fbvElement type="text" id="reviewDueDate" name="reviewDueDate" label="editor.review.reviewDueDate" value=$reviewDueDate inline=true size=$fbvStyles.size.MEDIUM class="datepicker"}
{/fbvFormSection}

{fbvFormButtons submitText="editor.review.resendRequestReviewer"}
</form>

0 comments on commit c2792b2

Please sign in to comment.