From ec562c4673ea457417b1b7ac810b717788c39fe7 Mon Sep 17 00:00:00 2001 From: Troels Ugilt Jensen <6103205+tuj@users.noreply.github.com> Date: Fri, 6 Sep 2024 12:47:57 +0200 Subject: [PATCH] 2294: Added worker name --- CHANGELOG.md | 2 ++ migrations/Version20240906102815.php | 31 ++++++++++++++++++++++++++++ src/Entity/Worker.php | 15 ++++++++++++++ src/Form/WorkerType.php | 8 +++++++ src/Service/PlanningService.php | 12 +++++++++-- templates/worker/index.html.twig | 2 ++ translations/messages.da.yaml | 2 ++ 7 files changed, 70 insertions(+), 2 deletions(-) create mode 100644 migrations/Version20240906102815.php diff --git a/CHANGELOG.md b/CHANGELOG.md index a666b0df..9d34faaa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +* [PR-154](https://github.com/itk-dev/economics/pull/154) + 2294: Added worker name field and added to planning overview. * [PR-153](https://github.com/itk-dev/economics/pull/153) 2265: Changed X column in external exported csv. diff --git a/migrations/Version20240906102815.php b/migrations/Version20240906102815.php new file mode 100644 index 00000000..e1191ad4 --- /dev/null +++ b/migrations/Version20240906102815.php @@ -0,0 +1,31 @@ +addSql('ALTER TABLE worker ADD name VARCHAR(255) DEFAULT NULL'); + } + + public function down(Schema $schema): void + { + // this down() migration is auto-generated, please modify it to your needs + $this->addSql('ALTER TABLE worker DROP name'); + } +} diff --git a/src/Entity/Worker.php b/src/Entity/Worker.php index 18763774..8d6aa3c1 100644 --- a/src/Entity/Worker.php +++ b/src/Entity/Worker.php @@ -20,6 +20,9 @@ class Worker #[ORM\Column(length: 180, nullable: true)] private ?float $workload = null; + #[ORM\Column(length: 255, nullable: true)] + private ?string $name = null; + public function __construct() { } @@ -62,4 +65,16 @@ public function getUserIdentifier(): string { return (string) $this->email; } + + public function getName(): ?string + { + return $this->name; + } + + public function setName(?string $name): static + { + $this->name = $name; + + return $this; + } } diff --git a/src/Form/WorkerType.php b/src/Form/WorkerType.php index e2f21950..b7f2cb67 100644 --- a/src/Form/WorkerType.php +++ b/src/Form/WorkerType.php @@ -21,6 +21,14 @@ public function buildForm(FormBuilderInterface $builder, array $options): void 'required' => false, 'row_attr' => ['class' => 'form-row'], ]) + ->add('name', TextType::class, [ + 'label' => 'worker.name', + 'label_attr' => ['class' => 'label'], + 'attr' => ['class' => 'form-element'], + 'help_attr' => ['class' => 'form-help'], + 'required' => false, + 'row_attr' => ['class' => 'form-row'], + ]) ->add('workload', TextType::class, [ 'label' => 'worker.workload', 'label_attr' => ['class' => 'label'], diff --git a/src/Service/PlanningService.php b/src/Service/PlanningService.php index f1f16a86..2ce476bf 100644 --- a/src/Service/PlanningService.php +++ b/src/Service/PlanningService.php @@ -10,6 +10,7 @@ use App\Model\Planning\SprintSum; use App\Model\Planning\Weeks; use App\Repository\IssueRepository; +use App\Repository\WorkerRepository; use Doctrine\Common\Collections\ArrayCollection; class PlanningService @@ -18,7 +19,7 @@ public function __construct( private readonly DateTimeHelper $dateTimeHelper, private readonly IssueRepository $issueRepository, protected readonly float $weekGoalLow, - protected readonly float $weekGoalHigh, + protected readonly float $weekGoalHigh, private readonly WorkerRepository $workerRepository, ) { } @@ -212,10 +213,17 @@ private function getAssigneeData(mixed $issue): array ]; } else { $assigneeKey = (string) $issue->getWorker(); + $assigneeName = $assigneeKey; + + $worker = $this->workerRepository->findOneBy(['email' => $assigneeKey]); + + if ($worker !== null && $worker->getName() !== null) { + $assigneeName = $worker->getName(); + } return [ 'key' => $assigneeKey, - 'displayName' => $assigneeKey, + 'displayName' => $assigneeName, ]; } } diff --git a/templates/worker/index.html.twig b/templates/worker/index.html.twig index 58722f80..aa460a87 100644 --- a/templates/worker/index.html.twig +++ b/templates/worker/index.html.twig @@ -15,6 +15,7 @@