mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-12-06 02:59:29 +00:00
Use yellow alert box for notifying of empty bom on build, show infinite correclty and added translations
Fixes issue #1038
This commit is contained in:
parent
05839a549c
commit
377feaf566
5 changed files with 47 additions and 10 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -18,10 +18,9 @@
|
|||
</div>
|
||||
{% endif %}
|
||||
|
||||
<div class="alert {% if can_build %}alert-success{% else %}alert-danger{% endif %}" role="alert">
|
||||
<div class="alert {% if can_build %}alert-success{% elseif bom_empty%}alert-warning{% else %}alert-danger{% endif %}" role="alert">
|
||||
{% if bom_empty %}
|
||||
<h5><i class="fa-solid fa-circle-exclamation fa-fw"></i> {% trans %}project.builds.no_bom_entries{% endtrans %}</h5>
|
||||
<span class="text-muted">{% trans %}project.builds.no_bom_entries_hint{% endtrans %}</span>
|
||||
{% elseif not can_build %}
|
||||
<h5><i class="fa-solid fa-circle-exclamation fa-fw"></i> {% trans %}project.builds.build_not_possible{% endtrans %}</h5>
|
||||
<b>{% trans with {"%number_of_builds%": number_of_builds} %}project.builds.following_bom_entries_miss_instock_n{% endtrans %}</b>
|
||||
|
|
|
|||
|
|
@ -9,10 +9,9 @@
|
|||
</div>
|
||||
{% endif %}
|
||||
|
||||
<div class="alert mt-2 {% if can_build %}alert-success{% else %}alert-danger{% endif %}" role="alert">
|
||||
<div class="alert mt-2 {% if can_build %}alert-success{% elseif bom_empty%}alert-warning{% else %}alert-danger{% endif %}" role="alert">
|
||||
{% if bom_empty %}
|
||||
<h5><i class="fa-solid fa-circle-exclamation fa-fw"></i> {% trans %}project.builds.no_bom_entries{% endtrans %}</h5>
|
||||
<span class="text-muted">{% trans %}project.builds.no_bom_entries_hint{% endtrans %}</span>
|
||||
{% elseif not can_build %}
|
||||
<h5><i class="fa-solid fa-circle-exclamation fa-fw"></i> {% trans %}project.builds.build_not_possible{% endtrans %}</h5>
|
||||
<b>{% trans %}project.builds.following_bom_entries_miss_instock{% endtrans %}</b>
|
||||
|
|
@ -23,7 +22,7 @@
|
|||
</ul>
|
||||
{% else %}
|
||||
<h5><i class="fa-solid fa-circle-check fa-fw"></i> {% trans %}project.builds.build_possible{% endtrans %}</h5>
|
||||
<span>{% trans with {"%max_builds%": buildHelper.maximumBuildableCount(project)} %}project.builds.number_of_builds_possible{% endtrans %}</span>
|
||||
<span>{% trans with {"%max_builds%": buildHelper.maximumBuildableCountAsString(project)} %}project.builds.number_of_builds_possible{% endtrans %}</span>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
|
|
|
|||
|
|
@ -114,4 +114,22 @@ class ProjectBuildHelperTest extends WebTestCase
|
|||
$this->assertSame(0, $this->service->getMaximumBuildableCount($project));
|
||||
|
||||
}
|
||||
|
||||
public function testGetMaximumBuildableCountEmpty(): void
|
||||
{
|
||||
$project = new Project();
|
||||
|
||||
$this->assertSame(0, $this->service->getMaximumBuildableCount($project));
|
||||
}
|
||||
|
||||
public function testGetMaximumBuildableCountAsString(): void
|
||||
{
|
||||
$project = new Project();
|
||||
$bom_entry1 = new ProjectBOMEntry();
|
||||
$bom_entry1->setName("Test");
|
||||
$project->addBomEntry($bom_entry1);
|
||||
|
||||
$this->assertSame('∞', $this->service->getMaximumBuildableCountAsString($project));
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14223,7 +14223,13 @@ Please note, that you can not impersonate a disabled user. If you try you will g
|
|||
<unit id="Ej2znKK" name="settings.system.localization.language_menu_entries.description">
|
||||
<segment state="translated">
|
||||
<source>settings.system.localization.language_menu_entries.description</source>
|
||||
<target>The languages to show in the language drop-down menu. Order can be changed via drag & drop. Leave empty to show all available languages.</target>
|
||||
<target><![CDATA[The languages to show in the language drop-down menu. Order can be changed via drag & drop. Leave empty to show all available languages.]]></target>
|
||||
</segment>
|
||||
</unit>
|
||||
<unit id="xIZ_mEX" name="project.builds.no_bom_entries">
|
||||
<segment>
|
||||
<source>project.builds.no_bom_entries</source>
|
||||
<target>Project has no BOM entries</target>
|
||||
</segment>
|
||||
</unit>
|
||||
</file>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue