From 8ff2fc5a82591a11c0c04c5ee823330538c24770 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20B=C3=B6hmer?= Date: Sun, 7 Sep 2025 19:55:47 +0200 Subject: [PATCH] Allow to disable the extraction of parameters out of part description and notes Fixes issue #747 --- src/Controller/PartController.php | 7 ++++--- src/Settings/BehaviorSettings/PartInfoSettings.php | 8 +++++++- translations/messages.en.xlf | 12 ++++++++++++ 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/src/Controller/PartController.php b/src/Controller/PartController.php index b11a5c90..6708ed4c 100644 --- a/src/Controller/PartController.php +++ b/src/Controller/PartController.php @@ -46,6 +46,7 @@ use App\Services\Parameters\ParameterExtractor; use App\Services\Parts\PartLotWithdrawAddHelper; use App\Services\Parts\PricedetailHelper; use App\Services\ProjectSystem\ProjectBuildPartHelper; +use App\Settings\BehaviorSettings\PartInfoSettings; use DateTime; use Doctrine\ORM\EntityManagerInterface; use Exception; @@ -69,7 +70,7 @@ class PartController extends AbstractController protected PartPreviewGenerator $partPreviewGenerator, private readonly TranslatorInterface $translator, private readonly AttachmentSubmitHandler $attachmentSubmitHandler, private readonly EntityManagerInterface $em, - protected EventCommentHelper $commentHelper) + protected EventCommentHelper $commentHelper, private readonly PartInfoSettings $partInfoSettings) { } @@ -119,8 +120,8 @@ class PartController extends AbstractController 'pricedetail_helper' => $this->pricedetailHelper, 'pictures' => $this->partPreviewGenerator->getPreviewAttachments($part), 'timeTravel' => $timeTravel_timestamp, - 'description_params' => $parameterExtractor->extractParameters($part->getDescription()), - 'comment_params' => $parameterExtractor->extractParameters($part->getComment()), + 'description_params' => $this->partInfoSettings->extractParamsFromDescription ? $parameterExtractor->extractParameters($part->getDescription()) : [], + 'comment_params' => $this->partInfoSettings->extractParamsFromNotes ? $parameterExtractor->extractParameters($part->getComment()) : [], 'withdraw_add_helper' => $withdrawAddHelper, ] ); diff --git a/src/Settings/BehaviorSettings/PartInfoSettings.php b/src/Settings/BehaviorSettings/PartInfoSettings.php index 4c44b9bb..f017c846 100644 --- a/src/Settings/BehaviorSettings/PartInfoSettings.php +++ b/src/Settings/BehaviorSettings/PartInfoSettings.php @@ -40,4 +40,10 @@ class PartInfoSettings #[SettingsParameter(label: new TM("settings.behavior.part_info.show_part_image_overlay"), description: new TM("settings.behavior.part_info.show_part_image_overlay.help"), envVar: "bool:SHOW_PART_IMAGE_OVERLAY", envVarMode: EnvVarMode::OVERWRITE)] public bool $showPartImageOverlay = true; -} \ No newline at end of file + + #[SettingsParameter(label: new TM("settings.behavior.part_info.extract_params_from_description"))] + public bool $extractParamsFromDescription = true; + + #[SettingsParameter(label: new TM("settings.behavior.part_info.extract_params_from_notes"))] + public bool $extractParamsFromNotes = true; +} diff --git a/translations/messages.en.xlf b/translations/messages.en.xlf index b7710f0c..6680521b 100644 --- a/translations/messages.en.xlf +++ b/translations/messages.en.xlf @@ -13459,5 +13459,17 @@ Please note, that you can not impersonate a disabled user. If you try you will g Show Part-DB version on homepage + + + settings.behavior.part_info.extract_params_from_description + Extract parameters from part description + + + + + settings.behavior.part_info.extract_params_from_notes + Extract parameters from part notes + +