mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-11-12 15:18:22 +00:00
Compare commits
1 Commits
v4.7.0
...
462-displa
| Author | SHA1 | Date | |
|---|---|---|---|
| f7ea7e4dbf |
6
.changes/unreleased/Feature-20251112-130016.yaml
Normal file
6
.changes/unreleased/Feature-20251112-130016.yaml
Normal file
@@ -0,0 +1,6 @@
|
||||
kind: Feature
|
||||
body: Display appointments (calendar items) linked to a person within the search results, like it was done for accompanying periods
|
||||
time: 2025-11-12T13:00:16.844313583+01:00
|
||||
custom:
|
||||
Issue: "462"
|
||||
SchemaChange: No schema change
|
||||
@@ -14,13 +14,13 @@ div.calendar-list {
|
||||
ul.calendar-list {
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
& > a.calendar-list__global {
|
||||
display: inline-block;
|
||||
padding: 0.2rem;
|
||||
min-width: 2rem;
|
||||
border: 1px solid var(--bs-chill-blue);
|
||||
border-radius: 0.25rem;
|
||||
text-align: center;
|
||||
}
|
||||
}
|
||||
|
||||
.calendar-list__global {
|
||||
display: inline-block;
|
||||
padding: 0.2rem;
|
||||
min-width: 2rem;
|
||||
border: 1px solid var(--bs-chill-blue);
|
||||
border-radius: 0.25rem;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
@@ -866,6 +866,29 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
|
||||
return $this->calendars;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get next calendars for this person.
|
||||
* Only returns calendars where this person is in the persons collection and the person property is not null.
|
||||
*
|
||||
* @param int $limit Maximum number of calendars to return
|
||||
*
|
||||
* @return ReadableCollection<int, Calendar>
|
||||
*/
|
||||
public function getNextCalendarsForPerson(int $limit = 5): ReadableCollection
|
||||
{
|
||||
$today = new \DateTimeImmutable('today');
|
||||
|
||||
$filtered = $this->calendars->filter(
|
||||
fn (Calendar $calendar) => $calendar->getStartDate() >= $today
|
||||
&& $calendar->getPerson() === $this
|
||||
);
|
||||
|
||||
$sorted = $filtered->toArray();
|
||||
usort($sorted, fn ($a, $b) => $a->getStartDate() <=> $b->getStartDate());
|
||||
|
||||
return new ArrayCollection(array_slice($sorted, 0, $limit));
|
||||
}
|
||||
|
||||
public function getCenter(): ?Center
|
||||
{
|
||||
if (null !== $this->centerCurrent) {
|
||||
|
||||
@@ -189,7 +189,43 @@
|
||||
{% endfor %}
|
||||
</li>
|
||||
{% endif %}
|
||||
|
||||
{% set calendars = [] %}
|
||||
{% for c in person.getNextCalendarsForPerson(10) %}
|
||||
{% if is_granted('CHILL_CALENDAR_CALENDAR_SEE', c) %}
|
||||
{% set calendars = calendars|merge([c]) %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
|
||||
{% if calendars|length > 0 %}
|
||||
<div class="d-flex align-items-center justify-content-between flex-wrap gap-3 mt-3">
|
||||
<h5 class="mb-0">{{ 'chill_calendar.Next calendars'|trans }}</h5>
|
||||
|
||||
<ul class="list-inline mb-0 d-flex flex-wrap align-items-center">
|
||||
{% for c in calendars %}
|
||||
<li class="list-inline-item">
|
||||
{% if is_granted('CHILL_CALENDAR_CALENDAR_EDIT', c) %}
|
||||
<a href="{{ chill_path_add_return_path('chill_calendar_calendar_edit', { id: c.id }) }}">
|
||||
<span class="badge bg-secondary">
|
||||
{{ c.startDate|format_datetime('long', 'short') }}
|
||||
</span>
|
||||
</a>
|
||||
{% else %}
|
||||
<span class="badge bg-secondary">
|
||||
{{ c.startDate|format_datetime('long', 'short') }}
|
||||
</span>
|
||||
{% endif %}
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% if is_granted('CHILL_CALENDAR_CALENDAR_SEE', person) %}
|
||||
<a href="{{ chill_path_add_return_path('chill_calendar_calendar_list_by_person', {'id': person.id}) }}" class="calendar-list__global"><i class="fa fa-list"></i></a>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endif %}
|
||||
</ul>
|
||||
</div>
|
||||
<div class="item-col">
|
||||
<ul class="record_actions">
|
||||
{% if options['customButtons']['before'] is defined %}
|
||||
{{ options['customButtons']['before'] }}
|
||||
|
||||
Reference in New Issue
Block a user