diff --git a/src/Entity/Parts/AssociationType.php b/src/Entity/Parts/AssociationType.php index 6980f600..52a56af2 100644 --- a/src/Entity/Parts/AssociationType.php +++ b/src/Entity/Parts/AssociationType.php @@ -34,4 +34,13 @@ enum AssociationType: int case COMPATIBLE = 1; /** The owning part supersedes the other part (owner is newer version) */ case SUPERSEDES = 2; + + /** + * Returns the translation key for this association type. + * @return string + */ + public function getTranslationKey(): string + { + return 'part_association.type.' . strtolower($this->name); + } } diff --git a/src/Form/Part/PartAssociationType.php b/src/Form/Part/PartAssociationType.php index 7163c257..abd534fe 100644 --- a/src/Form/Part/PartAssociationType.php +++ b/src/Form/Part/PartAssociationType.php @@ -37,12 +37,18 @@ class PartAssociationType extends AbstractType public function buildForm(FormBuilderInterface $builder, array $options): void { $builder + ->add('other', PartSelectType::class, [ + 'label' => 'part_association.edit.other_part', + ]) ->add('type', EnumType::class, [ 'class' => AssociationType::class, + 'label' => 'part_association.edit.type', + 'choice_label' => fn(AssociationType $type) => $type->getTranslationKey(), + 'help' => 'part_association.edit.type.help', ]) - ->add('other', PartSelectType::class) ->add('comment', TextType::class, [ 'required' => false, + 'label' => 'part_association.edit.comment' ]) ; diff --git a/src/Services/ElementTypeNameGenerator.php b/src/Services/ElementTypeNameGenerator.php index b9653d13..96efa01e 100644 --- a/src/Services/ElementTypeNameGenerator.php +++ b/src/Services/ElementTypeNameGenerator.php @@ -28,6 +28,7 @@ use App\Entity\Attachments\AttachmentType; use App\Entity\Base\AbstractDBElement; use App\Entity\Base\AbstractNamedDBElement; use App\Entity\Contracts\NamedElementInterface; +use App\Entity\Parts\PartAssociation; use App\Entity\ProjectSystem\Project; use App\Entity\LabelSystem\LabelProfile; use App\Entity\Parameters\AbstractParameter; @@ -80,6 +81,7 @@ class ElementTypeNameGenerator User::class => $this->translator->trans('user.label'), AbstractParameter::class => $this->translator->trans('parameter.label'), LabelProfile::class => $this->translator->trans('label_profile.label'), + PartAssociation::class => $this->translator->trans('part_association.label'), ]; } diff --git a/templates/parts/edit/edit_form_styles.html.twig b/templates/parts/edit/edit_form_styles.html.twig index 7ff81b77..0f46a2ad 100644 --- a/templates/parts/edit/edit_form_styles.html.twig +++ b/templates/parts/edit/edit_form_styles.html.twig @@ -183,4 +183,20 @@ +{% endblock %} + +{% block part_association_widget %} + {% import 'components/collection_type.macro.html.twig' as collection %} +