src/Products/NotificationsBundle/Resources/views/dashboard/messages/includes/_results.html.twig line 1

Open in your IDE?
  1. {% set searchable = _args.searchable is defined ? _args.searchable is same as(true) : true %}
  2. {% set headers = _args.headers|default([
  3.     {
  4.         title: 'Message',
  5.         sort: 'message',
  6.     },
  7.     {
  8.         title: 'Type',
  9.         spacing: 10,
  10.         sort: 'type',
  11.     },
  12.     {
  13.         title: 'Errors',
  14.     },
  15.     {
  16.         title: 'Contacts',
  17.     },
  18.     {
  19.         title: 'Last Modified',
  20.         spacing: 15,
  21.         sort: 'timestamp',
  22.     },
  23. ]) %}
  24. {% embed searchable ? '@ui2022/table--search.html.twig' : '@ui2022/table--plain.html.twig' with {
  25.     form: form|default(null),
  26.     headers: headers,
  27.     pagination: pagination|default(null),
  28. } %}
  29.     {% block items %}
  30.         {% if messages is empty %}
  31.             {% include '@ui2022/table__empty.html.twig' with {
  32.                 title: 'No messages found',
  33.                 message: 'No messages matching the criteria were found in the system.'
  34.             } %}
  35.         {% else %}
  36.             {% for message in messages %}
  37.                 {% set clone = constant('DISCR', message) is same as(constant('Products\\NotificationsBundle\\Entity\\Notifications\\Message::DISCR')) %}
  38.                 {% set delete = message.draft or is_granted('campussuite.root') %}
  39.                 {% set isGranted = message.id in messagesIsGrantedArray %}
  40.                 {% set actions = [] %}
  41.                 {% if isGranted %}
  42.                     {% set actions = [
  43.                     (message.draft) ? {
  44.                         text: 'Edit',
  45.                         link: path('app.notifications.dashboard.messages.update', {
  46.                             message: message.id,
  47.                         }),
  48.                     } : null,
  49.                     (message.scheduled) ? {
  50.                         text: 'Cancel',
  51.                         link: path('app.notifications.dashboard.messages.unschedule', {
  52.                             message: message.id,
  53.                         }),
  54.                         modal: 'modal__result_unschedule',
  55.                     } : null,
  56.                     (message.sending or message.complete) ? {
  57.                         text: 'Report',
  58.                         link: path('app.notifications.dashboard.messages.report', {
  59.                             message: message.id,
  60.                         })
  61.                     } : null,
  62.                     (clone or delete) ? {
  63.                         text: 'More',
  64.                         dropdown: {
  65.                             items: [
  66.                                 clone ? {
  67.                                     text: 'Clone',
  68.                                     link: path('app.notifications.dashboard.messages.create', {
  69.                                         clone: message.id,
  70.                                     })
  71.                                 } : null,
  72.                                 delete ? {
  73.                                     text: 'Delete',
  74.                                     link: path('app.notifications.dashboard.messages.delete', {
  75.                                         message: message.id,
  76.                                     }),
  77.                                     modal: 'modal__result_delete',
  78.                                 } : null,
  79.                             ],
  80.                         },
  81.                     }: null,
  82.                     ]|filter((action) => action) %}
  83.                 {% endif %}
  84.                 <tr>
  85.                     {% include '@ui2022/table__item__cell--status.html.twig' with {
  86.                         title: message.title,
  87.                         link: isGranted ? first_of(
  88.                             {
  89.                                 (path('app.notifications.dashboard.messages.update', {
  90.                                     message: message.id
  91.                                 })): message.draft,
  92.                             },
  93.                             path('app.notifications.dashboard.messages.report', {
  94.                                 message: message.id
  95.                             })
  96.                         ) : null,
  97.                         status: first_of({
  98.                             'danger': message.error,
  99.                             'draft': message.draft,
  100.                             'scheduled': message.ready,
  101.                             'sending': message.sending,
  102.                             'sent': message.complete,
  103.                         }),
  104.                         subtext: '%s — by %s'|format(
  105.                             first_of({
  106.                                 'Error': message.error,
  107.                                 'Draft': message.draft,
  108.                                 ('Scheduled %s'|format(message.scheduledAt|ui_datetime)|trim): message.ready,
  109.                                 'Sending': message.sending,
  110.                                 ('Sent (Scheduled %s)'|format(message.scheduledAt|ui_datetime)): message.complete and message.scheduledAt,
  111.                                 'Sent': message.complete,
  112.                             }),
  113.                             message.touchedBy ? message.touchedBy.displayName : 'SYSTEM'
  114.                         ),
  115.                         actions: actions,
  116.                     } %}
  117.                     <td>
  118.                         {{- 'app.notifications.messages.types.%s'|format((message.urgent) ? 'urgent' : 'general')|trans -}}
  119.                     </td>
  120.                     <td>
  121.                         {{- (message.firstJob) ? ((message.firstJob.error ? 1 : 0) + message.firstJob.messagesFailed + message.firstJob.messagesUndelivered) : '—' -}}
  122.                     </td>
  123.                     <td>
  124.                         {{- (message.firstJob) ? message.firstJob.messagesTotal : '—' -}}
  125.                     </td>
  126.                     <td>
  127.                         {{- message.timestampedAt|ui_relativeDate -}}
  128.                     </td>
  129.                 </tr>
  130.             {% endfor %}
  131.         {% endif %}
  132.     {% endblock %}
  133. {% endembed %}