From c75447ed83026cdc8e350efda2979637bc907c94 Mon Sep 17 00:00:00 2001 From: taslangraham Date: Thu, 10 Apr 2025 14:58:53 -0500 Subject: [PATCH 1/5] pkp/pkp-lib#10404 Allow arbitrary nesting depth in categories --- api/v1/categories/index.php | 19 +++++++++++++++++++ .../50-CreateCategories.cy.js | 2 +- dbscripts/xml/upgrade.xml | 1 + templates/management/context.tpl | 3 +-- 4 files changed, 22 insertions(+), 3 deletions(-) create mode 100644 api/v1/categories/index.php diff --git a/api/v1/categories/index.php b/api/v1/categories/index.php new file mode 100644 index 00000000000..99efb5602f3 --- /dev/null +++ b/api/v1/categories/index.php @@ -0,0 +1,19 @@ + + diff --git a/templates/management/context.tpl b/templates/management/context.tpl index 5eaf6632445..40113e0665c 100644 --- a/templates/management/context.tpl +++ b/templates/management/context.tpl @@ -45,8 +45,7 @@ {load_url_in_div id="seriesGridContainer" url=$seriesGridUrl} - {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} + {/block} From 14a2abca978b775a9cfb74ad4d78291f31be0203 Mon Sep 17 00:00:00 2001 From: taslangraham Date: Tue, 6 May 2025 20:00:43 -0500 Subject: [PATCH 2/5] updates based of review --- .../I10404_UpdateCategoryImageNameFields.php | 23 +++++++++++++++++++ dbscripts/xml/upgrade.xml | 2 +- templates/management/context.tpl | 2 +- 3 files changed, 25 insertions(+), 2 deletions(-) create mode 100644 classes/migration/upgrade/v3_6_0/I10404_UpdateCategoryImageNameFields.php diff --git a/classes/migration/upgrade/v3_6_0/I10404_UpdateCategoryImageNameFields.php b/classes/migration/upgrade/v3_6_0/I10404_UpdateCategoryImageNameFields.php new file mode 100644 index 00000000000..498cecfcbfe --- /dev/null +++ b/classes/migration/upgrade/v3_6_0/I10404_UpdateCategoryImageNameFields.php @@ -0,0 +1,23 @@ + - + diff --git a/templates/management/context.tpl b/templates/management/context.tpl index 40113e0665c..bed3c92ac2f 100644 --- a/templates/management/context.tpl +++ b/templates/management/context.tpl @@ -45,7 +45,7 @@ {load_url_in_div id="seriesGridContainer" url=$seriesGridUrl} - + {/block} From cf60b58f685604b9581a36d7b0b50ee63fd71bcb Mon Sep 17 00:00:00 2001 From: taslangraham Date: Tue, 6 May 2025 20:37:55 -0500 Subject: [PATCH 3/5] circular reference check --- .../forms/publication/CatalogEntryForm.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/classes/components/forms/publication/CatalogEntryForm.php b/classes/components/forms/publication/CatalogEntryForm.php index f35a6aef1f1..58ae7df6a3a 100644 --- a/classes/components/forms/publication/CatalogEntryForm.php +++ b/classes/components/forms/publication/CatalogEntryForm.php @@ -1,4 +1,5 @@ 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, ])); } From 6024eb06b6086be5665758f64ba846b70dea812a Mon Sep 17 00:00:00 2001 From: "Taslan A. Graham" <49318261+taslangraham@users.noreply.github.com> Date: Fri, 9 May 2025 00:34:00 -0500 Subject: [PATCH 4/5] Apply suggestions from code review Co-authored-by: Jonas Raoni Soares da Silva --- api/v1/categories/index.php | 2 +- .../v3_6_0/I10404_UpdateCategoryImageNameFields.php | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/api/v1/categories/index.php b/api/v1/categories/index.php index 99efb5602f3..41bb2d64486 100644 --- a/api/v1/categories/index.php +++ b/api/v1/categories/index.php @@ -1,6 +1,5 @@ Date: Fri, 9 May 2025 00:36:59 -0500 Subject: [PATCH 5/5] Submodule update --- lib/pkp | 2 +- lib/ui-library | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/pkp b/lib/pkp index 901fc3d4aac..466baa46c20 160000 --- a/lib/pkp +++ b/lib/pkp @@ -1 +1 @@ -Subproject commit 901fc3d4aacdf0033d78e1a790f71b76157fb144 +Subproject commit 466baa46c20273f48a78a4c505be4d3e5b15e3ae diff --git a/lib/ui-library b/lib/ui-library index 11bdd4ab289..fc5eb14ef86 160000 --- a/lib/ui-library +++ b/lib/ui-library @@ -1 +1 @@ -Subproject commit 11bdd4ab2890cce6ba4b0183f3f3f73a2cf795e1 +Subproject commit fc5eb14ef86d55463d86b583c3f5dac08a850388