Allow to put parameters in different groups.

This commit is contained in:
Jan Böhmer 2020-03-24 15:08:56 +01:00
parent 43857ce985
commit 2899db0206
31 changed files with 114 additions and 23 deletions

View file

@ -64,6 +64,7 @@ class AttachmentType extends AbstractStructuralDBElement
/** @var AttachmentTypeParameter[]
* @ORM\OneToMany(targetEntity="App\Entity\Parameters\AttachmentTypeParameter", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true)
* @ORM\OrderBy({"group" = "ASC" ,"name" = "ASC"})
* @Assert\Valid()
*/
protected $parameters;

View file

@ -100,6 +100,7 @@ class Device extends AbstractPartsContainingDBElement
/** @var DeviceParameter[]
* @ORM\OneToMany(targetEntity="App\Entity\Parameters\DeviceParameter", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true)
* @ORM\OrderBy({"group" = "ASC" ,"name" = "ASC"})
*/
protected $parameters;

View file

@ -28,6 +28,7 @@ use App\Entity\Base\AbstractNamedDBElement;
use Doctrine\ORM\Mapping as ORM;
use InvalidArgumentException;
use LogicException;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
use Symfony\Component\Validator\Constraints as Assert;
/**
@ -211,6 +212,26 @@ abstract class AbstractParameter extends AbstractNamedDBElement
return $this;
}
/**
* Returns the name of the group this parameter is associated to (e.g. Technical Parameters)
* @return string
*/
public function getGroup(): string
{
return $this->group;
}
/**
* Sets the name of the group this parameter is associated to.
* @param string $group
* @return $this
*/
public function setGroup(string $group): self
{
$this->group = $group;
return $this;
}
/**
* Returns the mathematical symbol for this specification (e.g. "V_CB").
*

View file

@ -25,9 +25,11 @@ namespace App\Entity\Parameters;
use App\Entity\Attachments\AttachmentType;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
/**
* @ORM\Entity()
* @UniqueEntity(fields={"name", "group", "element"})
*/
class AttachmentTypeParameter extends AbstractParameter
{

View file

@ -25,9 +25,11 @@ namespace App\Entity\Parameters;
use App\Entity\Parts\Category;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
/**
* @ORM\Entity()
* @UniqueEntity(fields={"name", "group", "element"})
*/
class CategoryParameter extends AbstractParameter
{

View file

@ -25,11 +25,13 @@ namespace App\Entity\Parameters;
use App\Entity\PriceInformations\Currency;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
/**
* A attachment attached to a category element.
*
* @ORM\Entity()
* @UniqueEntity(fields={"name", "group", "element"})
*/
class CurrencyParameter extends AbstractParameter
{

View file

@ -25,9 +25,11 @@ namespace App\Entity\Parameters;
use App\Entity\Devices\Device;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
/**
* @ORM\Entity()
* @UniqueEntity(fields={"name", "group", "element"})
*/
class DeviceParameter extends AbstractParameter
{

View file

@ -25,9 +25,11 @@ namespace App\Entity\Parameters;
use App\Entity\Parts\Footprint;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
/**
* @ORM\Entity()
* @UniqueEntity(fields={"name", "group", "element"})
*/
class FootprintParameter extends AbstractParameter
{

View file

@ -25,9 +25,11 @@ namespace App\Entity\Parameters;
use App\Entity\UserSystem\Group;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
/**
* @ORM\Entity()
* @UniqueEntity(fields={"name", "group", "element"})
*/
class GroupParameter extends AbstractParameter
{

View file

@ -25,9 +25,11 @@ namespace App\Entity\Parameters;
use App\Entity\Parts\Manufacturer;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
/**
* @ORM\Entity()
* @UniqueEntity(fields={"name", "group", "element"})
*/
class ManufacturerParameter extends AbstractParameter
{

View file

@ -25,9 +25,11 @@ namespace App\Entity\Parameters;
use App\Entity\Parts\MeasurementUnit;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
/**
* @ORM\Entity()
* @UniqueEntity(fields={"name", "group", "element"})
*/
class MeasurementUnitParameter extends AbstractParameter
{

View file

@ -65,4 +65,14 @@ trait ParametersTrait
return $this;
}
public function getGroupedParameters(): array
{
$tmp = [];
foreach ($this->parameters as $parameter) {
$tmp[$parameter->getGroup()][] = $parameter;
}
return $tmp;
}
}

View file

@ -25,9 +25,11 @@ namespace App\Entity\Parameters;
use App\Entity\Parts\Part;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
/**
* @ORM\Entity()
* @UniqueEntity(fields={"name", "group", "element"})
*/
class PartParameter extends AbstractParameter
{

View file

@ -25,9 +25,11 @@ namespace App\Entity\Parameters;
use App\Entity\Parts\Storelocation;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
/**
* @ORM\Entity()
* @UniqueEntity(fields={"name", "group", "element"})
*/
class StorelocationParameter extends AbstractParameter
{

View file

@ -25,9 +25,11 @@ namespace App\Entity\Parameters;
use App\Entity\Parts\Supplier;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
/**
* @ORM\Entity()
* @UniqueEntity(fields={"name", "group", "element"})
*/
class SupplierParameter extends AbstractParameter
{

View file

@ -109,6 +109,7 @@ class Category extends AbstractPartsContainingDBElement
/** @var CategoryParameter[]
* @ORM\OneToMany(targetEntity="App\Entity\Parameters\CategoryParameter", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true)
* @ORM\OrderBy({"group" = "ASC" ,"name" = "ASC"})
* @Assert\Valid()
*/
protected $parameters;

View file

@ -96,6 +96,7 @@ class Footprint extends AbstractPartsContainingDBElement
/** @var FootprintParameter[]
* @ORM\OneToMany(targetEntity="App\Entity\Parameters\FootprintParameter", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true)
* @ORM\OrderBy({"group" = "ASC" ,"name" = "ASC"})@ORM\OrderBy({"group" = "ASC" ,"name" = "ASC"})
* @Assert\Valid()
*/
protected $parameters;

View file

@ -89,6 +89,7 @@ class Manufacturer extends AbstractCompany
/** @var ManufacturerParameter[]
* @ORM\OneToMany(targetEntity="App\Entity\Parameters\ManufacturerParameter", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true)
* @ORM\OrderBy({"group" = "ASC" ,"name" = "ASC"})
* @Assert\Valid()
*/
protected $parameters;

View file

@ -106,6 +106,7 @@ class MeasurementUnit extends AbstractPartsContainingDBElement
/** @var MeasurementUnitParameter[]
* @ORM\OneToMany(targetEntity="App\Entity\Parameters\MeasurementUnitParameter", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true)
* @ORM\OrderBy({"group" = "ASC" ,"name" = "ASC"})
* @Assert\Valid()
*/
protected $parameters;

View file

@ -93,6 +93,8 @@ class Part extends AttachmentContainingDBElement
/** @var PartParameter[]
* @Assert\Valid()
* @ORM\OneToMany(targetEntity="App\Entity\Parameters\PartParameter", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true)
* @ORM\OrderBy({"group" = "ASC" ,"name" = "ASC"})
* @ORM\OrderBy({"group" = "ASC" ,"name" = "ASC"})
*/
protected $parameters;

View file

@ -94,6 +94,7 @@ class Storelocation extends AbstractPartsContainingDBElement
/** @var StorelocationParameter[]
* @ORM\OneToMany(targetEntity="App\Entity\Parameters\StorelocationParameter", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true)
* @ORM\OrderBy({"group" = "ASC" ,"name" = "ASC"})
* @Assert\Valid()
*/
protected $parameters;

View file

@ -116,6 +116,7 @@ class Supplier extends AbstractCompany
/** @var SupplierParameter[]
* @ORM\OneToMany(targetEntity="App\Entity\Parameters\SupplierParameter", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true)
* @ORM\OrderBy({"group" = "ASC" ,"name" = "ASC"})
* @Assert\Valid()
*/
protected $parameters;

View file

@ -96,6 +96,7 @@ class Currency extends AbstractStructuralDBElement
/** @var CurrencyParameter[]
* @ORM\OneToMany(targetEntity="App\Entity\Parameters\CurrencyParameter", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true)
* @ORM\OrderBy({"group" = "ASC" ,"name" = "ASC"})
* @Assert\Valid()
*/
protected $parameters;

View file

@ -95,6 +95,7 @@ class Group extends AbstractStructuralDBElement implements HasPermissionsInterfa
/** @var GroupParameter[]
* @ORM\OneToMany(targetEntity="App\Entity\Parameters\GroupParameter", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true)
* @ORM\OrderBy({"group" = "ASC" ,"name" = "ASC"})
* @Assert\Valid()
*/
protected $parameters;