Skip to content

Commit 8ff2fc5

Browse files
committed
Allow to disable the extraction of parameters out of part description and notes
Fixes issue #747
1 parent c7ec8ad commit 8ff2fc5

3 files changed

Lines changed: 23 additions & 4 deletions

File tree

src/Controller/PartController.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
use App\Services\Parts\PartLotWithdrawAddHelper;
4747
use App\Services\Parts\PricedetailHelper;
4848
use App\Services\ProjectSystem\ProjectBuildPartHelper;
49+
use App\Settings\BehaviorSettings\PartInfoSettings;
4950
use DateTime;
5051
use Doctrine\ORM\EntityManagerInterface;
5152
use Exception;
@@ -69,7 +70,7 @@ public function __construct(protected PricedetailHelper $pricedetailHelper,
6970
protected PartPreviewGenerator $partPreviewGenerator,
7071
private readonly TranslatorInterface $translator,
7172
private readonly AttachmentSubmitHandler $attachmentSubmitHandler, private readonly EntityManagerInterface $em,
72-
protected EventCommentHelper $commentHelper)
73+
protected EventCommentHelper $commentHelper, private readonly PartInfoSettings $partInfoSettings)
7374
{
7475
}
7576

@@ -119,8 +120,8 @@ public function show(Part $part, Request $request, TimeTravel $timeTravel, Histo
119120
'pricedetail_helper' => $this->pricedetailHelper,
120121
'pictures' => $this->partPreviewGenerator->getPreviewAttachments($part),
121122
'timeTravel' => $timeTravel_timestamp,
122-
'description_params' => $parameterExtractor->extractParameters($part->getDescription()),
123-
'comment_params' => $parameterExtractor->extractParameters($part->getComment()),
123+
'description_params' => $this->partInfoSettings->extractParamsFromDescription ? $parameterExtractor->extractParameters($part->getDescription()) : [],
124+
'comment_params' => $this->partInfoSettings->extractParamsFromNotes ? $parameterExtractor->extractParameters($part->getComment()) : [],
124125
'withdraw_add_helper' => $withdrawAddHelper,
125126
]
126127
);

src/Settings/BehaviorSettings/PartInfoSettings.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,10 @@ class PartInfoSettings
4040
#[SettingsParameter(label: new TM("settings.behavior.part_info.show_part_image_overlay"), description: new TM("settings.behavior.part_info.show_part_image_overlay.help"),
4141
envVar: "bool:SHOW_PART_IMAGE_OVERLAY", envVarMode: EnvVarMode::OVERWRITE)]
4242
public bool $showPartImageOverlay = true;
43-
}
43+
44+
#[SettingsParameter(label: new TM("settings.behavior.part_info.extract_params_from_description"))]
45+
public bool $extractParamsFromDescription = true;
46+
47+
#[SettingsParameter(label: new TM("settings.behavior.part_info.extract_params_from_notes"))]
48+
public bool $extractParamsFromNotes = true;
49+
}

translations/messages.en.xlf

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13459,5 +13459,17 @@ Please note, that you can not impersonate a disabled user. If you try you will g
1345913459
<target>Show Part-DB version on homepage</target>
1346013460
</segment>
1346113461
</unit>
13462+
<unit id="GLYhV9m" name="settings.behavior.part_info.extract_params_from_description">
13463+
<segment>
13464+
<source>settings.behavior.part_info.extract_params_from_description</source>
13465+
<target>Extract parameters from part description</target>
13466+
</segment>
13467+
</unit>
13468+
<unit id="aYOedkN" name="settings.behavior.part_info.extract_params_from_notes">
13469+
<segment>
13470+
<source>settings.behavior.part_info.extract_params_from_notes</source>
13471+
<target>Extract parameters from part notes</target>
13472+
</segment>
13473+
</unit>
1346213474
</file>
1346313475
</xliff>

0 commit comments

Comments
 (0)