diff --git a/migrations/Version20231112211329.php b/migrations/Version20231114223101.php similarity index 77% rename from migrations/Version20231112211329.php rename to migrations/Version20231114223101.php index 8fa7409c..73c845bd 100644 --- a/migrations/Version20231112211329.php +++ b/migrations/Version20231114223101.php @@ -10,7 +10,7 @@ use Doctrine\Migrations\AbstractMigration; /** * Auto-generated Migration: Please modify to your needs! */ -final class Version20231112211329 extends AbstractMigration +final class Version20231114223101 extends AbstractMigration { public function getDescription(): string { @@ -20,7 +20,7 @@ final class Version20231112211329 extends AbstractMigration public function up(Schema $schema): void { // this up() migration is auto-generated, please modify it to your needs - $this->addSql('CREATE TABLE part_association (id INT AUTO_INCREMENT NOT NULL, owner_id INT NOT NULL, other_id INT NOT NULL, type SMALLINT NOT NULL, comment LONGTEXT DEFAULT NULL, last_modified DATETIME DEFAULT CURRENT_TIMESTAMP NOT NULL, datetime_added DATETIME DEFAULT CURRENT_TIMESTAMP NOT NULL, INDEX IDX_61B952E07E3C61F9 (owner_id), INDEX IDX_61B952E0998D9879 (other_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); + $this->addSql('CREATE TABLE part_association (id INT AUTO_INCREMENT NOT NULL, owner_id INT NOT NULL, other_id INT NOT NULL, type SMALLINT NOT NULL, other_type VARCHAR(255) DEFAULT NULL, comment LONGTEXT DEFAULT NULL, last_modified DATETIME DEFAULT CURRENT_TIMESTAMP NOT NULL, datetime_added DATETIME DEFAULT CURRENT_TIMESTAMP NOT NULL, INDEX IDX_61B952E07E3C61F9 (owner_id), INDEX IDX_61B952E0998D9879 (other_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); $this->addSql('ALTER TABLE part_association ADD CONSTRAINT FK_61B952E07E3C61F9 FOREIGN KEY (owner_id) REFERENCES `parts` (id) ON DELETE CASCADE'); $this->addSql('ALTER TABLE part_association ADD CONSTRAINT FK_61B952E0998D9879 FOREIGN KEY (other_id) REFERENCES `parts` (id) ON DELETE CASCADE'); $this->addSql('ALTER TABLE part_lots ADD vendor_barcode VARCHAR(255) DEFAULT NULL'); diff --git a/src/Entity/Parts/PartAssociation.php b/src/Entity/Parts/PartAssociation.php index ae3e1271..1c31bf43 100644 --- a/src/Entity/Parts/PartAssociation.php +++ b/src/Entity/Parts/PartAssociation.php @@ -47,8 +47,14 @@ class PartAssociation extends AbstractDBElement protected AssociationType $type = AssociationType::OTHER; /** - * @var string|null A comment describing this association further. Can also be used to specify the OTHER type - * further. + * @var string|null A user definable association type, which can be described in the comment field, which + * is used if the type is OTHER + */ + #[ORM\Column(type: Types::STRING, length: 255, nullable: true)] + protected ?string $other_type = null; + + /** + * @var string|null A comment describing this association further. */ #[ORM\Column(type: Types::TEXT, nullable: true)] protected ?string $comment = null; @@ -113,5 +119,16 @@ class PartAssociation extends AbstractDBElement return $this; } + public function getOtherType(): ?string + { + return $this->other_type; + } + + public function setOtherType(?string $other_type): PartAssociation + { + $this->other_type = $other_type; + return $this; + } + } \ No newline at end of file diff --git a/src/Form/Part/PartAssociationType.php b/src/Form/Part/PartAssociationType.php index abd534fe..cb5b526f 100644 --- a/src/Form/Part/PartAssociationType.php +++ b/src/Form/Part/PartAssociationType.php @@ -46,6 +46,9 @@ class PartAssociationType extends AbstractType 'choice_label' => fn(AssociationType $type) => $type->getTranslationKey(), 'help' => 'part_association.edit.type.help', ]) + ->add('other_type', TextType::class, [ + 'required' => false, + ]) ->add('comment', TextType::class, [ 'required' => false, 'label' => 'part_association.edit.comment'