Configurable activity and project number (#4729)

* added configurable activity number
* added configurable project number
* fix deprecations
* added some tests for entity exporter
* better configuration of dropdown pattern for customer, project and activity
This commit is contained in:
Kevin Papst
2024-04-04 17:43:22 +02:00
committed by GitHub
parent c1f5d3def4
commit a636683dee
55 changed files with 920 additions and 136 deletions

View File

@@ -10,6 +10,7 @@
namespace App\Entity;
use App\Export\Annotation as Exporter;
use App\Validator\Constraints as Constraints;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
@@ -26,8 +27,9 @@ use Symfony\Component\Validator\Constraints as Assert;
#[Serializer\ExclusionPolicy('all')]
#[Serializer\VirtualProperty('ProjectName', exp: 'object.getProject() === null ? null : object.getProject().getName()', options: [new Serializer\SerializedName('parentTitle'), new Serializer\Type(name: 'string'), new Serializer\Groups(['Activity'])])]
#[Serializer\VirtualProperty('ProjectAsId', exp: 'object.getProject() === null ? null : object.getProject().getId()', options: [new Serializer\SerializedName('project'), new Serializer\Type(name: 'integer'), new Serializer\Groups(['Activity', 'Team', 'Not_Expanded'])])]
#[Exporter\Order(['id', 'name', 'project', 'budget', 'timeBudget', 'budgetType', 'color', 'visible', 'comment', 'billable'])]
#[Exporter\Order(['id', 'name', 'project', 'budget', 'timeBudget', 'budgetType', 'color', 'visible', 'comment', 'billable', 'number'])]
#[Exporter\Expose(name: 'project', label: 'project', exp: 'object.getProject() === null ? null : object.getProject().getName()')]
#[Constraints\Activity]
class Activity implements EntityWithMetaFields, EntityWithBudget
{
use BudgetTrait;
@@ -109,6 +111,12 @@ class Activity implements EntityWithMetaFields, EntityWithBudget
private Collection $teams;
#[ORM\Column(name: 'invoice_text', type: 'text', nullable: true)]
private ?string $invoiceText = null;
#[ORM\Column(name: 'number', type: 'string', length: 10, nullable: true)]
#[Assert\Length(max: 10)]
#[Serializer\Expose]
#[Serializer\Groups(['Default'])]
#[Exporter\Expose(label: 'activity_number')]
private ?string $number = null;
public function __construct()
{
@@ -269,6 +277,16 @@ class Activity implements EntityWithMetaFields, EntityWithBudget
$this->invoiceText = $invoiceText;
}
public function setNumber(?string $number): void
{
$this->number = $number;
}
public function getNumber(): ?string
{
return $this->number;
}
public function __toString(): string
{
return $this->getName();
@@ -276,7 +294,7 @@ class Activity implements EntityWithMetaFields, EntityWithBudget
public function __clone()
{
if ($this->id) {
if ($this->id !== null) {
$this->id = null;
}