Files
myep-team/templates/administrative/assignment/timeline.html.twig
T

142 lines
8.2 KiB
Twig

{% extends 'administrative/layout.html.twig' %}
{% block title %}Zeitleiste{% endblock %}
{% set state_labels = { open: 'offen', pending: 'in Bewerbung', staffed: 'besetzt' } %}
{% macro bar(item, row, state_labels) %}
{% set is_disposition = item.type == 'disposition' %}
<div class="timeline-bar timeline-bar--{{ item.state }}"
style="grid-row: {{ row }}; grid-column: {{ item.column + 1 }} / span {{ item.span }}"
title="{{ item.jobProfile }}{{ is_disposition ? ' · ' ~ item.teamerName }} · {{ item.dateRange }} · {{ state_labels[item.state] }}">
<span class="sr-only">{{ state_labels[item.state] }}:</span>
{% if not is_disposition and item.state == 'open' %}
<span class="font-bold uppercase">offen</span>
{% endif %}
{% if is_granted('ROLE_HOUSE_MANAGER') %}
<span class="truncate">{{ item.jobProfile }}</span>
{% else %}
<a href="{{ path('app_administrative_assignment_detail', { 'uuid': item.assignmentUuid, 'r': return_url() }) }}"
class="truncate hover:underline">{{ item.jobProfile }}</a>
{% endif %}
{% if is_disposition %}
<span aria-hidden="true">·</span>
<button type="button"
class="truncate font-bold hover:underline"
title="Teamer:inneninfo {{ item.teamerName }}"
hx-get="{{ path('app_administrative_teamer_info', { 'uuid': item.teamerUuid, 'r': return_url() }) }}"
hx-target="body"
hx-swap="beforeend">{{ item.teamerName }}</button>
{% endif %}
</div>
{% endmacro %}
{% block content %}
<div {{ stimulus_controller('timeline-scroll') }}>
<div class="flex items-start justify-between pb-4">
<h1 class="text-2xl font-bold">
Zeitleiste
</h1>
<div class="flex flex-col items-end space-y-2 md:flex-row md:items-center md:space-x-2 md:space-y-0">
<button type="button"
class="btn btn--small btn--secondary"
{{ stimulus_action('timeline-scroll', 'scrollToToday') }}>
{{ icon('calendar', 'w-4 h-4 shrink-0') }}
<span>Heute</span>
</button>
<button type="button"
class="{{ html_classes('btn btn--small', { 'btn--secondary': filterDto.active }) }}"
title="Filter"
hx-get="{{ path('app_common_timeline_filter', { 'r': return_url() }) }}"
hx-target="body"
hx-swap="beforeend">
{{ icon('filter', 'w-4 h-4 shrink-0') }}
{% if filterDto.active %}
<span class="whitespace-nowrap">{{ filterDto.activeFiltersCount }} Filter aktiv</span>
{% else %}
<span>Filter</span>
{% endif %}
</button>
{% if filterDto.active %}
<a href="{{ path('app_common_timeline_filter_reset', { 'r': return_url() }) }}" class="btn btn--small btn--secondary">
Reset
</a>
{% endif %}
</div>
</div>
{% if houses is empty %}
<div class="card p-4 mb-4 text-muted">Keine Ergebnisse</div>
{% else %}
<div class="timeline card mb-4"
style="--timeline-days: {{ calendar.days|length }}"
{{ stimulus_target('timeline-scroll', 'scroller') }}
{{ stimulus_action('timeline-scroll', 'startDrag', 'pointerdown')|stimulus_action('timeline-scroll', 'moveDrag', 'pointermove')|stimulus_action('timeline-scroll', 'endDrag', 'pointerup')|stimulus_action('timeline-scroll', 'endDrag', 'pointercancel')|stimulus_action('timeline-scroll', 'preventNativeDrag', 'dragstart') }}>
<div class="relative w-max min-w-full">
{# weekends, month boundaries and today, behind the bars #}
<div class="timeline-grid timeline-background" aria-hidden="true">
{% for day in calendar.days %}
{% if day.weekend or day.today or day.monthStart %}
<div class="{{ html_classes({
'bg-page': day.weekend,
'border-l border-slate-300': day.monthStart and day.column > 1,
}) }}" style="grid-column: {{ day.column + 1 }}">
{% if day.today %}
<div class="mx-auto h-full w-0.5 bg-brand-bright"></div>
{% endif %}
</div>
{% endif %}
{% endfor %}
</div>
<div class="timeline-grid timeline-header">
<div class="timeline-corner" style="grid-row: 1 / span 2"></div>
{% for month in calendar.months %}
<div class="{{ html_classes('truncate px-2 py-1 text-xs font-bold uppercase tracking-wide text-brand', { 'border-l border-slate-300': not loop.first }) }}"
style="grid-row: 1; grid-column: {{ month.column + 1 }} / span {{ month.span }}">
{{ month.label }}
</div>
{% endfor %}
{% for day in calendar.days %}
<div class="{{ html_classes('flex flex-col items-center py-1 text-[11px] leading-tight', {
'text-muted': day.weekend and not day.today,
'bg-brand-bright text-white font-bold': day.today,
}) }}"
style="grid-row: 2; grid-column: {{ day.column + 1 }}"
{% if day.today %}{{ stimulus_target('timeline-scroll', 'today') }}{% endif %}>
<span class="font-bold">{{ day.date.day }}</span>
<span>{{ day.date.isoFormat('dd') }}</span>
</div>
{% endfor %}
</div>
{% for house in houses %}
<div class="timeline-grid timeline-house">
<div class="timeline-house-label" style="grid-row: 1 / span {{ house.rows|length }}">
<span class="block truncate font-bold">{{ house.name ?? house.code }}</span>
<span class="block text-xs text-muted">
{{ house.code }}{% if house.openSlots > 0 %} · <span class="font-bold text-ink">{{ house.openSlots }} offen</span>{% endif %}
</span>
</div>
{% for row in house.rows %}
{% set row_number = loop.index %}
{% for item in row %}
{{ _self.bar(item, row_number, state_labels) }}
{% endfor %}
{% endfor %}
</div>
{% endfor %}
</div>
</div>
{% endif %}
<ul class="flex flex-wrap gap-x-6 gap-y-2 text-xs" aria-label="Legende">
<li class="flex items-center gap-x-2"><span class="timeline-bar timeline-bar--staffed w-10 h-5"></span> besetzt</li>
<li class="flex items-center gap-x-2"><span class="timeline-bar timeline-bar--pending w-10 h-5"></span> in Bewerbung oder Vertrag in Prüfung</li>
<li class="flex items-center gap-x-2"><span class="timeline-bar timeline-bar--open w-10 h-5"></span> offen, noch keine Bewerbung</li>
<li class="flex items-center gap-x-2"><span class="inline-block h-5 w-0.5 bg-brand-bright"></span> heute</li>
<li class="text-muted sm:ml-auto">Mit gedrückter Maustaste lässt sich die Zeitleiste verschieben</li>
</ul>
</div>
{% endblock %}