From 8c8f321a11efc2d20ca12ce479393a474db4f0a5 Mon Sep 17 00:00:00 2001 From: Chris Hill-Scott Date: Thu, 1 Sep 2016 11:06:52 +0100 Subject: [PATCH 1/2] Make sure partials always have a wrapping `
` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The diffDOM Javascript sometimes throws an error if it can’t calculate a diff between the original content of the page and the updated HTML delivered via AJAX. The problem seems to be when there’s not one, consistent top-level element for it to base its calculations on. This commit: - makes sure that all AJAX-delivered partials have a wrapping `
` - that this `
` has a consistent class name to make it clear why it’s there --- app/templates/partials/jobs/count.html | 2 +- .../partials/jobs/notifications.html | 122 +++++++++--------- app/templates/partials/jobs/status.html | 2 +- app/templates/views/dashboard/_jobs.html | 2 +- app/templates/views/dashboard/_totals.html | 2 +- app/templates/views/dashboard/_usage.html | 2 +- 6 files changed, 67 insertions(+), 65 deletions(-) diff --git a/app/templates/partials/jobs/count.html b/app/templates/partials/jobs/count.html index 2755f3259..78003a22e 100644 --- a/app/templates/partials/jobs/count.html +++ b/app/templates/partials/jobs/count.html @@ -1,5 +1,5 @@ {% from "components/pill.html" import pill %} -
+
{{ pill('Status', counts, request.args.get('status', '')) }}
diff --git a/app/templates/partials/jobs/notifications.html b/app/templates/partials/jobs/notifications.html index 052d5b2ec..12d0d47e0 100644 --- a/app/templates/partials/jobs/notifications.html +++ b/app/templates/partials/jobs/notifications.html @@ -1,71 +1,73 @@ {% from "components/table.html" import list_table, field, right_aligned_field_heading, date_field, row_heading %} -{% if job.job_status == 'scheduled' %} +
+ {% if job.job_status == 'scheduled' %} -

- Sending will start at {{ job.scheduled_for|format_time }} -

+

+ Sending will start at {{ job.scheduled_for|format_time }} +

-{% else %} + {% else %} - {% if notifications %} -
- {% endif %} + {% if notifications %} +
+ {% endif %} - {% if not help %} - {% if percentage_complete < 100 %} -

- Report is {{ "{:.0f}%".format(percentage_complete) }} complete… -

- {% elif notifications %} -

- Download this report -   - {{ time_left }} + {% if not help %} + {% if percentage_complete < 100 %} +

+ Report is {{ "{:.0f}%".format(percentage_complete) }} complete… +

+ {% elif notifications %} +

+ Download this report +   + {{ time_left }} +

+ {% endif %} + {% endif %} + + {% call(item, row_number) list_table( + notifications, + caption=uploaded_file_name, + caption_visible=False, + empty_message="No messages to show", + field_headings=[ + 'Recipient', + 'Time', + 'Status' + ], + field_headings_visible=False + ) %} + {% call row_heading() %} + {{ item.to }} + {% endcall %} + {{ date_field( + (item.updated_at or item.created_at)|format_datetime_short + ) }} + {% 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 %} + {% endcall %} + {% endcall %} + + {% if more_than_one_page %} + {% endif %} + + {% if notifications %} +
{% endif %} - {% call(item, row_number) list_table( - notifications, - caption=uploaded_file_name, - caption_visible=False, - empty_message="No messages to show", - field_headings=[ - 'Recipient', - 'Time', - 'Status' - ], - field_headings_visible=False - ) %} - {% call row_heading() %} - {{ item.to }} - {% endcall %} - {{ date_field( - (item.updated_at or item.created_at)|format_datetime_short - ) }} - {% 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 %} - {% endcall %} - {% endcall %} - - {% if more_than_one_page %} - - {% endif %} - - {% if notifications %} -
{% endif %} - -{% endif %} +
diff --git a/app/templates/partials/jobs/status.html b/app/templates/partials/jobs/status.html index 6c46bbaf2..694bb117c 100644 --- a/app/templates/partials/jobs/status.html +++ b/app/templates/partials/jobs/status.html @@ -1,4 +1,4 @@ -
+

Uploaded by {{ job.created_by.name }} on {{ job.created_at|format_datetime_short }}

diff --git a/app/templates/views/dashboard/_jobs.html b/app/templates/views/dashboard/_jobs.html index 3c70670e4..ea49cc3e7 100644 --- a/app/templates/views/dashboard/_jobs.html +++ b/app/templates/views/dashboard/_jobs.html @@ -1,7 +1,7 @@ {% from "components/table.html" import list_table, field, right_aligned_field_heading, row_heading %} {% from "components/big-number.html" import big_number -%} -
+
{% call(item, row_number) list_table( jobs, caption="Recent files uploaded", diff --git a/app/templates/views/dashboard/_totals.html b/app/templates/views/dashboard/_totals.html index a5dcc2f51..88725efb5 100644 --- a/app/templates/views/dashboard/_totals.html +++ b/app/templates/views/dashboard/_totals.html @@ -1,7 +1,7 @@ {% from "components/big-number.html" import big_number_with_status %} {% from "components/message-count-label.html" import message_count_label %} -
+
{{ big_number_with_status( statistics['email']['requested'], diff --git a/app/templates/views/dashboard/_usage.html b/app/templates/views/dashboard/_usage.html index 066dae104..ff0530549 100644 --- a/app/templates/views/dashboard/_usage.html +++ b/app/templates/views/dashboard/_usage.html @@ -1,6 +1,6 @@ {% from "components/big-number.html" import big_number %} -
+
{{ big_number("Unlimited", 'free email allowance', smaller=True) }} From b98b328d9b7fc6c2238342e679bb61e9c02afafa Mon Sep 17 00:00:00 2001 From: Chris Hill-Scott Date: Thu, 1 Sep 2016 11:07:00 +0100 Subject: [PATCH 2/2] Upgrade diffDOM dependency Features: - Expose Diff object Fixes: - Reverse actions for modifyComment/Text - Simplify diff on some text only diffs - Simplify diff on single element removal --- app/templates/views/dashboard/_upcoming.html | 68 ++++++++++---------- package.json | 2 +- 2 files changed, 36 insertions(+), 34 deletions(-) diff --git a/app/templates/views/dashboard/_upcoming.html b/app/templates/views/dashboard/_upcoming.html index 0f7babb99..4589b20a3 100644 --- a/app/templates/views/dashboard/_upcoming.html +++ b/app/templates/views/dashboard/_upcoming.html @@ -2,37 +2,39 @@ {% from "components/big-number.html" import big_number %} {% from "components/show-more.html" import show_more %} -{% if scheduled_jobs %} -
-

- In the next 24 hours -

- {% call(item, row_number) list_table( - scheduled_jobs, - caption="In the next 24 hours", - caption_visible=False, - empty_message='Nothing to see here', - field_headings=[ - 'File', - 'Messages to be sent' - ], - field_headings_visible=True - ) %} - {% call row_heading() %} -
- {{ item.original_file_name }} - - Sending at {{ item.scheduled_for|format_time }} - -
+
+ {% if scheduled_jobs %} +
+

+ In the next 24 hours +

+ {% call(item, row_number) list_table( + scheduled_jobs, + caption="In the next 24 hours", + caption_visible=False, + empty_message='Nothing to see here', + field_headings=[ + 'File', + 'Messages to be sent' + ], + field_headings_visible=True + ) %} + {% call row_heading() %} +
+ {{ item.original_file_name }} + + Sending at {{ item.scheduled_for|format_time }} + +
+ {% endcall %} + {% call field() %} + {{ big_number( + item.notification_count, + smallest=True + ) }} + {% endcall %} {% endcall %} - {% call field() %} - {{ big_number( - item.notification_count, - smallest=True - ) }} - {% endcall %} - {% endcall %} - {{ show_more() }} -
-{% endif %} + {{ show_more() }} +
+ {% endif %} +
diff --git a/package.json b/package.json index c3f8fd139..ffcc530fc 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,7 @@ "dependencies": { "babel-core": "6.3.26", "babel-preset-es2015": "6.3.13", - "diff-dom": "2.0.3", + "diff-dom": "2.1.0", "govuk-elements-sass": "1.1.1", "govuk_frontend_toolkit": "4.6.0", "govuk_template_jinja": "https://github.com/alphagov/govuk_template/releases/download/v0.18.0/jinja_govuk_template-0.18.0.tgz",