From 85e31c684d13cd2a103025e1573c4d5884f8dc9c Mon Sep 17 00:00:00 2001 From: Phablulo Date: Thu, 30 Dec 2021 12:16:29 -0300 Subject: [PATCH] [MODULES][Collection] Fixing mistakes --- src/Core/Controller/CollectionController.php | 1 + src/Core/Modules/Collection.php | 9 ++++++--- templates/collections/collections.html.twig | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/Core/Controller/CollectionController.php b/src/Core/Controller/CollectionController.php index 9bed76323f..c8d80b48c5 100644 --- a/src/Core/Controller/CollectionController.php +++ b/src/Core/Controller/CollectionController.php @@ -192,6 +192,7 @@ abstract class CollectionController extends FeedController return [ '_template' => 'collections/collections.html.twig', 'page_title' => $this->page_title, + 'list_title' => 'Your ' . $this->plural_slug, 'add_collection' => $create?->createView(), 'fn' => $fn, 'collections' => $collections, diff --git a/src/Core/Modules/Collection.php b/src/Core/Modules/Collection.php index 47ba9e0999..4421048989 100644 --- a/src/Core/Modules/Collection.php +++ b/src/Core/Modules/Collection.php @@ -76,6 +76,9 @@ abstract class Collection extends Plugin foreach ($collections as $col) { $choices[$col->getName()] = $col->getId(); } + + $collections = array_map(fn ($x) => $x->getId(), $collections); + $already_selected = $this->getCollectionsBy($user, $vars, true); $add_form = Form::create([ ['collections', ChoiceType::class, [ @@ -98,9 +101,9 @@ abstract class Collection extends Plugin ]); $add_form->handleRequest($request); if ($add_form->isSubmitted() && $add_form->isValid()) { - $collections = $add_form->getData()['collections']; - $removed = array_filter($already_selected, fn ($x) => !\in_array($x, $collections)); - $added = array_filter($collections, fn ($x) => !\in_array($x, $already_selected)); + $selected = $add_form->getData()['collections']; + $removed = array_filter($already_selected, fn ($x) => !\in_array($x, $selected)); + $added = array_filter($selected, fn ($x) => !\in_array($x, $already_selected)); if (\count($removed) > 0) { $this->removeItems($user, $vars, $removed, $collections); } diff --git a/templates/collections/collections.html.twig b/templates/collections/collections.html.twig index 7dd761f3aa..f2d209fc37 100644 --- a/templates/collections/collections.html.twig +++ b/templates/collections/collections.html.twig @@ -19,7 +19,7 @@ {% endif %}
-

{{ 'Your collections' | trans }}

+

{{ list_title | trans }}

{% for col in collections %}