Improved the association edit panel

This commit is contained in:
Jan Böhmer 2023-11-13 23:01:59 +01:00
parent 8ab9cf1417
commit 81f8b365e9
5 changed files with 70 additions and 1 deletions

View file

@ -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);
}
}

View file

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

View file

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