diff --git a/api/v1/reviewers/recommendations/ReviewerRecommendationController.php b/api/v1/reviewers/recommendations/ReviewerRecommendationController.php
index ecd212ad3f1..c88a8f33852 100644
--- a/api/v1/reviewers/recommendations/ReviewerRecommendationController.php
+++ b/api/v1/reviewers/recommendations/ReviewerRecommendationController.php
@@ -9,18 +9,17 @@
*
* @class ReviewerRecommendationController
*
- * @brief
+ * @brief API controller class to handle actions on reviewer recommendations
*
*/
namespace PKP\API\v1\reviewers\recommendations;
use Illuminate\Http\JsonResponse;
-use PKP\API\v1\reviewers\recommendations\formRequests\UpdateStatusReviewerRecommendation;
-
use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Illuminate\Support\Facades\Route;
+use PKP\API\v1\reviewers\recommendations\formRequests\UpdateStatusReviewerRecommendation;
use PKP\API\v1\reviewers\recommendations\resources\ReviewerRecommendationResource;
use PKP\submission\reviewer\recommendation\ReviewerRecommendation;
use PKP\API\v1\reviewers\recommendations\formRequests\AddReviewerRecommendation;
@@ -98,6 +97,9 @@ public function getGroupRoutes(): void
->whereNumber(['contextId', 'recommendationId']);
}
+ /**
+ * Get specific recommendation response
+ */
public function get(Request $illuminateRequest): JsonResponse
{
$recommendation = ReviewerRecommendation::find($illuminateRequest->route('recommendationId'));
@@ -114,6 +116,9 @@ public function get(Request $illuminateRequest): JsonResponse
);
}
+ /**
+ * Get all recommendations response
+ */
public function getMany(Request $illuminateRequest): JsonResponse
{
$recommendations = ReviewerRecommendation::query()
@@ -126,6 +131,9 @@ public function getMany(Request $illuminateRequest): JsonResponse
], Response::HTTP_OK);
}
+ /**
+ * Add new recommendation
+ */
public function add(AddReviewerRecommendation $illuminateRequest): JsonResponse
{
$validateds = $illuminateRequest->validated();
@@ -139,12 +147,21 @@ public function add(AddReviewerRecommendation $illuminateRequest): JsonResponse
);
}
+ /**
+ * Update existing recommendation
+ */
public function edit(EditReviewerRecommendation $illuminateRequest): JsonResponse
{
$validated = $illuminateRequest->validated();
$recommendation = ReviewerRecommendation::find($illuminateRequest->route('recommendationId'));
+ if (!$recommendation->removable) {
+ return response()->json([
+ 'error' => __('api.406.notAcceptable'),
+ ], Response::HTTP_NOT_ACCEPTABLE);
+ }
+
if (!$recommendation->update($validated)) {
return response()->json([
'error' => __('api.409.resourceActionConflict'),
@@ -158,11 +175,27 @@ public function edit(EditReviewerRecommendation $illuminateRequest): JsonRespons
);
}
+ /**
+ * Update the status of existing recommendation
+ */
public function updateStatus(UpdateStatusReviewerRecommendation $illuminateRequest): JsonResponse
{
- return $this->edit($illuminateRequest);
+ $validated = $illuminateRequest->validated();
+
+ $recommendation = ReviewerRecommendation::find($illuminateRequest->route('recommendationId'));
+
+ $recommendation->update($validated);
+
+ return response()->json(
+ (new ReviewerRecommendationResource($recommendation->refresh()))
+ ->toArray($illuminateRequest),
+ Response::HTTP_OK
+ );
}
+ /**
+ * Delete existing recommendation
+ */
public function delete(Request $illuminateRequest): JsonResponse
{
$recommendation = ReviewerRecommendation::find($illuminateRequest->route('recommendationId'));
diff --git a/api/v1/reviewers/recommendations/formRequests/AddReviewerRecommendation.php b/api/v1/reviewers/recommendations/formRequests/AddReviewerRecommendation.php
index f2beac9fcf5..5a26bd5e471 100644
--- a/api/v1/reviewers/recommendations/formRequests/AddReviewerRecommendation.php
+++ b/api/v1/reviewers/recommendations/formRequests/AddReviewerRecommendation.php
@@ -10,7 +10,7 @@
*
* @class AddReviewerRecommendation
*
- * @brief
+ * @brief Form request class to validation storing of resource
*
*/
diff --git a/api/v1/reviewers/recommendations/formRequests/EditReviewerRecommendation.php b/api/v1/reviewers/recommendations/formRequests/EditReviewerRecommendation.php
index f8dd39313b2..5fa7846840c 100644
--- a/api/v1/reviewers/recommendations/formRequests/EditReviewerRecommendation.php
+++ b/api/v1/reviewers/recommendations/formRequests/EditReviewerRecommendation.php
@@ -10,7 +10,7 @@
*
* @class EditReviewerRecommendation
*
- * @brief
+ * @brief Form request class to validation updating of resource
*
*/
diff --git a/api/v1/reviewers/recommendations/formRequests/UpdateStatusReviewerRecommendation.php b/api/v1/reviewers/recommendations/formRequests/UpdateStatusReviewerRecommendation.php
index 358c330a331..b0c630eec2e 100644
--- a/api/v1/reviewers/recommendations/formRequests/UpdateStatusReviewerRecommendation.php
+++ b/api/v1/reviewers/recommendations/formRequests/UpdateStatusReviewerRecommendation.php
@@ -9,7 +9,7 @@
*
* @class UpdateStatusReviewerRecommendation
*
- * @brief
+ * @brief Form request class to validation updating of resource status
*
*/
diff --git a/api/v1/reviewers/recommendations/resources/ReviewerRecommendationResource.php b/api/v1/reviewers/recommendations/resources/ReviewerRecommendationResource.php
index ed630eda26f..8a67c1e704c 100644
--- a/api/v1/reviewers/recommendations/resources/ReviewerRecommendationResource.php
+++ b/api/v1/reviewers/recommendations/resources/ReviewerRecommendationResource.php
@@ -9,7 +9,7 @@
*
* @class ReviewerRecommendationResource
*
- * @brief
+ * @brief API resource class
*
*/
diff --git a/classes/components/forms/context/ReviewerRecommendationForm.php b/classes/components/forms/context/ReviewerRecommendationForm.php
index a5449fc4c70..c5e394459ee 100644
--- a/classes/components/forms/context/ReviewerRecommendationForm.php
+++ b/classes/components/forms/context/ReviewerRecommendationForm.php
@@ -8,7 +8,7 @@
*
* @class ReviewerRecommendationForm
*
- * @brief
+ * @brief Form to configure/add/edit reviewer recommendation
*/
namespace PKP\components\forms\context;
diff --git a/classes/components/listPanels/ReviewerRecommendationsListPanel.php b/classes/components/listPanels/ReviewerRecommendationsListPanel.php
index b586930ccbb..a4a0b80f751 100644
--- a/classes/components/listPanels/ReviewerRecommendationsListPanel.php
+++ b/classes/components/listPanels/ReviewerRecommendationsListPanel.php
@@ -8,7 +8,7 @@
*
* @class ReviewerRecommendationsListPanel
*
- * @brief
+ * @brief A ListPanel component for displaying reviewer recommendations in workflow settings
*/
namespace PKP\components\listPanels;
diff --git a/classes/migration/install/ReviewerRecommendationsMigration.php b/classes/migration/install/ReviewerRecommendationsMigration.php
index 8befefc42af..f4d897839f5 100644
--- a/classes/migration/install/ReviewerRecommendationsMigration.php
+++ b/classes/migration/install/ReviewerRecommendationsMigration.php
@@ -9,7 +9,7 @@
*
* @class ReviewerRecommendationsMigration
*
- * @brief
+ * @brief Describe database table structures .
*/
namespace PKP\migration\install;
@@ -19,10 +19,19 @@
abstract class ReviewerRecommendationsMigration extends \PKP\migration\Migration
{
+ /**
+ * Get the context table name
+ */
abstract public function contextTable(): string;
+ /**
+ * Get the context settings table name
+ */
abstract public function settingTable(): string;
+ /**
+ * Get the context primary key name
+ */
abstract public function contextPrimaryKey(): string;
/**
diff --git a/classes/migration/upgrade/v3_6_0/I1660_ReviewerRecommendations.php b/classes/migration/upgrade/v3_6_0/I1660_ReviewerRecommendations.php
index fa34197ef6c..6c7fe1826a7 100644
--- a/classes/migration/upgrade/v3_6_0/I1660_ReviewerRecommendations.php
+++ b/classes/migration/upgrade/v3_6_0/I1660_ReviewerRecommendations.php
@@ -9,7 +9,7 @@
*
* @class I1660_ReviewerRecommendations
*
- * @brief
+ * @brief Upgrade migration add recommendations
*/
namespace PKP\migration\upgrade\v3_6_0;
@@ -23,8 +23,6 @@
abstract class I1660_ReviewerRecommendations extends \PKP\migration\Migration
{
- abstract protected function systemDefineNonRemovableRecommendations(): array;
-
protected ReviewerRecommendationsMigration $recommendationInstallMigration;
/**
@@ -39,6 +37,11 @@ public function __construct(Installer $installer, array $attributes)
parent::__construct($installer, $attributes);
}
+
+ /**
+ * Get the pre-seeded reviewer recommendations to add on migration update
+ */
+ abstract protected function systemDefineNonRemovableRecommendations(): array;
/**
* Run the migration.
@@ -58,14 +61,15 @@ public function down(): void
$this->recommendationInstallMigration->down();
}
- // TODO : Optimize the process if possible
+ /**
+ * Seed the existing recommendations with context mapping on upgrade
+ */
protected function seedNonRemovableRecommendations(array $nonRemovablerecommendations): void
{
if (empty($nonRemovablerecommendations)) {
return;
}
- // $currentLocale = Locale::getLocale();
$contextSupportedLocales = DB::table($this->recommendationInstallMigration->contextTable())
->select($this->recommendationInstallMigration->contextPrimaryKey())
->addSelect([
@@ -107,9 +111,6 @@ protected function seedNonRemovableRecommendations(array $nonRemovablerecommenda
DB::beginTransaction();
foreach ($allContextSupportLocales as $locale) {
-
- // Locale::setLocale($locale);
-
foreach ($nonRemovablerecommendations as $recommendationValue => $translatableKey) {
$recommendations[$recommendationValue]['title'][$locale] = Locale::get(
$translatableKey,
@@ -118,8 +119,6 @@ protected function seedNonRemovableRecommendations(array $nonRemovablerecommenda
);
}
}
-
- // Locale::setLocale($currentLocale);
$contextSupportedLocales->each(
fn (array $supportedLocales, int $contextId) => collect($recommendations)->each(
@@ -143,7 +142,7 @@ protected function seedNonRemovableRecommendations(array $nonRemovablerecommenda
} catch (Throwable $exception) {
DB::rollBack();
- // Locale::setLocale($currentLocale);
+
ReviewerRecommendation::reguard();
throw $exception;
diff --git a/classes/submission/reviewer/recommendation/ReviewerRecommendation.php b/classes/submission/reviewer/recommendation/ReviewerRecommendation.php
index 21a737fedbe..7f7dbab93ad 100644
--- a/classes/submission/reviewer/recommendation/ReviewerRecommendation.php
+++ b/classes/submission/reviewer/recommendation/ReviewerRecommendation.php
@@ -1,5 +1,17 @@
shouldCache();
}
+ /**
+ * Get associated review assignments details as attribute
+ */
protected function reviewAssignments(): Attribute
{
return Attribute::make(
@@ -172,18 +193,24 @@ protected function reviewAssignments(): Attribute
}
/**
- *
+ * Scope a query to filter by context id.
*/
public function scopeWithContextId(Builder $query, int $contextId): Builder
{
return $query->where('context_id', $contextId);
}
+ /**
+ * Scope a query to filter by recommendation active status.
+ */
public function scopeWithActive(Builder $query, bool $active = true): Builder
{
return $query->where('status', $active);
}
+ /**
+ * Scope a query to filter by recommendation value
+ */
public function scopeWithRecommendation(Builder $query, int $recommendation): Builder
{
return $query->where('value', $recommendation);
diff --git a/locale/en/manager.po b/locale/en/manager.po
index b6e24393bbf..28cdd6ebddc 100644
--- a/locale/en/manager.po
+++ b/locale/en/manager.po
@@ -1988,13 +1988,13 @@ msgid "manager.reviewerRecommendations.confirmDelete"
msgstr "Are you sure you want to delete the recommendation {$title}"
msgid "manager.reviewerRecommendations.confirmActivate"
-msgstr "Are you sure you want to activate the recommendation {$title}"
+msgstr "Are you sure you want to activate the recommendation {$title}"
msgid "manager.reviewerRecommendations.activate.title"
msgstr "Activate Reviewer Recommendation"
msgid "manager.reviewerRecommendations.confirmDeactivate"
-msgstr "Are you sure you want to deactivate the recommendation {$title}"
+msgstr "Are you sure you want to deactivate the recommendation {$title}"
msgid "manager.reviewerRecommendations.deactivate.title"
msgstr "Deactivate Reviewer Recommendation"