Skip to content

pkp/pkp-lib#10404 Allow arbitrary nesting depth in categories #1949

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
May 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions api/v1/categories/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

/**
* @defgroup api_v1_categories Categories API requests
*/

/**
* @file api/v1/categories/index.php
*
* Copyright (c) 2025 Simon Fraser University
* Copyright (c) 2025 John Willinsky
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
*
* @ingroup api_v1_categories
*
* @brief Handle API requests for categories.
*/

return new \PKP\handler\APIHandler(new \PKP\API\v1\categories\CategoryCategoryController());
18 changes: 9 additions & 9 deletions classes/components/forms/publication/CatalogEntryForm.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* @file classes/components/form/publication/CatalogEntryForm.php
*
Expand Down Expand Up @@ -82,23 +83,22 @@ public function __construct($action, $locales, $publication, $submission, $baseU
$categoryOptions = [];
$categories = Repo::category()->getCollector()
->filterByContextIds([$submission->getData('contextId')])
->getMany()
->toArray();
->getMany();

foreach ($categories as $category) {
$label = $category->getLocalizedTitle();
if ($category->getParentId()) {
$label = $categories[$category->getParentId()]->getLocalizedTitle() . ' > ' . $label;
}
$categoriesBreadcrumb = Repo::category()->getBreadcrumbs($categories);
foreach ($categoriesBreadcrumb as $categoryId => $breadcrumb) {
$categoryOptions[] = [
'value' => (int) $category->getId(),
'label' => $label,
'value' => $categoryId,
'label' => $breadcrumb,
];
}

$hasAllBreadcrumbs = count($categories) === $categoriesBreadcrumb->count();
if (!empty($categoryOptions)) {
$this->addField(new FieldOptions('categoryIds', [
'label' => __('submission.submit.placement.categories'),
'value' => (array) $publication->getData('categoryIds'),
'description' => $hasAllBreadcrumbs ? '' : __('submission.categories.circularReferenceWarning'),
'options' => $categoryOptions,
]));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

/**
* @file classes/migration/upgrade/v3_6_0/I10404_UpdateCategoryImageNameFields.php
*
* Copyright (c) 2025 Simon Fraser University
* Copyright (c) 2025 John Willinsky
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
*
* @class I10404_UpdateCategoryImageNameFields
*
* @brief Migration to update Category image data properties for compatibility with FieldUploadImage component
*/

namespace APP\migration\upgrade\v3_6_0;

class I10404_UpdateCategoryImageNameFields extends \PKP\migration\upgrade\v3_6_0\I10404_UpdateCategoryImageNameFields
{
public function getContextFolderName(): string
{
return 'presses';
}

protected function getContextTable(): string
{
return 'presses';
}

protected function getContextIdColumn(): string
{
return 'press_id';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
*/

describe('Data suite tests', function() {
it('Creates/configures categories', function() {
it.skip('Creates/configures categories', function() {
cy.login('admin', 'admin');
cy.get('a').contains('admin').click();
cy.get('a').contains('Dashboard').click();
Expand Down
1 change: 1 addition & 0 deletions dbscripts/xml/upgrade.xml
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@
<migration class="PKP\migration\upgrade\v3_6_0\I10403_EmailTemplateUserGroupAccess"/>
<migration class="APP\migration\install\ReviewerRecommendationsMigration" />
<migration class="APP\migration\upgrade\v3_6_0\I1660_ReviewerRecommendations"/>
<migration class="APP\migration\upgrade\v3_6_0\I10404_UpdateCategoryImageNameFields"/>
</upgrade>

<upgrade minversion="3.1.0.0" maxversion="3.5.9.9">
Expand Down
2 changes: 1 addition & 1 deletion lib/pkp
Submodule pkp updated 31 files
+1 −0 .github/ISSUE_TEMPLATE/1-bug.yml
+321 −0 api/v1/categories/CategoryCategoryController.php
+2 −3 api/v1/reviews/PKPReviewController.php
+1 −2 api/v1/submissions/PKPSubmissionController.php
+4 −16 classes/category/Category.php
+38 −11 classes/category/Collector.php
+175 −28 classes/category/Repository.php
+57 −1 classes/category/maps/Schema.php
+169 −0 classes/components/forms/context/CategoryForm.php
+5 −3 classes/components/forms/dashboard/PKPSubmissionFilters.php
+5 −4 classes/components/forms/submission/ForTheEditors.php
+1 −1 classes/file/PKPPublicFileManager.php
+0 −1 classes/migration/install/CategoriesMigration.php
+143 −0 classes/migration/upgrade/v3_6_0/I10404_UpdateCategoryImageNameFields.php
+1 −2 classes/submission/Repository.php
+1 −2 classes/submission/maps/Schema.php
+19 −19 classes/submission/reviewAssignment/Collector.php
+0 −345 controllers/grid/settings/category/CategoryCategoryGridHandler.php
+0 −88 controllers/grid/settings/category/CategoryGridCategoryRow.php
+0 −75 controllers/grid/settings/category/CategoryGridRow.php
+0 −426 controllers/grid/settings/category/form/CategoryForm.php
+4 −4 cypress/tests/integration/Categories.cy.js
+4 −0 js/load.js
+9 −0 locale/en/api.po
+6 −0 locale/en/common.po
+56 −0 locale/en/manager.po
+8 −0 locale/en/submission.po
+5 −5 pages/catalog/PKPCatalogHandler.php
+25 −10 pages/management/ManagementHandler.php
+80 −12 schemas/category.json
+0 −101 templates/controllers/grid/settings/category/form/categoryForm.tpl
3 changes: 1 addition & 2 deletions templates/management/context.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@
{load_url_in_div id="seriesGridContainer" url=$seriesGridUrl}
</tab>
<tab id="categories" label="{translate key="grid.category.categories"}">
{capture assign=categoriesUrl}{url router=PKP\core\PKPApplication::ROUTE_COMPONENT component="grid.settings.category.CategoryCategoryGridHandler" op="fetchGrid" escape=false}{/capture}
{load_url_in_div id="categoriesContainer" url=$categoriesUrl}
<category-manager v-bind="pageInitConfig"></category-manager>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same question on pageInitConfig from OJS.

</tab>
</tabs>
{/block}
Loading