{% set searchable = _args.searchable is defined ? _args.searchable is same as(true) : true %}
{% set headers = _args.headers|default([
{
title: 'Message',
sort: 'message',
},
{
title: 'Type',
spacing: 10,
sort: 'type',
},
{
title: 'Errors',
},
{
title: 'Contacts',
},
{
title: 'Last Modified',
spacing: 15,
sort: 'timestamp',
},
]) %}
{% embed searchable ? '@ui2022/table--search.html.twig' : '@ui2022/table--plain.html.twig' with {
form: form|default(null),
headers: headers,
pagination: pagination|default(null),
} %}
{% block items %}
{% if messages is empty %}
{% include '@ui2022/table__empty.html.twig' with {
title: 'No messages found',
message: 'No messages matching the criteria were found in the system.'
} %}
{% else %}
{% for message in messages %}
{% set clone = constant('DISCR', message) is same as(constant('Products\\NotificationsBundle\\Entity\\Notifications\\Message::DISCR')) %}
{% set delete = message.draft or is_granted('campussuite.root') %}
{% set isGranted = message.id in messagesIsGrantedArray %}
{% set actions = [] %}
{% if isGranted %}
{% set actions = [
(message.draft) ? {
text: 'Edit',
link: path('app.notifications.dashboard.messages.update', {
message: message.id,
}),
} : null,
(message.scheduled) ? {
text: 'Cancel',
link: path('app.notifications.dashboard.messages.unschedule', {
message: message.id,
}),
modal: 'modal__result_unschedule',
} : null,
(message.sending or message.complete) ? {
text: 'Report',
link: path('app.notifications.dashboard.messages.report', {
message: message.id,
})
} : null,
(clone or delete) ? {
text: 'More',
dropdown: {
items: [
clone ? {
text: 'Clone',
link: path('app.notifications.dashboard.messages.create', {
clone: message.id,
})
} : null,
delete ? {
text: 'Delete',
link: path('app.notifications.dashboard.messages.delete', {
message: message.id,
}),
modal: 'modal__result_delete',
} : null,
],
},
}: null,
]|filter((action) => action) %}
{% endif %}
<tr>
{% include '@ui2022/table__item__cell--status.html.twig' with {
title: message.title,
link: isGranted ? first_of(
{
(path('app.notifications.dashboard.messages.update', {
message: message.id
})): message.draft,
},
path('app.notifications.dashboard.messages.report', {
message: message.id
})
) : null,
status: first_of({
'danger': message.error,
'draft': message.draft,
'scheduled': message.ready,
'sending': message.sending,
'sent': message.complete,
}),
subtext: '%s — by %s'|format(
first_of({
'Error': message.error,
'Draft': message.draft,
('Scheduled %s'|format(message.scheduledAt|ui_datetime)|trim): message.ready,
'Sending': message.sending,
('Sent (Scheduled %s)'|format(message.scheduledAt|ui_datetime)): message.complete and message.scheduledAt,
'Sent': message.complete,
}),
message.touchedBy ? message.touchedBy.displayName : 'SYSTEM'
),
actions: actions,
} %}
<td>
{{- 'app.notifications.messages.types.%s'|format((message.urgent) ? 'urgent' : 'general')|trans -}}
</td>
<td>
{{- (message.firstJob) ? ((message.firstJob.error ? 1 : 0) + message.firstJob.messagesFailed + message.firstJob.messagesUndelivered) : '—' -}}
</td>
<td>
{{- (message.firstJob) ? message.firstJob.messagesTotal : '—' -}}
</td>
<td>
{{- message.timestampedAt|ui_relativeDate -}}
</td>
</tr>
{% endfor %}
{% endif %}
{% endblock %}
{% endembed %}