Feature: [calendar] convert calendar to activity in the context of a person

This commit is contained in:
Julien Fastré 2023-04-03 19:54:10 +02:00
parent 46e1891386
commit 4cf6721e35
Signed by: julienfastre
GPG Key ID: BDE2190974723FCB
2 changed files with 56 additions and 9 deletions

View File

@ -526,14 +526,20 @@ class CalendarController extends AbstractController
'comment' => $calendar->getComment()->getComment(),
];
return $this->redirectToRoute(
'chill_activity_activity_new',
[
'accompanying_period_id' => $calendar->getAccompanyingPeriod()->getId(),
'activityData' => $activityData,
'returnPath' => $request->query->get('returnPath', null),
]
);
$routeParams = [
'activityData' => $activityData,
'returnPath' => $request->query->get('returnPath', null),
];
if ($calendar->getContext() === 'accompanying_period'){
$routeParams['accompanying_period_id'] = $calendar->getAccompanyingPeriod()->getId();
} elseif ($calendar->getContext() === 'person') {
$routeParams['person_id'] = $calendar->getPerson()->getId();
} else {
throw new RuntimeException('context not found for this calendar');
}
return $this->redirectToRoute('chill_activity_activity_new', $routeParams);
}
private function buildListFilterOrder(): FilterOrderHelper

View File

@ -103,6 +103,42 @@
</div>
{% endif %}
{% if calendar.activity is not null %}
<div class="item-row separator">
<div class="item-col">
<div class="wrap-list">
<div class="wl-row">
<div class="wl-col title"><h3>{{ 'Activity'|trans }}</h3></div>
<div class="wl-col list activity-linked">
<h2 class="badge-title">
<span class="title_label"></span>
<span class="title_action">
{{ calendar.activity.type.name | localize_translatable_string }}
{% if calendar.activity.emergency %}
<span class="badge bg-danger rounded-pill fs-6 float-end">{{ 'Emergency'|trans|upper }}</span>
{% endif %}
</span>
</h2>
<ul class="record_actions">
<li class="cancel">
{{ 'Created by'|trans }} {{ calendar.activity.createdBy|chill_entity_render_string }}, {{ 'on'|trans }} {{ calendar.activity.createdAt|format_datetime('short', 'short') }}
</li>
{% if is_granted('CHILL_ACTIVITY_SEE', calendar.activity) %}
<li>
<a href="{{ chill_path_add_return_path('chill_activity_activity_show', {'id': calendar.activity.id}) }}" class="btn btn-sm btn-show" ></a>
</li>
{% endif %}
</ul>
</div>
</div>
</div>
</div>
</div>
{% endif %}
<div class="item-row separator column">
<div>
@ -147,7 +183,12 @@
</li>
{% endif %}
{% endif %}
{% if accompanyingCourse is defined and is_granted('CHILL_ACTIVITY_CREATE', accompanyingCourse) and calendar.activity is null %}
{% if calendar.activity is null and (
(calendar.context == 'accompanying_period' and is_granted('CHILL_ACTIVITY_CREATE', calendar.accompanyingPeriod))
or
(calendar.context == 'person' and is_granted('CHILL_ACTIVITY_CREATE', calendar.person))
)
%}
<li>
<a class="btn btn-create"
href="{{ chill_path_add_return_path('chill_calendar_calendar_to_activity', { 'id': calendar.id }) }}">