layout for filter on the list page

This commit is contained in:
Julien Fastré 2022-07-01 15:16:21 +02:00
parent f513749780
commit 3dcec5d44a
5 changed files with 7 additions and 5 deletions

View File

@ -427,7 +427,7 @@ class CalendarController extends AbstractController
private function buildListFilterOrder(): FilterOrderHelper
{
$filterOrder = $this->filterOrderHelperFactory->create(self::class);
$filterOrder->addDateRange('startDate', 'chill_calendar.start date filter', new DateTimeImmutable('3 days ago'), null);
$filterOrder->addDateRange('startDate', null, new DateTimeImmutable('3 days ago'), null);
return $filterOrder->build();
}

View File

@ -77,7 +77,7 @@ final class FilterOrderType extends \Symfony\Component\Form\AbstractType
foreach ($helper->getDateRanges() as $name => $opts) {
$rangeBuilder = $dateRangesBuilder->create($name, null, [
'compound' => true,
'label' => $opts['label'] ?? $name,
'label' => null === $opts['label'] ? false : $opts['label'] ?? $name,
]);
$rangeBuilder->add(

View File

@ -13,10 +13,12 @@
{% if form.dateRanges is defined %}
{% if form.dateRanges|length > 0 %}
{% for dateRangeName, _o in form.dateRanges %}
<div class="row gx-2">
<div class="row gx-2 justify-content-center">
{% if form.dateRanges[dateRangeName].vars.label is not same as(false) %}
<div class="col-md-5">
{{ form_label(form.dateRanges[dateRangeName])}}
</div>
{% endif %}
<div class="col-md-6">
<div class="input-group mb-3">
<span class="input-group-text">{{ 'chill_calendar.From'|trans }}</span>

View File

@ -63,7 +63,7 @@ class FilterOrderHelper
return $this;
}
public function addDateRange(string $name, string $label, ?DateTimeImmutable $from = null, ?DateTimeImmutable $to = null): self
public function addDateRange(string $name, ?string $label = null, ?DateTimeImmutable $from = null, ?DateTimeImmutable $to = null): self
{
$this->dateRanges[$name] = ['from' => $from, 'to' => $to, 'label' => $label];

View File

@ -42,7 +42,7 @@ class FilterOrderHelperBuilder
return $this;
}
public function addDateRange(string $name, string $label, ?DateTimeImmutable $from = null, ?DateTimeImmutable $to = null): self
public function addDateRange(string $name, ?string $label = null, ?DateTimeImmutable $from = null, ?DateTimeImmutable $to = null): self
{
$this->dateRanges[$name] = ['from' => $from, 'to' => $to, 'label' => $label];