Allow to import attachments and parameters via entity import

This fixes issue #363
This commit is contained in:
Jan Böhmer 2024-06-23 00:41:25 +02:00
parent bbf7222a6a
commit 06c8e584a4
19 changed files with 73 additions and 58 deletions

View file

@ -147,7 +147,7 @@ abstract class Attachment extends AbstractNamedDBElement
* @var string|null the original filename the file had, when the user uploaded it
*/
#[ORM\Column(type: Types::STRING, nullable: true)]
#[Groups(['full', 'attachment:read'])]
#[Groups(['attachment:read', 'import'])]
#[Assert\Length(max: 255)]
protected ?string $original_filename = null;
@ -161,7 +161,7 @@ abstract class Attachment extends AbstractNamedDBElement
* @var string the name of this element
*/
#[Assert\NotBlank(message: 'validator.attachment.name_not_blank')]
#[Groups(['simple', 'extended', 'full', 'attachment:read', 'attachment:write'])]
#[Groups(['simple', 'extended', 'full', 'attachment:read', 'attachment:write', 'import'])]
protected string $name = '';
/**
@ -173,14 +173,14 @@ abstract class Attachment extends AbstractNamedDBElement
protected ?AttachmentContainingDBElement $element = null;
#[ORM\Column(type: Types::BOOLEAN)]
#[Groups(['attachment:read', 'attachment_write'])]
#[Groups(['attachment:read', 'attachment_write', 'full', 'import'])]
protected bool $show_in_table = false;
#[Assert\NotNull(message: 'validator.attachment.must_not_be_null')]
#[ORM\ManyToOne(targetEntity: AttachmentType::class, inversedBy: 'attachments_with_type')]
#[ORM\JoinColumn(name: 'type_id', nullable: false)]
#[Selectable]
#[Groups(['attachment:read', 'attachment:write'])]
#[Groups(['attachment:read', 'attachment:write', 'import', 'full'])]
#[ApiProperty(readableLink: false)]
protected ?AttachmentType $attachment_type = null;

View file

@ -45,7 +45,7 @@ abstract class AttachmentContainingDBElement extends AbstractNamedDBElement impl
* @phpstan-var Collection<int, AT>
* ORM Mapping is done in subclasses (e.g. Part)
*/
#[Groups(['full'])]
#[Groups(['full', 'import'])]
protected Collection $attachments;
public function __construct()

View file

@ -103,7 +103,7 @@ class AttachmentType extends AbstractStructuralDBElement
*/
#[ORM\Column(type: Types::TEXT)]
#[ValidFileFilter]
#[Groups(['attachment_type:read', 'attachment_type:write'])]
#[Groups(['attachment_type:read', 'attachment_type:write', 'import', 'extended'])]
protected string $filetype_filter = '';
/**
@ -112,12 +112,12 @@ class AttachmentType extends AbstractStructuralDBElement
#[Assert\Valid]
#[ORM\OneToMany(mappedBy: 'element', targetEntity: AttachmentTypeAttachment::class, cascade: ['persist', 'remove'], orphanRemoval: true)]
#[ORM\OrderBy(['name' => Criteria::ASC])]
#[Groups(['attachment_type:read', 'attachment_type:write'])]
#[Groups(['attachment_type:read', 'attachment_type:write', 'import', 'full'])]
protected Collection $attachments;
#[ORM\ManyToOne(targetEntity: AttachmentTypeAttachment::class)]
#[ORM\JoinColumn(name: 'id_preview_attachment', onDelete: 'SET NULL')]
#[Groups(['attachment_type:read', 'attachment_type:write'])]
#[Groups(['attachment_type:read', 'attachment_type:write', 'full'])]
protected ?Attachment $master_picture_attachment = null;
/** @var Collection<int, AttachmentTypeParameter>
@ -125,7 +125,7 @@ class AttachmentType extends AbstractStructuralDBElement
#[Assert\Valid]
#[ORM\OneToMany(mappedBy: 'element', targetEntity: AttachmentTypeParameter::class, cascade: ['persist', 'remove'], orphanRemoval: true)]
#[ORM\OrderBy(['group' => Criteria::ASC, 'name' => 'ASC'])]
#[Groups(['attachment_type:read', 'attachment_type:write'])]
#[Groups(['attachment_type:read', 'attachment_type:write', 'import', 'full'])]
protected Collection $parameters;
/**