Skip to content

Commit

Permalink
pkp#9453 Use the new Vue.js model
Browse files Browse the repository at this point in the history
  • Loading branch information
nibou230 authored and jardakotesovec committed Apr 29, 2024
1 parent cd3adf6 commit 2674745
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 267 deletions.
87 changes: 0 additions & 87 deletions controllers/review/linkAction/ReviewRoundModalLinkAction.php

This file was deleted.

85 changes: 17 additions & 68 deletions pages/reviewer/PKPReviewerHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand All @@ -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()
];
}
}

Expand All @@ -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
]
]);

Expand All @@ -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
Expand Down Expand Up @@ -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);
}
}
}
89 changes: 0 additions & 89 deletions templates/controllers/modals/reviewRound/reviewRound.tpl

This file was deleted.

21 changes: 0 additions & 21 deletions templates/reviewer/review/reviewRoundTab.tpl

This file was deleted.

2 changes: 0 additions & 2 deletions templates/reviewer/review/reviewStepHeader.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@
{rdelim});
</script>

{include file="reviewer/review/reviewRoundTab.tpl"}

<div id="reviewTabs" class="pkp_controllers_tab">
<ul>
<li><a href="{url op="step" path=$submission->getId() step=1}">{translate key="reviewer.reviewSteps.request"}</a></li>
Expand Down

0 comments on commit 2674745

Please sign in to comment.