diff --git a/src/DataTables/Helpers/PartDataTableHelper.php b/src/DataTables/Helpers/PartDataTableHelper.php index 37737052..90255835 100644 --- a/src/DataTables/Helpers/PartDataTableHelper.php +++ b/src/DataTables/Helpers/PartDataTableHelper.php @@ -57,6 +57,10 @@ class PartDataTableHelper if ($context->isNeedsReview()) { $icon = sprintf('', $this->translator->trans('part.needs_review.badge')); } + if ($context->getBuiltProject() !== null) { + $icon = sprintf('', + $this->translator->trans('part.info.projectBuildPart.hint') . ': ' . $context->getBuiltProject()->getName()); + } return sprintf( diff --git a/src/Services/Attachments/PartPreviewGenerator.php b/src/Services/Attachments/PartPreviewGenerator.php index d47e873c..39d1c65c 100644 --- a/src/Services/Attachments/PartPreviewGenerator.php +++ b/src/Services/Attachments/PartPreviewGenerator.php @@ -62,6 +62,13 @@ class PartPreviewGenerator } } + if (null !== $part->getBuiltProject()) { + $attachment = $part->getBuiltProject()->getMasterPictureAttachment(); + if ($this->isAttachmentValidPicture($attachment)) { + $list[] = $attachment; + } + } + if (null !== $part->getCategory()) { $attachment = $part->getCategory()->getMasterPictureAttachment(); if ($this->isAttachmentValidPicture($attachment)) { @@ -109,7 +116,7 @@ class PartPreviewGenerator return $attachment; } - //Otherwise check if the part has a footprint with a valid masterattachment + //Otherwise check if the part has a footprint with a valid master attachment if (null !== $part->getFootprint()) { $attachment = $part->getFootprint()->getMasterPictureAttachment(); if ($this->isAttachmentValidPicture($attachment)) { @@ -117,6 +124,14 @@ class PartPreviewGenerator } } + //With lowest priority use the master attachment of the project this part represents (when existing) + if (null !== $part->getBuiltProject()) { + $attachment = $part->getBuiltProject()->getMasterPictureAttachment(); + if ($this->isAttachmentValidPicture($attachment)) { + return $attachment; + } + } + //If nothing is available return null return null; } diff --git a/templates/Parts/info/_extended_infos.html.twig b/templates/Parts/info/_extended_infos.html.twig index fec3d5c9..e0bb01d7 100644 --- a/templates/Parts/info/_extended_infos.html.twig +++ b/templates/Parts/info/_extended_infos.html.twig @@ -37,14 +37,20 @@ {{ part.iD }} - {# ID #} + {# IPN #} {% trans %}part.edit.ipn{% endtrans %} {{ part.ipn ?? 'part.ipn.not_defined'|trans }} {# Favorite status #} {% trans %}part.isFavorite{% endtrans %} - {{ helper.boolean(part.favorite) }} + {{ helper.boolean_badge(part.favorite) }} + + + {# Build status #} + {% trans %}part.is_build_part{% endtrans %} + {{ helper.boolean_badge(part.projectBuildPart) }} + {% if part.projectBuildPart %}({{ part.builtProject.name }}){% endif %} diff --git a/templates/Parts/info/_sidebar.html.twig b/templates/Parts/info/_sidebar.html.twig index 65a7d576..9d6296df 100644 --- a/templates/Parts/info/_sidebar.html.twig +++ b/templates/Parts/info/_sidebar.html.twig @@ -4,6 +4,10 @@ {% trans with {'%timestamp%': timeTravel|format_datetime('short')} %}part.info.timetravel_hint{% endtrans %} {% endif %} +{% if part.projectBuildPart %} + {% trans %}part.info.projectBuildPart.hint{% endtrans %}: {{ part.builtProject.name }} +{% endif %} +
{{ helper.date_user_combination(part, true) }} diff --git a/templates/Parts/info/show_part_info.html.twig b/templates/Parts/info/show_part_info.html.twig index 10cd423e..ad8d9dc9 100644 --- a/templates/Parts/info/show_part_info.html.twig +++ b/templates/Parts/info/show_part_info.html.twig @@ -20,6 +20,9 @@ {% if timeTravel != null %} ({{ timeTravel | format_datetime('short') }}) {% endif %} + {% if part.projectBuildPart %} + ({{ entity_type_label(part.builtProject) }}: {{ part.builtProject.name }}) + {% endif %}
{% trans %}id.label{% endtrans %}: {{ part.id }} {% if part.ipn is not empty %}({{ part.ipn }}){% endif %}
diff --git a/translations/messages.en.xlf b/translations/messages.en.xlf index f791969b..b3fbae4e 100644 --- a/translations/messages.en.xlf +++ b/translations/messages.en.xlf @@ -10079,5 +10079,17 @@ Element 3 This part represents the builds of this project, which are stored somewhere. + + + part.info.projectBuildPart.hint + This part represents the builds of the following project and is associated with it + + + + + part.is_build_part + Is project builds part + +