Allow to disable the extraction of parameters out of part description and notes

Fixes issue #747
This commit is contained in:
Jan Böhmer 2025-09-07 19:55:47 +02:00
parent c7ec8adc31
commit 8ff2fc5a82
3 changed files with 23 additions and 4 deletions

View file

@ -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,
]
);

View file

@ -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;
#[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;
}

View file

@ -13459,5 +13459,17 @@ Please note, that you can not impersonate a disabled user. If you try you will g
<target>Show Part-DB version on homepage</target>
</segment>
</unit>
<unit id="GLYhV9m" name="settings.behavior.part_info.extract_params_from_description">
<segment>
<source>settings.behavior.part_info.extract_params_from_description</source>
<target>Extract parameters from part description</target>
</segment>
</unit>
<unit id="aYOedkN" name="settings.behavior.part_info.extract_params_from_notes">
<segment>
<source>settings.behavior.part_info.extract_params_from_notes</source>
<target>Extract parameters from part notes</target>
</segment>
</unit>
</file>
</xliff>