From b4f4e518c6b44c9c04ede9937a61cbb28de82c37 Mon Sep 17 00:00:00 2001 From: Nicolas Boulay Date: Wed, 17 Jan 2024 16:46:12 -0500 Subject: [PATCH] pkp/pkp-lib#9453 Use the new Vue.js model --- .../linkAction/ReviewRoundModalLinkAction.php | 87 ------------------ pages/reviewer/PKPReviewerHandler.php | 85 ++++-------------- .../modals/reviewRound/reviewRound.tpl | 89 ------------------- templates/reviewer/review/reviewRoundTab.tpl | 21 ----- .../reviewer/review/reviewStepHeader.tpl | 2 - 5 files changed, 17 insertions(+), 267 deletions(-) delete mode 100644 controllers/review/linkAction/ReviewRoundModalLinkAction.php delete mode 100644 templates/controllers/modals/reviewRound/reviewRound.tpl delete mode 100644 templates/reviewer/review/reviewRoundTab.tpl diff --git a/controllers/review/linkAction/ReviewRoundModalLinkAction.php b/controllers/review/linkAction/ReviewRoundModalLinkAction.php deleted file mode 100644 index a956b6adc5e..00000000000 --- a/controllers/review/linkAction/ReviewRoundModalLinkAction.php +++ /dev/null @@ -1,87 +0,0 @@ -_round = $reviewRoundNumber; - - $submission = Repo::submission()->get($submissionId); - $submissionTitle = $submission->getCurrentPublication()->getLocalizedTitle(); - $router = $request->getRouter(); - $actionArgs = [ - 'submissionId' => $submissionId, - 'reviewRoundId' => $reviewRoundId, - 'reviewRoundNumber' => $reviewRoundNumber - ]; - - $ajaxModal = new AjaxModal( - $router->getDispatcher()->url( - $request, - PKPApplication::ROUTE_COMPONENT, - null, - 'review.ReviewRoundModalHandler', - 'viewRoundInfo', - null, - $actionArgs - ), - __( - 'reviewer.submission.reviewRound.info.modal.title', - [ - 'reviewRoundNumber' => $reviewRoundNumber, - 'submissionTitle' => $submissionTitle - ] - ), - 'modal_information' - ); - - // Configure the link action. - parent::__construct('viewRoundInfo', $ajaxModal); - } - - /** - * Get the review round number. - * - * @return int - */ - function getRound(): int - { - return $this->_round; - } -} diff --git a/pages/reviewer/PKPReviewerHandler.php b/pages/reviewer/PKPReviewerHandler.php index 3e5cc1e7bfa..b5229893983 100644 --- a/pages/reviewer/PKPReviewerHandler.php +++ b/pages/reviewer/PKPReviewerHandler.php @@ -24,14 +24,12 @@ use Exception; use Illuminate\Support\Facades\Mail; use PKP\config\Config; -use PKP\controllers\review\linkAction\ReviewRoundModalLinkAction; use PKP\core\JSONMessage; use PKP\core\PKPApplication; use PKP\core\PKPRequest; use PKP\db\DAORegistry; use PKP\facades\Locale; use PKP\notification\PKPNotification; -use PKP\security\Role; use PKP\submission\reviewAssignment\ReviewAssignment; use PKP\submission\reviewer\form\PKPReviewerReviewStep3Form; use PKP\submission\reviewer\form\ReviewerReviewForm; @@ -50,9 +48,7 @@ public function submission(array $args, PKPRequest $request): void { $reviewAssignment = $this->getAuthorizedContextObject(PKPApplication::ASSOC_TYPE_REVIEW_ASSIGNMENT); /** @var ReviewAssignment $reviewAssignment */ $reviewSubmission = Repo::submission()->get($reviewAssignment->getSubmissionId()); - $reviewSubmissionId = $reviewSubmission->getId(); - $this->insertNewStageAssignmentIfEmpty($request, $reviewSubmissionId); $this->setupTemplate($request); $templateMgr = TemplateManager::getManager($request); @@ -67,28 +63,23 @@ public function submission(array $args, PKPRequest $request): void } $reviewRoundDao = DAORegistry::getDAO('ReviewRoundDAO'); - $reviewRounds = $reviewRoundDao->getBySubmissionId($reviewSubmissionId)->toArray(); - $reviewerId = $reviewAssignment->getReviewerId(); - $reviewRoundsWhereReviewerAssigned = []; - foreach ($reviewRounds as $reviewRound) { - $reviewAssignment = Repo::reviewAssignment()->getCollector() - ->filterByReviewRoundIds([$reviewRound->getId()]) - ->filterByReviewerIds([$reviewerId]) - ->filterByContextIds([$request->getContext()->getId()]) - ->getMany() - ->first(); - if (!is_null($reviewAssignment)) { - $reviewRoundsWhereReviewerAssigned[$reviewRound->getRound()] = $reviewRound; - } - } - - $lastReviewRound = $reviewRoundDao->getLastReviewRoundBySubmissionId($reviewSubmissionId); - $lastReviewRoundNumber = $lastReviewRound->getRound(); + $submissionId = $reviewSubmission->getId(); + $lastRoundId = $reviewRoundDao->getLastReviewRoundBySubmissionId($submissionId)->getId(); + $reviewAssignments = Repo::reviewAssignment()->getCollector() + ->filterByContextIds([$request->getContext()->getId()]) + ->filterBySubmissionIds([$submissionId]) + ->filterByReviewerIds([$reviewAssignment->getReviewerId()]) + ->getMany() + ->toArray(); $reviewRoundHistories = []; - foreach ($reviewRoundsWhereReviewerAssigned as $reviewRound) { - $round = $reviewRound->getRound(); - if ($round != $lastReviewRoundNumber) { - $reviewRoundHistories[$round - 1] = new ReviewRoundModalLinkAction($request, $reviewSubmissionId, $reviewRound->getId(), $round); + foreach ($reviewAssignments as $reviewAssignment) { + $reviewRoundId = $reviewAssignment->getReviewRoundId(); + if ($reviewRoundId != $lastRoundId) { + $reviewRoundHistories[] = [ + 'submissionId' => $submissionId, + 'reviewRoundId' => $reviewRoundId, + 'reviewRoundNumber' => $reviewAssignment->getRound() + ]; } } @@ -97,26 +88,12 @@ public function submission(array $args, PKPRequest $request): void 'reviewStep' => $reviewStep, 'selected' => $step - 1, 'submission' => $reviewSubmission, - 'reviewRoundHistories' => $reviewRoundHistories, ]); $templateMgr->setState([ 'isReviewRoundHistoryEnabled' => Config::getVar('features', 'enable_review_round_history'), 'pageInitConfig' => [ - 'reviewRoundHistories' => [ - [ - 'submissionId' => $reviewSubmission->getId(), - // Just as example, not real data - 'reviewRoundId' => 0, - 'reviewRoundNumber' => 1 - ], - [ - 'submissionId' => $reviewSubmission->getId(), - // Just as example, not real data - 'reviewRoundId' => 1, - 'reviewRoundNumber' => 2 - ] - ] + 'reviewRoundHistories' => $reviewRoundHistories ] ]); @@ -134,9 +111,7 @@ public function step(array $args, PKPRequest $request): JSONMessage assert(!empty($reviewId)); $reviewSubmission = Repo::submission()->get($reviewAssignment->getSubmissionId()); - $reviewSubmissionId = $reviewSubmission->getId(); - $this->insertNewStageAssignmentIfEmpty($request, $reviewSubmissionId); $this->setupTemplate($request); $reviewStep = max($reviewAssignment->getStep(), 1); // Get the current saved step from the DB @@ -283,30 +258,4 @@ public function _retrieveStep(): int assert(!empty($reviewId)); return $reviewId; } - - /** - * Insert a new stage assignment object if it doesn't already exist. - * - * @param PKPRequest $request - * @param int $reviewSubmissionId - * - * @throws Exception - */ - private function insertNewStageAssignmentIfEmpty(PKPRequest $request, int $reviewSubmissionId): void - { - $reviewerUserGroups = Repo::userGroup() - ->getByRoleIds([Role::ROLE_ID_REVIEWER], $request->getContext()->getId(), true) - ->first(); - $reviewerUserGroupsId = $reviewerUserGroups->getId(); - $userId = $request->getUser()->getId(); - $stageAssignmentDao = DAORegistry::getDAO('StageAssignmentDAO'); - $result = $stageAssignmentDao->getBySubmissionAndStageId($reviewSubmissionId, null, $reviewerUserGroupsId, $userId); - if (count($result->toArray()) === 0) { - $stageAssignment = $stageAssignmentDao->newDataObject(); - $stageAssignment->setSubmissionId($reviewSubmissionId); - $stageAssignment->setUserId($userId); - $stageAssignment->setUserGroupId($reviewerUserGroupsId); - $stageAssignmentDao->insertObject($stageAssignment); - } - } } diff --git a/templates/controllers/modals/reviewRound/reviewRound.tpl b/templates/controllers/modals/reviewRound/reviewRound.tpl deleted file mode 100644 index 2d884c39bb7..00000000000 --- a/templates/controllers/modals/reviewRound/reviewRound.tpl +++ /dev/null @@ -1,89 +0,0 @@ -{** - * templates/controllers/modals/reviewRound/reviewRound.tpl - * - * Copyright (c) 2014-2021 Simon Fraser University - * Copyright (c) 2003-2021 John Willinsky - * Copyright (c) 2021 Université Laval - * Distributed under the GNU GPL v3. For full terms see the file docs/COPYING. - * - * Display reviewer review round info modal. - *} - - - -
- -
- {if $reviewAssignment->getDeclined() == false} -

{translate key="reviewer.article.recommendation"}:

-
-

{$reviewAssignment->getLocalizedRecommendation()}

-
- - {if !$reviewComments->wasEmpty()} -

{translate key="reviewer.submission.comments.review"}:

- {iterate from=reviewComments item=reviewComment} -
- {if $reviewComment->getViewable() == 1} - {translate key="reviewer.submission.comments.authorAndEditor"}: - {else} - {translate key="reviewer.submission.comments.editorOnly"}: - {/if} - {$reviewComment->getComments()} -
- {/iterate} - {/if} - - {if $displayFilesGrid} - {capture assign="reviewAttachmentsModalUrl"}{url router=$smarty.const.ROUTE_COMPONENT component="grid.files.attachment.ReviewerReviewAttachmentsGridHandler" op="fetchGrid" assocType=$smarty.const.ASSOC_TYPE_REVIEW_ASSIGNMENT assocId=$reviewAssignment->getId() submissionId=$submission->getId() stageId=$reviewAssignment->getStageId() reviewIsClosed=true escape=false}{/capture} - {load_url_in_div id="reviewAttachmentsModal" url=$reviewAttachmentsModalUrl} - {/if} - -
-

{translate key="reviewer.submission.reviewRequestDate"}: {$reviewAssignment->getDateNotified()|date_format:$dateFormatShort}

-

{translate key="reviewer.submission.responseDueDate"}: {$reviewAssignment->getDateResponseDue()|date_format:$dateFormatShort}

-

{translate key="reviewer.submission.reviewDueDate"}: {$reviewAssignment->getDateDue()|date_format:$dateFormatShort}

-

{translate key="common.dateCompleted"}: {$reviewAssignment->getDateCompleted()|date_format:$dateFormatShort}

-
- - {if $displayFilesGrid} - {capture assign="reviewFilesModalUrl"}{url router=$smarty.const.ROUTE_COMPONENT component="grid.files.review.ReviewerReviewFilesGridHandler" op="fetchGrid" submissionId=$submission->getId() stageId=$reviewAssignment->getStageId() reviewRoundId=$reviewRoundId reviewAssignmentId=$reviewAssignment->getId() escape=false}{/capture} - {load_url_in_div id="reviewFilesModal" url=$reviewFilesModalUrl} - {/if} - {else} -

{translate key="reviewer.submission.reviewDeclineDate"}:

-
-

{$reviewAssignment->getDateConfirmed()|date_format:$dateFormatShort}

-
-

{translate key="reviewer.submission.emailLog"}:

- {if isset($declineEmail)} -
-

{$declineEmail->getSubject()}
- {$declineEmail->getBody()} -

-
- {else} -

{translate key="reviewer.submission.emailLog.defaultMessage"}

- {/if} - {/if} -
-
- {fbvFormSection class="formButtons form_buttons"} - {assign var=cancelButtonId value="cancelFormButton"|concat:"-"|uniqid} - {translate key="common.ok"} - - {/fbvFormSection} -
-
diff --git a/templates/reviewer/review/reviewRoundTab.tpl b/templates/reviewer/review/reviewRoundTab.tpl deleted file mode 100644 index a5d3d08b26f..00000000000 --- a/templates/reviewer/review/reviewRoundTab.tpl +++ /dev/null @@ -1,21 +0,0 @@ -{** - * templates/reviewer/review/reviewRoundTab.tpl - * - * Copyright (c) 2014-2021 Simon Fraser University - * Copyright (c) 2003-2021 John Willinsky - * Copyright (c) 2021 Université Laval - * Distributed under the GNU GPL v3. For full terms see the file docs/COPYING. - * - * Build reviewer review round info buttons - *} - -{if $reviewRoundHistories|@count > 0} -
- {translate key="reviewer.submission.reviewRound.info"}  - {foreach from=$reviewRoundHistories item=reviewRoundHistory key=key} - {assign var=resumeButtonId value="resumeButton"|concat:"-"|uniqid} - {include file="linkAction/buttonGenericLinkAction.tpl" buttonSelector="#"|concat:$resumeButtonId action=$reviewRoundHistory} - {translate key="submission.round" round=$reviewRoundHistory->getRound()} - {/foreach} -
-{/if} diff --git a/templates/reviewer/review/reviewStepHeader.tpl b/templates/reviewer/review/reviewStepHeader.tpl index bdb00c120bc..116b44858bf 100644 --- a/templates/reviewer/review/reviewStepHeader.tpl +++ b/templates/reviewer/review/reviewStepHeader.tpl @@ -30,8 +30,6 @@ {rdelim}); - {include file="reviewer/review/reviewRoundTab.tpl"} -