SPRA-4 fix mobile views

This commit is contained in:
2024-07-29 13:32:03 +02:00
parent 55b520bdfe
commit f54b6db693
4 changed files with 30 additions and 17 deletions
+4 -2
View File
@@ -44,12 +44,13 @@ class BaseController extends AbstractController
#[IsGranted('reportView')] #[IsGranted('reportView')]
public function reportsIndex(EntityManagerInterface $entityManager, int $monthId = 0) : Response public function reportsIndex(EntityManagerInterface $entityManager, int $monthId = 0) : Response
{ {
if ($this->getUser()) $isOverdue = false;
if ($monthId > -1) { if ($monthId > -1) {
$monthCurrent = $this->monthHelper->getCurrentMonth($monthId); $monthCurrent = $this->monthHelper->getCurrentMonth($monthId);
$reportsAll = $entityManager->getRepository(Reports::class)->findAllInMonth($monthCurrent); $reportsAll = $entityManager->getRepository(Reports::class)->findAllInMonth($monthCurrent);
} else { } else {
$reportsAll = $entityManager->getRepository(Reports::class)->findAllOverdue(); $reportsAll = $entityManager->getRepository(Reports::class)->findAllOverdue();
$isOverdue = true;
} }
$reports = []; $reports = [];
@@ -68,7 +69,8 @@ class BaseController extends AbstractController
'reportsGroup' => $reports, 'reportsGroup' => $reports,
'months' => $this->monthHelper->takeMonths(), 'months' => $this->monthHelper->takeMonths(),
'currentMonth' => $monthCurrent ?? null, 'currentMonth' => $monthCurrent ?? null,
'reportToDoList' => ReportTodoEnum::cases() 'reportToDoList' => ReportTodoEnum::cases(),
'isOverdue' => $isOverdue,
]); ]);
} }
} }
+1 -1
View File
@@ -8,7 +8,7 @@ class MonthHelper
$startDate = new \DateTime("-6 months"); $startDate = new \DateTime("-6 months");
$return = []; $return = [];
for ($i=1; $i<=12; $i++) { for ($i=1; $i<=11; $i++) {
$tmp = clone $startDate; $tmp = clone $startDate;
$tmp->modify("+$i month"); $tmp->modify("+$i month");
$return[$i] = $tmp; $return[$i] = $tmp;
@@ -1,18 +1,22 @@
{% macro month_menu(routeName, months, currentMonth) %} {% macro month_menu(routeName, months, currentMonth) %}
<div class="row row-cols-12 reports-months-all"> <div class="row reports-months-all">
<div class="col"> <div class="col">
<a href="{{ path(routeName, {monthId:-1}) }}" class="btn {% if currentMonth is null %}btn-success{% else %}btn-secondary{% endif %}">Zaległe</a> <div class="card">
<a href="{{ path(routeName, {monthId:-1}) }}" class="btn {% if currentMonth is null %}btn-success{% else %}btn-secondary{% endif %}">Zaległe</a>
</div>
</div> </div>
{% for id,month in months %} {% for id,month in months %}
{% set isCurrent = currentMonth is not null and month | date("Y-m") == currentMonth | date("Y-m") %} {% set isCurrent = currentMonth is not null and month | date("Y-m") == currentMonth | date("Y-m") %}
<div class="col"> <div class="col col-xxl-1 col-xl-2 col-lg-2 col-md-3 col-sm-3 col-4">
<a href="{{ path(routeName,{monthId: id}) }}" class="btn {% if isCurrent %}btn-success{% else %}btn-secondary{% endif %}"> <div class="card">
{% if routeName=='app_schedule' %} <a href="{{ path(routeName,{monthId: id}) }}" class="btn {% if isCurrent %}btn-success{% else %}btn-secondary{% endif %}">
{{ id }} {% if routeName=='app_schedule' %}
{% else %} {{ id }}
{{ month | date("Y-m") }} {% else %}
{% endif %} {{ month | date("Y-m") }}
</a> {% endif %}
</a>
</div>
</div> </div>
{% endfor %} {% endfor %}
</div> </div>
+10 -3
View File
@@ -2,9 +2,16 @@
{% import 'navigation/switch_months.html.twig' as navigation %} {% import 'navigation/switch_months.html.twig' as navigation %}
{% block body %} {% block body %}
{{ navigation.month_menu('app_base',months,currentMonth) }} {{ navigation.month_menu('app_base',months,currentMonth) }}
<div class="row row-cols-3 row-cols-md-3 g-3 reports-all"> <div class="
row
d-flex
row-cols-sm-1
row-cols-lg-3
justify-content-center
reports-all"
>
{% for id,reports in reportsGroup %} {% for id,reports in reportsGroup %}
<div class="status-row" style="{% if currentMonth is null and id == 3 %}display:none{% endif %}"> <div class="status-row" style="{% if isOverdue and id == 3 %}display:none{% endif %}">
<div class="col"> <div class="col">
<div class="card text-center text-white bg-dark"> <div class="card text-center text-white bg-dark">
<div class="card-title"><h2>{{ reports.status.takeLang }}</h2></div> <div class="card-title"><h2>{{ reports.status.takeLang }}</h2></div>
@@ -24,7 +31,7 @@
<form action="{{ path('app_set_status_todo') }}" method="post"> <form action="{{ path('app_set_status_todo') }}" method="post">
<input type="hidden" name="reportId" value="{{ report.id }}"> <input type="hidden" name="reportId" value="{{ report.id }}">
<input type="hidden" name="token" value="{{ csrf_token('report-status') }}"> <input type="hidden" name="token" value="{{ csrf_token('report-status') }}">
<div class="btn-group" role="group" aria-label="Test"> <div class="btn-group" role="group" aria-label="Todos">
{% for todo in reportToDoList %} {% for todo in reportToDoList %}
<input onchange="this.form.submit()" <input onchange="this.form.submit()"
name="{{ todo.value }}" name="{{ todo.value }}"