From c60b406157a4cfcedca9e114216a2ab9a45a5a1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20B=C3=B6hmer?= Date: Sun, 7 Dec 2025 20:21:19 +0100 Subject: [PATCH 01/10] Fixed partkeepr import with databases that do not feature custom states --- .../PartKeeprImporter/PKDatastructureImporter.php | 2 +- .../ImportExportSystem/PartKeeprImporter/PKPartImporter.php | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Services/ImportExportSystem/PartKeeprImporter/PKDatastructureImporter.php b/src/Services/ImportExportSystem/PartKeeprImporter/PKDatastructureImporter.php index 9e674f05..ec23d34b 100644 --- a/src/Services/ImportExportSystem/PartKeeprImporter/PKDatastructureImporter.php +++ b/src/Services/ImportExportSystem/PartKeeprImporter/PKDatastructureImporter.php @@ -152,7 +152,7 @@ class PKDatastructureImporter public function importPartCustomStates(array $data): int { if (!isset($data['partcustomstate'])) { - throw new \RuntimeException('$data must contain a "partcustomstate" key!'); + return 0; //Not all PartKeepr installations have custom states } $partCustomStateData = $data['partcustomstate']; diff --git a/src/Services/ImportExportSystem/PartKeeprImporter/PKPartImporter.php b/src/Services/ImportExportSystem/PartKeeprImporter/PKPartImporter.php index ab06a134..cab5a49b 100644 --- a/src/Services/ImportExportSystem/PartKeeprImporter/PKPartImporter.php +++ b/src/Services/ImportExportSystem/PartKeeprImporter/PKPartImporter.php @@ -91,7 +91,10 @@ class PKPartImporter $this->setAssociationField($entity, 'partUnit', MeasurementUnit::class, $part['partUnit_id']); } - $this->setAssociationField($entity, 'partCustomState', MeasurementUnit::class, $part['partCustomState_id']); + if (isset($part['partCustomState_id'])) { + $this->setAssociationField($entity, 'partCustomState', MeasurementUnit::class, + $part['partCustomState_id']); + } //Create a part lot to store the stock level and location $lot = new PartLot(); From 39ff4f81c06b07b6fa0b60ad3c85f6da3d7a50cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20B=C3=B6hmer?= Date: Sun, 7 Dec 2025 20:25:39 +0100 Subject: [PATCH 02/10] Use image attachments as preview images for partkeepr imports Fixes issue #1115 --- .../PartKeeprImporter/PKImportHelperTrait.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Services/ImportExportSystem/PartKeeprImporter/PKImportHelperTrait.php b/src/Services/ImportExportSystem/PartKeeprImporter/PKImportHelperTrait.php index 1e4cd3ba..64127341 100644 --- a/src/Services/ImportExportSystem/PartKeeprImporter/PKImportHelperTrait.php +++ b/src/Services/ImportExportSystem/PartKeeprImporter/PKImportHelperTrait.php @@ -150,6 +150,11 @@ trait PKImportHelperTrait $target->addAttachment($attachment); $this->em->persist($attachment); + + //If the attachment is an image, and the target has no master picture yet, set it + if ($attachment->isPicture() && $target->getMasterPictureAttachment() === null) { + $target->setMasterPictureAttachment($attachment); + } } $this->em->flush(); From e1090d46e3a7d26e6ad124cc3e80393d2cd7c81a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20B=C3=B6hmer?= Date: Sun, 7 Dec 2025 20:34:47 +0100 Subject: [PATCH 03/10] Fixed error that attachment path had to have exactly 2048 chars --- src/Entity/Attachments/Attachment.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Entity/Attachments/Attachment.php b/src/Entity/Attachments/Attachment.php index 08aacaa0..259785cb 100644 --- a/src/Entity/Attachments/Attachment.php +++ b/src/Entity/Attachments/Attachment.php @@ -169,7 +169,7 @@ abstract class Attachment extends AbstractNamedDBElement #[ORM\Column(type: Types::STRING, length: 2048, nullable: true)] #[Groups(['attachment:read'])] #[ApiProperty(example: 'http://example.com/image.jpg')] - #[Assert\Length(2048)] + #[Assert\Length(max: 2048)] protected ?string $external_path = null; /** From 15243dbcc889d4fe1b13f6c424f67b0ee95b8be4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20B=C3=B6hmer?= Date: Sun, 7 Dec 2025 20:39:03 +0100 Subject: [PATCH 04/10] Allow to autodetermine categories and pathes from info provider import using a full path This fixes issue #1113 --- src/Repository/StructuralDBElementRepository.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/Repository/StructuralDBElementRepository.php b/src/Repository/StructuralDBElementRepository.php index 781c7622..7fc38671 100644 --- a/src/Repository/StructuralDBElementRepository.php +++ b/src/Repository/StructuralDBElementRepository.php @@ -243,6 +243,14 @@ class StructuralDBElementRepository extends AttachmentContainingDBElementReposit return $result[0]; } + //If the name contains category delimiters like ->, try to find the element by its full path + if (str_contains($name, '->')) { + $tmp = $this->getEntityByPath($name, '->'); + if (count($tmp) > 0) { + return $tmp[count($tmp) - 1]; + } + } + //If we find nothing, return null return null; } From 065396d1e92561cd3156ed7b89254c6307da925d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20B=C3=B6hmer?= Date: Sun, 7 Dec 2025 20:44:32 +0100 Subject: [PATCH 05/10] Correctly determine the number of mass created entities Fixes issue #1102 --- src/Controller/AdminPages/BaseAdminController.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/Controller/AdminPages/BaseAdminController.php b/src/Controller/AdminPages/BaseAdminController.php index e7dd7421..558c7bb2 100644 --- a/src/Controller/AdminPages/BaseAdminController.php +++ b/src/Controller/AdminPages/BaseAdminController.php @@ -366,6 +366,14 @@ abstract class BaseAdminController extends AbstractController } } + //Count how many actual new entities were created (id is null until persisted) + $created_count = 0; + foreach ($results as $result) { + if (null === $result->getID()) { + $created_count++; + } + } + //Persist valid entities to DB foreach ($results as $result) { $em->persist($result); @@ -373,7 +381,7 @@ abstract class BaseAdminController extends AbstractController $em->flush(); if (count($results) > 0) { - $this->addFlash('success', t('entity.mass_creation_flash', ['%COUNT%' => count($results)])); + $this->addFlash('success', t('entity.mass_creation_flash', ['%COUNT%' => $created_count])); } } From 319ac406a818d63ba954af039c1af37ba5486f2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20B=C3=B6hmer?= Date: Sun, 7 Dec 2025 20:50:09 +0100 Subject: [PATCH 06/10] Update the mass creation form, so that you can see the newly created entities in dropdown Fixes issue #1103 --- src/Controller/AdminPages/BaseAdminController.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Controller/AdminPages/BaseAdminController.php b/src/Controller/AdminPages/BaseAdminController.php index 558c7bb2..b2c5e751 100644 --- a/src/Controller/AdminPages/BaseAdminController.php +++ b/src/Controller/AdminPages/BaseAdminController.php @@ -383,6 +383,9 @@ abstract class BaseAdminController extends AbstractController if (count($results) > 0) { $this->addFlash('success', t('entity.mass_creation_flash', ['%COUNT%' => $created_count])); } + + //Recreate mass creation form, so we get the updated parent list and empty lines + $mass_creation_form = $this->createForm(MassCreationForm::class, ['entity_class' => $this->entity_class]); } return $this->render($this->twig_template, [ From b457298152435455d76d218372148c3560da5a5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20B=C3=B6hmer?= Date: Sun, 7 Dec 2025 21:33:41 +0100 Subject: [PATCH 07/10] Do not clear the mass import form if errors appeared --- src/Controller/AdminPages/BaseAdminController.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/Controller/AdminPages/BaseAdminController.php b/src/Controller/AdminPages/BaseAdminController.php index b2c5e751..4378f7a3 100644 --- a/src/Controller/AdminPages/BaseAdminController.php +++ b/src/Controller/AdminPages/BaseAdminController.php @@ -380,12 +380,15 @@ abstract class BaseAdminController extends AbstractController } $em->flush(); - if (count($results) > 0) { + if (count($created_count) > 0) { $this->addFlash('success', t('entity.mass_creation_flash', ['%COUNT%' => $created_count])); } - //Recreate mass creation form, so we get the updated parent list and empty lines - $mass_creation_form = $this->createForm(MassCreationForm::class, ['entity_class' => $this->entity_class]); + if (count($errors)) { + //Recreate mass creation form, so we get the updated parent list and empty lines + $mass_creation_form = $this->createForm(MassCreationForm::class, ['entity_class' => $this->entity_class]); + } + } return $this->render($this->twig_template, [ From 9565a9d548ea44317ec7cfc3744afd57b564dbcd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20B=C3=B6hmer?= Date: Sun, 7 Dec 2025 21:40:57 +0100 Subject: [PATCH 08/10] Fixed error with mass creation, when elements on different level had the same name Fixes issue #1104 --- src/Controller/AdminPages/BaseAdminController.php | 2 +- src/Services/ImportExportSystem/EntityImporter.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Controller/AdminPages/BaseAdminController.php b/src/Controller/AdminPages/BaseAdminController.php index 4378f7a3..7c109751 100644 --- a/src/Controller/AdminPages/BaseAdminController.php +++ b/src/Controller/AdminPages/BaseAdminController.php @@ -380,7 +380,7 @@ abstract class BaseAdminController extends AbstractController } $em->flush(); - if (count($created_count) > 0) { + if (count($results) > 0) { $this->addFlash('success', t('entity.mass_creation_flash', ['%COUNT%' => $created_count])); } diff --git a/src/Services/ImportExportSystem/EntityImporter.php b/src/Services/ImportExportSystem/EntityImporter.php index 459866ba..a89be9dc 100644 --- a/src/Services/ImportExportSystem/EntityImporter.php +++ b/src/Services/ImportExportSystem/EntityImporter.php @@ -167,7 +167,7 @@ class EntityImporter } //Only return objects once - return array_values(array_unique($valid_entities)); + return array_values(array_unique($valid_entities, SORT_REGULAR)); } /** From e0feda4e466a9a764561f6556ddb70b12032ae12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20B=C3=B6hmer?= Date: Sun, 7 Dec 2025 22:47:27 +0100 Subject: [PATCH 09/10] Fixed 2DA login Fixes issue #1141 --- config/packages/translation.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/packages/translation.yaml b/config/packages/translation.yaml index a3f529e3..cbc1cd7e 100644 --- a/config/packages/translation.yaml +++ b/config/packages/translation.yaml @@ -1,7 +1,7 @@ framework: default_locale: 'en' # Just enable the locales we need for performance reasons. - enabled_locale: ['en', 'de', 'it', 'fr', 'ru', 'ja', 'cs', 'da', 'zh', 'pl'] + enabled_locale: '%partdb.locale_menu%' translator: default_path: '%kernel.project_dir%/translations' fallbacks: From 98b8c5b788aac772a66b4de1f92c356ddc776370 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20B=C3=B6hmer?= Date: Sun, 7 Dec 2025 22:47:59 +0100 Subject: [PATCH 10/10] Bump to version 2.3.0 --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index c043eea7..276cbf9e 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -2.2.1 +2.3.0