fix: correctly assign items to timeline
This commit is contained in:
@@ -36,7 +36,7 @@ class TimelineFilterController extends AbstractController
|
||||
|
||||
if ($form->isSubmitted() && $form->isValid()) {
|
||||
$this->filterHandler->handleRequest($form);
|
||||
$returnUrl = $this->getReturnUrl($request, 'app_administrative_assignment_timeline');
|
||||
$returnUrl = $this->getReturnUrl($request, 'app_administrative_timeline');
|
||||
|
||||
return new HxRedirectResponse($returnUrl);
|
||||
}
|
||||
@@ -51,7 +51,7 @@ class TimelineFilterController extends AbstractController
|
||||
public function reset(Request $request): Response
|
||||
{
|
||||
$this->filterHandler->resetFilterSettings();
|
||||
$returnUrl = $this->getReturnUrl($request, 'app_administrative_assignment_timeline');
|
||||
$returnUrl = $this->getReturnUrl($request, 'app_administrative_timeline');
|
||||
|
||||
return $this->redirect($returnUrl);
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ class TimelineItem
|
||||
public const TYPE_ASSIGNMENT = 'assignment';
|
||||
public const TYPE_DISPOSITION = 'disposition';
|
||||
|
||||
private ?int $dispositionId = null;
|
||||
private ?\DateTimeImmutable $dateFrom = null;
|
||||
private ?\DateTimeImmutable $dateTo = null;
|
||||
private ?string $status = null;
|
||||
@@ -44,6 +45,7 @@ class TimelineItem
|
||||
$dateTo = $assignment->getDestination()->getDateTo();
|
||||
|
||||
return (new static($assignment->getId(), static::TYPE_DISPOSITION))
|
||||
->setDispositionId($disposition->getId())
|
||||
->setDateFrom($dateFrom)
|
||||
->setDateTo($dateTo)
|
||||
->setJobProfile($assignment->getJobProfile()->getName())
|
||||
@@ -64,6 +66,18 @@ class TimelineItem
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
public function getDispositionId(): ?int
|
||||
{
|
||||
return $this->dispositionId;
|
||||
}
|
||||
|
||||
public function setDispositionId(?int $dispositionId): static
|
||||
{
|
||||
$this->dispositionId = $dispositionId;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getDateFrom(): ?\DateTimeImmutable
|
||||
{
|
||||
return $this->dateFrom;
|
||||
|
||||
@@ -41,33 +41,24 @@ class TimelineService
|
||||
|
||||
private function addItem(array &$rows, TimelineItem $item): void
|
||||
{
|
||||
$itemAdded = false;
|
||||
$rowIndex = 0;
|
||||
|
||||
foreach ($rows as $index => $row) {
|
||||
$addToRow = true;
|
||||
|
||||
$fitsRow = true;
|
||||
foreach ($row as $entry) {
|
||||
/** @var TimelineItem $entry */
|
||||
if (
|
||||
$item->getDateFrom() >= $entry->getDateFrom() && $item->getDateFrom() <= $entry->getDateTo()
|
||||
|| $item->getDateTo() >= $entry->getDateFrom() && $item->getDateTo() <= $entry->getDateTo()
|
||||
) {
|
||||
$addToRow = false;
|
||||
if ($entry->getDateTo() >= $item->getDateFrom() && $entry->getDateFrom() <= $item->getDateTo()) {
|
||||
$fitsRow = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (true === $addToRow) {
|
||||
$rows[$index][$item->getKey()] = $item;
|
||||
$itemAdded = true;
|
||||
break;
|
||||
}
|
||||
$rowIndex = $index;
|
||||
}
|
||||
|
||||
if (false === $itemAdded) {
|
||||
$rows[] = [
|
||||
$item->getKey() => $item,
|
||||
];
|
||||
if (false === $fitsRow) {
|
||||
++$rowIndex;
|
||||
}
|
||||
|
||||
$rows[$rowIndex][$item->getKey()] = $item;
|
||||
}
|
||||
|
||||
public function getActiveWindow(): CarbonPeriod
|
||||
|
||||
@@ -2,35 +2,27 @@
|
||||
|
||||
{% block title %}Zeitleiste{% endblock %}
|
||||
|
||||
{% macro cell(row, day) %}
|
||||
{% if colspan is defined and colspan > 1 %}
|
||||
{% set colspan = colspan - 1 %}
|
||||
{% elseif row[day|date('Ymd')] is defined %}
|
||||
{% set item = row[day|date('Ymd')] %}
|
||||
{% set colspan = item.numberOfDays %}
|
||||
<td class="{{ html_classes('border border-gray-700', {
|
||||
'bg-gray-100': item.type == 'assignment',
|
||||
'bg-blue-500 text-gray-50': item.type == 'disposition' and item.status != 'confirmed',
|
||||
'bg-green-500 text-gray-50': item.type == 'disposition' and item.status == 'confirmed',
|
||||
}) }}" colspan="{{ colspan }}">
|
||||
{% if item.type == 'disposition' %}
|
||||
<button type="button"
|
||||
class="flex items-center space-x-2"
|
||||
title="Teamer:inneninfo {{ item.teamerName }}"
|
||||
hx-get="{{ path('app_administrative_teamer_info', { 'uuid': item.teamerUuid }) }}"
|
||||
hx-target="body"
|
||||
hx-swap="beforeend">
|
||||
<span class="text-xs font-semibold">{{ item.jobProfile }}</span>
|
||||
<span class="text-xs">{{ item.teamerName | raw }}</span>
|
||||
{{ icon('info', 'w-4 h-4') }}
|
||||
</button>
|
||||
{% else %}
|
||||
{% macro cell(item, colspan) %}
|
||||
<td class="{{ html_classes('border border-gray-700', {
|
||||
'bg-gray-100': item.type == 'assignment',
|
||||
'bg-blue-500 text-gray-50': item.type == 'disposition' and item.status != 'confirmed',
|
||||
'bg-green-500 text-gray-50': item.type == 'disposition' and (item.status == 'confirmed' or item.status == 'ended' or item.status == 'completed'),
|
||||
}) }}" colspan="{{ colspan }}">
|
||||
{% if item.type == 'disposition' %}
|
||||
<button type="button"
|
||||
class="flex items-center space-x-2"
|
||||
title="Teamer:inneninfo {{ item.teamerName }}"
|
||||
hx-get="{{ path('app_administrative_teamer_info', { 'uuid': item.teamerUuid }) }}"
|
||||
hx-target="body"
|
||||
hx-swap="beforeend">
|
||||
<span class="text-xs font-semibold">{{ item.jobProfile }}</span>
|
||||
{% endif %}
|
||||
</td>
|
||||
{% else %}
|
||||
<td class="border border-gray-700"></td>
|
||||
{% endif %}
|
||||
<span class="text-xs">{{ item.teamerName | raw }}</span>
|
||||
{{ icon('info', 'w-4 h-4') }}
|
||||
</button>
|
||||
{% else %}
|
||||
<span class="text-xs font-semibold">{{ item.jobProfile }}</span>
|
||||
{% endif %}
|
||||
</td>
|
||||
{% endmacro %}
|
||||
|
||||
{% block content %}
|
||||
@@ -75,13 +67,29 @@
|
||||
{{ hotelCode }}
|
||||
</td>
|
||||
{% for day in filterDto.period %}
|
||||
{{ _self.cell(rows[0], day) }}
|
||||
{% if colspan is defined and colspan > 1 %}
|
||||
{% set colspan = colspan - 1 %}
|
||||
{% elseif rows[0][day|date('Ymd')] is defined %}
|
||||
{% set item = rows[0][day|date('Ymd')] %}
|
||||
{% set colspan = item.numberOfDays %}
|
||||
{{ _self.cell(item, colspan) }}
|
||||
{% else %}
|
||||
<td class="border border-gray-700"></td>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</tr>
|
||||
{% for row in rows[1:] %}
|
||||
<tr>
|
||||
{% for day in filterDto.period %}
|
||||
{{ _self.cell(row, day) }}
|
||||
{% if colspan is defined and colspan > 1 %}
|
||||
{% set colspan = colspan - 1 %}
|
||||
{% elseif row[day|date('Ymd')] is defined %}
|
||||
{% set item = row[day|date('Ymd')] %}
|
||||
{% set colspan = item.numberOfDays %}
|
||||
{{ _self.cell(item, colspan) }}
|
||||
{% else %}
|
||||
<td class="border border-gray-700"></td>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</tr>
|
||||
{% endfor %}
|
||||
|
||||
Reference in New Issue
Block a user