From 95506e7c3b2b23489d2b664977e5d5cc352c9a9e Mon Sep 17 00:00:00 2001 From: Chris Hill-Scott Date: Fri, 9 Sep 2016 15:40:27 +0100 Subject: [PATCH] Refactor notification status into its own field type --- app/templates/components/table.html | 20 ++++++++++++++++ .../partials/jobs/notifications.html | 22 ++---------------- app/templates/views/notifications.html | 23 ++----------------- 3 files changed, 24 insertions(+), 41 deletions(-) diff --git a/app/templates/components/table.html b/app/templates/components/table.html index 21a73f185..8f0453012 100644 --- a/app/templates/components/table.html +++ b/app/templates/components/table.html @@ -104,3 +104,23 @@ {% macro hidden_field_heading(text) %} {{ text }} {%- endmacro %} + + +{% macro notification_status_field(notification) %} + {% call field(status=notification.status|format_notification_status_as_field_status, align='right') %} + {% if notification.status|format_notification_status_as_url %} + + {% endif %} + {{ notification.status|format_notification_status( + notification.template.template_type + ) }} + {% if notification.status|format_notification_status_as_url %} + + {% endif %} + + {{ notification.status|format_notification_status_as_time( + (notification.updated_at or notification.created_at)|format_datetime_short + ) }} + + {% endcall %} +{% endmacro %} diff --git a/app/templates/partials/jobs/notifications.html b/app/templates/partials/jobs/notifications.html index 2a8f20220..d75b8310d 100644 --- a/app/templates/partials/jobs/notifications.html +++ b/app/templates/partials/jobs/notifications.html @@ -1,4 +1,4 @@ -{% from "components/table.html" import list_table, field, right_aligned_field_heading, date_field, row_heading %} +{% from "components/table.html" import list_table, field, right_aligned_field_heading, date_field, row_heading, notification_status_field %} {% from "components/page-footer.html" import page_footer %}
@@ -50,25 +50,7 @@ {% call row_heading() %}

{{ item.to }}

{% endcall %} - {% call field( - align='right', - status=item.status|format_notification_status_as_field_status - ) %} - {% if item.status|format_notification_status_as_url %} - - {% endif %} - {{ item.status|format_notification_status( - item.template.template_type - ) }} - {% if item.status|format_notification_status_as_url %} - - {% endif %} - - {{ item.status|format_notification_status_as_time( - (item.updated_at or item.created_at)|format_datetime_short - ) }} - - {% endcall %} + {{ notification_status_field(item) }} {% endcall %} {% if more_than_one_page %} diff --git a/app/templates/views/notifications.html b/app/templates/views/notifications.html index 6d8760a62..c2170c334 100644 --- a/app/templates/views/notifications.html +++ b/app/templates/views/notifications.html @@ -1,5 +1,5 @@ {% extends "withnav_template.html" %} -{% from "components/table.html" import list_table, field, text_field, link_field, right_aligned_field_heading, hidden_field_heading, row_heading, notification_status_field %} +{% from "components/table.html" import list_table, field, text_field, link_field, right_aligned_field_heading, hidden_field_heading, row_heading, date_field, notification_status_field %} {% from "components/previous-next-navigation.html" import previous_next_navigation %} {% from "components/page-footer.html" import page_footer %} {% from "components/pill.html" import pill %} @@ -68,26 +68,7 @@

{% endcall %} - {% call field( - align='right', - status=item.status|format_notification_status_as_field_status - ) %} - {% if item.status|format_notification_status_as_url %} - - {% endif %} - {{ item.status|format_notification_status( - item.template.template_type - ) }} - {% if item.status|format_notification_status_as_url %} - -
- {% endif %} - - {{ item.status|format_notification_status_as_time( - (item.updated_at or item.created_at)|format_datetime_short - ) }} - - {% endcall %} + {{ notification_status_field(item) }} {% endcall %} {% if notifications %}