Allow to create new parts.

This commit is contained in:
Jan Böhmer 2019-08-19 23:41:58 +02:00
parent 813e7dc85b
commit 76abef57be
3 changed files with 23 additions and 8 deletions

View file

@ -53,8 +53,10 @@ declare(strict_types=1);
namespace App\Entity\Attachments; namespace App\Entity\Attachments;
use App\Entity\Base\NamedDBElement; use App\Entity\Base\NamedDBElement;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection; use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
use Doctrine\ORM\PersistentCollection;
use Exception; use Exception;
/** /**
@ -74,6 +76,11 @@ abstract class AttachmentContainingDBElement extends NamedDBElement
//TODO //TODO
protected $attachmentTypes; protected $attachmentTypes;
public function __construct()
{
$this->attachments = new ArrayCollection();
}
/******************************************************************************** /********************************************************************************
* *
* Getters * Getters

View file

@ -67,6 +67,8 @@ use App\Entity\Devices\Device;
use App\Entity\PriceInformations\Orderdetail; use App\Entity\PriceInformations\Orderdetail;
use App\Security\Annotations\ColumnSecurity; use App\Security\Annotations\ColumnSecurity;
use App\Validator\Constraints\Selectable; use App\Validator\Constraints\Selectable;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
use Doctrine\ORM\PersistentCollection; use Doctrine\ORM\PersistentCollection;
@ -167,7 +169,7 @@ class Part extends AttachmentContainingDBElement
* *
* @ColumnSecurity(prefix="name") * @ColumnSecurity(prefix="name")
*/ */
protected $name; protected $name = '';
/** /**
* @var string * @var string
@ -239,7 +241,7 @@ class Part extends AttachmentContainingDBElement
* @ORM\Column(type="string") * @ORM\Column(type="string")
* @ColumnSecurity(prefix="manufacturer", type="string", placeholder="") * @ColumnSecurity(prefix="manufacturer", type="string", placeholder="")
*/ */
protected $manufacturer_product_number; protected $manufacturer_product_number = '';
/** /**
* @var bool Determines if this part entry needs review (for example, because it is work in progress) * @var bool Determines if this part entry needs review (for example, because it is work in progress)
@ -258,7 +260,7 @@ class Part extends AttachmentContainingDBElement
* @var string A comma seperated list of tags, assocciated with the part. * @var string A comma seperated list of tags, assocciated with the part.
* @ORM\Column(type="text") * @ORM\Column(type="text")
*/ */
protected $tags; protected $tags = '';
/** /**
* @var float|null How much a single part unit weighs in gramms. * @var float|null How much a single part unit weighs in gramms.
@ -267,6 +269,12 @@ class Part extends AttachmentContainingDBElement
*/ */
protected $mass; protected $mass;
public function __construct()
{
parent::__construct();
$this->partLots = new ArrayCollection();
}
/** /**
* Returns the ID as an string, defined by the element class. * Returns the ID as an string, defined by the element class.
* This should have a form like P000014, for a part with ID 14. * This should have a form like P000014, for a part with ID 14.
@ -473,7 +481,7 @@ class Part extends AttachmentContainingDBElement
* * the array is sorted by the suppliers names / minimum order quantity * * the array is sorted by the suppliers names / minimum order quantity
* *
*/ */
public function getOrderdetails(bool $hide_obsolete = false) : PersistentCollection public function getOrderdetails(bool $hide_obsolete = false) : Collection
{ {
//If needed hide the obsolete entries //If needed hide the obsolete entries
if ($hide_obsolete) { if ($hide_obsolete) {
@ -587,9 +595,9 @@ class Part extends AttachmentContainingDBElement
/** /**
* Get all part lots where this part is stored. * Get all part lots where this part is stored.
* @return PartLot[]|PersistentCollection * @return PartLot[]|Collection
*/ */
public function getPartLots() : PersistentCollection public function getPartLots() : Collection
{ {
return $this->partLots; return $this->partLots;
} }

View file

@ -93,10 +93,10 @@ class PartBaseType extends AbstractType
->add('category', StructuralEntityType::class, ['class' => Category::class, ->add('category', StructuralEntityType::class, ['class' => Category::class,
'label' => 'category.label', 'disable_not_selectable' => true, 'label' => 'category.label', 'disable_not_selectable' => true,
'disabled' => !$this->security->isGranted('move', $part), ]) 'disabled' => !$this->security->isGranted('move', $part), ])
->add('footprint', StructuralEntityType::class, ['class' => Footprint::class, ->add('footprint', StructuralEntityType::class, ['class' => Footprint::class, 'required' => false,
'label' => 'footprint.label', 'disable_not_selectable' => true, 'label' => 'footprint.label', 'disable_not_selectable' => true,
'disabled' => !$this->security->isGranted('move', $part), ]) 'disabled' => !$this->security->isGranted('move', $part), ])
->add('tags', TextType::class, ['required' => false, 'label' => 'part.tags', ->add('tags', TextType::class, ['required' => false, 'label' => 'part.tags', 'empty_data' => "",
'attr' => ['data-role' => 'tagsinput'], 'attr' => ['data-role' => 'tagsinput'],
'disabled' => !$this->security->isGranted('edit', $part) ]) 'disabled' => !$this->security->isGranted('edit', $part) ])
->add('comment', CKEditorType::class, ['required' => false, ->add('comment', CKEditorType::class, ['required' => false,