mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-12-14 15:09:31 +00:00
Merge remote-tracking branch 'origin/master' into order-details
# Conflicts: # src/Entity/Parts/Part.php
This commit is contained in:
commit
3408334a1f
104 changed files with 12100 additions and 1406 deletions
|
|
@ -22,8 +22,6 @@ declare(strict_types=1);
|
|||
|
||||
namespace App\Entity\Parts;
|
||||
|
||||
use App\ApiPlatform\Filter\TagFilter;
|
||||
use Doctrine\Common\Collections\Criteria;
|
||||
use ApiPlatform\Doctrine\Common\Filter\DateFilterInterface;
|
||||
use ApiPlatform\Doctrine\Orm\Filter\BooleanFilter;
|
||||
use ApiPlatform\Doctrine\Orm\Filter\DateFilter;
|
||||
|
|
@ -40,10 +38,12 @@ use ApiPlatform\Serializer\Filter\PropertyFilter;
|
|||
use App\ApiPlatform\Filter\EntityFilter;
|
||||
use App\ApiPlatform\Filter\LikeFilter;
|
||||
use App\ApiPlatform\Filter\PartStoragelocationFilter;
|
||||
use App\ApiPlatform\Filter\TagFilter;
|
||||
use App\Entity\Attachments\Attachment;
|
||||
use App\Entity\Attachments\AttachmentContainingDBElement;
|
||||
use App\Entity\Attachments\PartAttachment;
|
||||
use App\Entity\EDA\EDAPartInfo;
|
||||
use App\Entity\InfoProviderSystem\BulkInfoProviderImportJobPart;
|
||||
use App\Entity\Parameters\ParametersTrait;
|
||||
use App\Entity\Parameters\PartParameter;
|
||||
use App\Entity\Parts\PartTraits\AdvancedPropertyTrait;
|
||||
|
|
@ -59,6 +59,7 @@ use App\Repository\PartRepository;
|
|||
use App\Validator\Constraints\UniqueObjectCollection;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\Common\Collections\Criteria;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Doctrine\DBAL\Types\Types;
|
||||
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
|
||||
|
|
@ -84,8 +85,18 @@ use Symfony\Component\Validator\Context\ExecutionContextInterface;
|
|||
#[ORM\Index(columns: ['ipn'], name: 'parts_idx_ipn')]
|
||||
#[ApiResource(
|
||||
operations: [
|
||||
new Get(normalizationContext: ['groups' => ['part:read', 'provider_reference:read', 'api:basic:read', 'part_lot:read',
|
||||
'orderdetail:read', 'pricedetail:read', 'parameter:read', 'attachment:read', 'eda_info:read'],
|
||||
new Get(normalizationContext: [
|
||||
'groups' => [
|
||||
'part:read',
|
||||
'provider_reference:read',
|
||||
'api:basic:read',
|
||||
'part_lot:read',
|
||||
'orderdetail:read',
|
||||
'pricedetail:read',
|
||||
'parameter:read',
|
||||
'attachment:read',
|
||||
'eda_info:read'
|
||||
],
|
||||
'openapi_definition_name' => 'Read',
|
||||
], security: 'is_granted("read", object)'),
|
||||
new GetCollection(security: 'is_granted("@parts.read")'),
|
||||
|
|
@ -93,7 +104,7 @@ use Symfony\Component\Validator\Context\ExecutionContextInterface;
|
|||
new Patch(security: 'is_granted("edit", object)'),
|
||||
new Delete(security: 'is_granted("delete", object)'),
|
||||
],
|
||||
normalizationContext: ['groups' => ['part:read', 'provider_reference:read', 'api:basic:read', 'part_lot:read'], 'openapi_definition_name' => 'Read'],
|
||||
normalizationContext: ['groups' => ['part:read', 'provider_reference:read', 'api:basic:read', 'part_lot:read'], 'openapi_definition_name' => 'Read'],
|
||||
denormalizationContext: ['groups' => ['part:write', 'api:basic:write', 'eda_info:write', 'attachment:write', 'parameter:write'], 'openapi_definition_name' => 'Write'],
|
||||
)]
|
||||
#[ApiFilter(PropertyFilter::class)]
|
||||
|
|
@ -101,7 +112,7 @@ use Symfony\Component\Validator\Context\ExecutionContextInterface;
|
|||
#[ApiFilter(PartStoragelocationFilter::class, properties: ["storage_location"])]
|
||||
#[ApiFilter(LikeFilter::class, properties: ["name", "comment", "description", "ipn", "manufacturer_product_number"])]
|
||||
#[ApiFilter(TagFilter::class, properties: ["tags"])]
|
||||
#[ApiFilter(BooleanFilter::class, properties: ["favorite" , "needs_review"])]
|
||||
#[ApiFilter(BooleanFilter::class, properties: ["favorite", "needs_review"])]
|
||||
#[ApiFilter(RangeFilter::class, properties: ["mass", "minamount", "orderamount"])]
|
||||
#[ApiFilter(DateFilter::class, strategy: DateFilterInterface::EXCLUDE_NULL)]
|
||||
#[ApiFilter(OrderFilter::class, properties: ['name', 'id', 'orderDelivery', 'addedDate', 'lastModified'])]
|
||||
|
|
@ -170,6 +181,12 @@ class Part extends AttachmentContainingDBElement
|
|||
#[Groups(['part:read'])]
|
||||
protected ?\DateTimeImmutable $lastModified = null;
|
||||
|
||||
/**
|
||||
* @var Collection<int, BulkInfoProviderImportJobPart>
|
||||
*/
|
||||
#[ORM\OneToMany(mappedBy: 'part', targetEntity: BulkInfoProviderImportJobPart::class, cascade: ['remove'], orphanRemoval: true)]
|
||||
protected Collection $bulkImportJobParts;
|
||||
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
|
|
@ -182,6 +199,7 @@ class Part extends AttachmentContainingDBElement
|
|||
|
||||
$this->associated_parts_as_owner = new ArrayCollection();
|
||||
$this->associated_parts_as_other = new ArrayCollection();
|
||||
$this->bulkImportJobParts = new ArrayCollection();
|
||||
|
||||
//By default, the part has no provider
|
||||
$this->providerReference = InfoProviderReference::noProvider();
|
||||
|
|
@ -260,4 +278,38 @@ class Part extends AttachmentContainingDBElement
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all bulk import job parts for this part
|
||||
* @return Collection<int, BulkInfoProviderImportJobPart>
|
||||
*/
|
||||
public function getBulkImportJobParts(): Collection
|
||||
{
|
||||
return $this->bulkImportJobParts;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a bulk import job part to this part
|
||||
*/
|
||||
public function addBulkImportJobPart(BulkInfoProviderImportJobPart $jobPart): self
|
||||
{
|
||||
if (!$this->bulkImportJobParts->contains($jobPart)) {
|
||||
$this->bulkImportJobParts->add($jobPart);
|
||||
$jobPart->setPart($this);
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a bulk import job part from this part
|
||||
*/
|
||||
public function removeBulkImportJobPart(BulkInfoProviderImportJobPart $jobPart): self
|
||||
{
|
||||
if ($this->bulkImportJobParts->removeElement($jobPart)) {
|
||||
if ($jobPart->getPart() === $this) {
|
||||
$jobPart->setPart(null);
|
||||
}
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue