Skip to content

Commit 5a8ad51

Browse files
author
tchapi
committed
Add view on subscriptions in user calendars list
1 parent bbb9a36 commit 5a8ad51

File tree

3 files changed

+182
-146
lines changed

3 files changed

+182
-146
lines changed

src/Controller/Admin/CalendarController.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ public function calendars(ManagerRegistry $doctrine, UrlGeneratorInterface $rout
2727
$principal = $doctrine->getRepository(Principal::class)->findOneByUri(Principal::PREFIX.$username);
2828
$allCalendars = $doctrine->getRepository(CalendarInstance::class)->findByPrincipalUri(Principal::PREFIX.$username);
2929

30+
$subscriptions = $doctrine->getRepository(CalendarSubscription::class)->findByPrincipalUri(Principal::PREFIX.$username);
31+
3032
// Separate shared calendars
3133
$calendars = [];
3234
$shared = [];
@@ -49,6 +51,7 @@ public function calendars(ManagerRegistry $doctrine, UrlGeneratorInterface $rout
4951

5052
return $this->render('calendars/index.html.twig', [
5153
'calendars' => $calendars,
54+
'subscriptions' => $subscriptions,
5255
'shared' => $shared,
5356
'principal' => $principal,
5457
'username' => $username,

templates/calendars/index.html.twig

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
</div>
4141
</div>
4242
<p class="mb-1">{{ calendar.description }}</p>
43-
{% if calendar.calendar.components|split(',')|length > 0 %}
43+
<small>{% if calendar.calendar.components|split(',')|length > 0 %}
4444
{% if constant('\\App\\Entity\\Calendar::COMPONENT_EVENTS') in calendar.calendar.components %}<span class="badge bg-primary">{{ "calendars.component.events"|trans }}</span>{% endif %}
4545
{% if constant('\\App\\Entity\\Calendar::COMPONENT_NOTES') in calendar.calendar.components %}<span class="badge bg-info">{{ "calendars.component.notes"|trans }}</span>{% endif %}
4646
{% if constant('\\App\\Entity\\Calendar::COMPONENT_TODOS') in calendar.calendar.components %}<span class="badge bg-primary-subtle">{{ "calendars.component.todos"|trans }}</span>{% endif %}
@@ -98,7 +98,7 @@
9898
</div>
9999
</div>
100100
<p class="mb-1">{{ calendar.description }}</p>
101-
{% if calendar.calendar.components|split(',')|length > 0 %}
101+
<small>{% if calendar.calendar.components|split(',')|length > 0 %}
102102
{% if constant('\\App\\Entity\\Calendar::COMPONENT_EVENTS') in calendar.calendar.components %}<span class="badge bg-primary">{{ "calendars.component.events"|trans }}</span>{% endif %}
103103
{% if constant('\\App\\Entity\\Calendar::COMPONENT_NOTES') in calendar.calendar.components %}<span class="badge bg-info">{{ "calendars.component.notes"|trans }}</span>{% endif %}
104104
{% if constant('\\App\\Entity\\Calendar::COMPONENT_TODOS') in calendar.calendar.components %}<span class="badge bg-primary-subtle">{{ "calendars.component.todos"|trans }}</span>{% endif %}
@@ -121,6 +121,31 @@
121121
{% include '_partials/delete_modal.html.twig' with {flavour: 'revoke'} %}
122122
{% endif %}
123123

124+
125+
{% if subscriptions|length > 0 %}
126+
<h2 class="h4 mt-5 fw-lighter">{{ "calendars.subscriptions"|trans }}</h2>
127+
128+
<div class="list-group mt-3">
129+
{% for subscription in subscriptions %}
130+
<div class="list-group-item p-3">
131+
<div class="d-flex w-100 justify-content-between">
132+
<h5 class="mb-1 me-auto">
133+
{{ subscription.displayName }}
134+
<span class="badge bg-info ms-1">{{ ('calendar.subscription')|trans }}</span>
135+
<a href="#" tabindex="0" class="badge badge-indicator ms-1" role="button" data-bs-toggle="popover" data-bs-title="{{ 'calendars.setup.title'|trans }}" data-bs-html='true' data-bs-content="URI: <code>{{ subscription.uri }}</code>">ⓘ</a>
136+
<span class="badge badge-indicator" style="background-color: {{ subscription.calendarColor }}">&nbsp;</span>
137+
</h5>
138+
</div>
139+
<code class="mb-1">{{ subscription.source }}</code>
140+
141+
</div>
142+
{% endfor %}
143+
</div>
144+
145+
{% include '_partials/delete_modal.html.twig' with {flavour: 'revoke'} %}
146+
{% endif %}
147+
148+
124149
{% include '_partials/share_modal.html.twig' with {principals: allPrincipals} %}
125150
{% include '_partials/delete_modal.html.twig' with {flavour: 'calendars'} %}
126151

0 commit comments

Comments
 (0)