Switch dates to from/to range, sort by most recent end date
This commit is contained in:
parent
03099845a8
commit
7e6854da22
2 changed files with 16 additions and 22 deletions
|
|
@ -35,19 +35,23 @@ tabs:
|
||||||
columns:
|
columns:
|
||||||
name:
|
name:
|
||||||
width: 1/2
|
width: 1/2
|
||||||
dates:
|
from:
|
||||||
width: 1/2
|
width: 1/4
|
||||||
|
to:
|
||||||
|
width: 1/4
|
||||||
fields:
|
fields:
|
||||||
name:
|
name:
|
||||||
label: Lieu
|
label: Lieu
|
||||||
placeholder: Théâtre-Sénart, Scène Nationale, Lieusaint
|
placeholder: Théâtre-Sénart, Scène Nationale, Lieusaint
|
||||||
type: text
|
type: text
|
||||||
dates:
|
from:
|
||||||
label: Dates
|
label: Du
|
||||||
type: structure
|
type: date
|
||||||
fields:
|
display: DD/MM/YYYY
|
||||||
date:
|
width: 1/2
|
||||||
label: Date
|
to:
|
||||||
type: date
|
label: Au
|
||||||
display: DD/MM/YYYY
|
type: date
|
||||||
|
display: DD/MM/YYYY
|
||||||
|
width: 1/2
|
||||||
files: tabs/files
|
files: tabs/files
|
||||||
|
|
|
||||||
|
|
@ -7,20 +7,10 @@ class EventPage extends Page
|
||||||
$groups = array_values($this->dates()->toStructure()->data());
|
$groups = array_values($this->dates()->toStructure()->data());
|
||||||
|
|
||||||
usort($groups, fn($a, $b) => strcmp(
|
usort($groups, fn($a, $b) => strcmp(
|
||||||
$this->firstDateOf($a),
|
$b->to()->value() ?? '',
|
||||||
$this->firstDateOf($b)
|
$a->to()->value() ?? ''
|
||||||
));
|
));
|
||||||
|
|
||||||
return $groups;
|
return $groups;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function firstDateOf($group): string
|
|
||||||
{
|
|
||||||
$dates = array_filter(array_map(
|
|
||||||
fn($item) => $item->date()->value(),
|
|
||||||
array_values($group->dates()->toStructure()->data())
|
|
||||||
));
|
|
||||||
|
|
||||||
return !empty($dates) ? min($dates) : '';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue