Skip to content

Commit

Permalink
2294: Added worker name
Browse files Browse the repository at this point in the history
  • Loading branch information
tuj committed Sep 6, 2024
1 parent 9e6815a commit ec562c4
Show file tree
Hide file tree
Showing 7 changed files with 70 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
31 changes: 31 additions & 0 deletions migrations/Version20240906102815.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

declare(strict_types=1);

namespace DoctrineMigrations;

use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;

/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20240906102815 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}

public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->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');
}
}
15 changes: 15 additions & 0 deletions src/Entity/Worker.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
}
Expand Down Expand Up @@ -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;
}
}
8 changes: 8 additions & 0 deletions src/Form/WorkerType.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
Expand Down
12 changes: 10 additions & 2 deletions src/Service/PlanningService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
) {
}

Expand Down Expand Up @@ -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,
];
}
}
Expand Down
2 changes: 2 additions & 0 deletions templates/worker/index.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
<tr>
<th class="table-th">{{ 'worker.id'|trans }}</th>
<th class="table-th">{{ 'worker.email'|trans }}</th>
<th class="table-th">{{ 'worker.name'|trans }}</th>
<th class="table-th">{{ 'worker.workload'|trans }}</th>
<th class="table-th">{{ 'worker.actions'|trans }}</th>
</tr>
Expand All @@ -24,6 +25,7 @@
<tr class="{{ index % 2 == 0 ? 'table-tr' : 'table-tr-alt' }}">
<td class="table-td">{{ worker.id }}</td>
<td class="table-td">{{ worker.email }}</td>
<td class="table-td">{{ worker.name }}</td>
<td class="table-td">{{ worker.workload }}</td>
<td class="table-td">
<a href="{{ path('app_worker_edit', {'id': worker.id}) }}">{{ 'worker.action_edit'|trans }}</a>
Expand Down
2 changes: 2 additions & 0 deletions translations/messages.da.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -725,13 +725,15 @@ worker:
title: 'Medarbejdere'
index_description: 'På denne side kan synkroniserede medarbejderes norm tid defineres'
id: 'Id'
name: 'Navn'
email: 'Email'
workload: 'Normtid (inkl. middagspause)'
actions: 'Handlinger'
action_edit: 'Rediger'
edit: 'Rediger medarbejder'
action_save: 'Gem'
back_to_list: "Tilbage til listen"
no_records_found: 'Ingen arbejdere'

workload_report_period_type_enum:
week:
Expand Down

0 comments on commit ec562c4

Please sign in to comment.