From 377feaf566c2393c92afa025befd4ece117d1d86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20B=C3=B6hmer?= Date: Sat, 18 Oct 2025 23:32:20 +0200 Subject: [PATCH] Use yellow alert box for notifying of empty bom on build, show infinite correclty and added translations Fixes issue #1038 --- .../ProjectSystem/ProjectBuildHelper.php | 19 +++++++++++++++++-- templates/projects/build/build.html.twig | 5 ++--- templates/projects/info/_builds.html.twig | 7 +++---- .../ProjectSystem/ProjectBuildHelperTest.php | 18 ++++++++++++++++++ translations/messages.en.xlf | 8 +++++++- 5 files changed, 47 insertions(+), 10 deletions(-) diff --git a/src/Services/ProjectSystem/ProjectBuildHelper.php b/src/Services/ProjectSystem/ProjectBuildHelper.php index 824923cb..a541c29d 100644 --- a/src/Services/ProjectSystem/ProjectBuildHelper.php +++ b/src/Services/ProjectSystem/ProjectBuildHelper.php @@ -31,9 +31,9 @@ use App\Services\Parts\PartLotWithdrawAddHelper; /** * @see \App\Tests\Services\ProjectSystem\ProjectBuildHelperTest */ -class ProjectBuildHelper +final readonly class ProjectBuildHelper { - public function __construct(private readonly PartLotWithdrawAddHelper $withdraw_add_helper) + public function __construct(private PartLotWithdrawAddHelper $withdraw_add_helper) { } @@ -79,6 +79,21 @@ class ProjectBuildHelper return $maximum_buildable_count; } + /** + * Returns the maximum buildable amount of the given project as string, based on the stock of the used parts in the BOM. + * If the maximum buildable count is infinite, the string '∞' is returned. + * @param Project $project + * @return string + */ + public function getMaximumBuildableCountAsString(Project $project): string + { + $max_count = $this->getMaximumBuildableCount($project); + if ($max_count === PHP_INT_MAX) { + return '∞'; + } + return (string) $max_count; + } + /** * Checks if the given project can be built with the current stock. * This means that the maximum buildable count is greater or equal than the requested $number_of_projects diff --git a/templates/projects/build/build.html.twig b/templates/projects/build/build.html.twig index 6489256d..a5ff3d9a 100644 --- a/templates/projects/build/build.html.twig +++ b/templates/projects/build/build.html.twig @@ -18,10 +18,9 @@ {% endif %} -