From b84d06bd68d5f3c94169b856eec9d2a8a0293ba9 Mon Sep 17 00:00:00 2001 From: Chris Hill-Scott Date: Thu, 26 May 2016 17:05:16 +0100 Subject: [PATCH] =?UTF-8?q?Move=20parameters=20out=20of=20the=20`=E2=80=A6?= =?UTF-8?q?=5Fmessage`=20components?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit refactors the `email_message` and `sms_message` UI components to take fewer parameters. `name`, `edit_link` and anything to do with versions are identical for both text and email messages so I’ve moved them to the pages where you choose a template or see the versions. This commit also tidies up the wording and styling of the template history stuff. --- app/__init__.py | 4 +- .../stylesheets/components/email-message.scss | 13 +----- .../stylesheets/components/message.scss | 38 ++++++++++++++++ .../stylesheets/components/sms-message.scss | 45 ------------------- app/assets/stylesheets/main.scss | 1 + app/templates/components/email-message.html | 19 -------- app/templates/components/sms-message.html | 16 ------- app/templates/views/styleguide.html | 8 +--- app/templates/views/templates/_template.html | 15 ++----- .../views/templates/_template_history.html | 31 +++++-------- app/templates/views/templates/choose.html | 12 +++-- .../views/templates/choose_history.html | 19 ++++---- 12 files changed, 77 insertions(+), 144 deletions(-) create mode 100644 app/assets/stylesheets/components/message.scss diff --git a/app/__init__.py b/app/__init__.py index 2f86e12d4..bd2f3d619 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -198,7 +198,7 @@ def format_datetime(date): def format_datetime_normal(date): - return gmt_timezones(date).strftime('%d %B %Y at %H:%M') + return gmt_timezones(date).strftime('%d %B %Y at %H:%M').lstrip('0') def format_datetime_short(date): @@ -214,7 +214,7 @@ def format_date(date): def format_date_normal(date): - return gmt_timezones(date).strftime('%d %B %Y') + return gmt_timezones(date).strftime('%d %B %Y').lstrip('0') def format_date_short(date): diff --git a/app/assets/stylesheets/components/email-message.scss b/app/assets/stylesheets/components/email-message.scss index 338668140..53230bb62 100644 --- a/app/assets/stylesheets/components/email-message.scss +++ b/app/assets/stylesheets/components/email-message.scss @@ -5,17 +5,6 @@ $button-bottom-border-colour: rgba(0, 0, 0, 0.17); margin-bottom: $gutter; - &-name { - @include bold-24; - margin: 20px 0 5px 0; - } - - &-updated-at { - @include copy-16; - color: $secondary-text-colour; - margin: 0 0 10px 0; - } - &-meta { @include core-19; @@ -45,7 +34,7 @@ $button-bottom-border-colour: rgba(0, 0, 0, 0.17); } &-body { - + width: 100%; box-sizing: border-box; padding: $gutter-half 0 0 0; diff --git a/app/assets/stylesheets/components/message.scss b/app/assets/stylesheets/components/message.scss new file mode 100644 index 000000000..bf8a2c8ab --- /dev/null +++ b/app/assets/stylesheets/components/message.scss @@ -0,0 +1,38 @@ +.message { + + &-name { + @include bold-24; + margin: 20px 0 5px 0; + } + + &-updated-at { + @include copy-16; + color: $secondary-text-colour; + margin: 0 0 5px 0; + } + + &-use-links { + + @include copy-16; + margin-top: -7px; + color: $secondary-text-colour; + + a { + @include core-19; + display: block; + margin-bottom: 5px; + text-decoration: none; + + &:hover { + text-decoration: underline; + } + + } + + .primary { + @include bold-19; + } + + } + +} diff --git a/app/assets/stylesheets/components/sms-message.scss b/app/assets/stylesheets/components/sms-message.scss index 1ce242b2f..29696bd04 100644 --- a/app/assets/stylesheets/components/sms-message.scss +++ b/app/assets/stylesheets/components/sms-message.scss @@ -40,23 +40,6 @@ margin: 20px 0 5px 0; } -.sms-message-updated-at { - @include copy-16; - color: $secondary-text-colour; - margin: 0 0 10px 0; -} - -.sms-message-use-links-history { - @include copy-16; - color: $secondary-text-colour; - margin: 45px 0 0 0; - - .primary { - color: $text-colour; - - } -} - .sms-message-picker { display: block; margin: 7px 0 0 0; @@ -66,34 +49,6 @@ z-index: 50; } -%sms-message-use-links, -.sms-message-use-links { - - @include copy-19; - margin-top: 35px; - - a { - display: block; - margin-bottom: 5px; - text-decoration: none; - - &:hover { - text-decoration: underline; - } - - } - - .primary { - @include bold-19; - } - -} - -.sms-message-use-links-with-title { - @extend %sms-message-use-links; - margin-top: 50px; -} - .sms-message-from { @include bold-19; display: block; diff --git a/app/assets/stylesheets/main.scss b/app/assets/stylesheets/main.scss index eae80027d..b6cc06f93 100644 --- a/app/assets/stylesheets/main.scss +++ b/app/assets/stylesheets/main.scss @@ -51,6 +51,7 @@ $path: '/static/images/'; @import 'components/pill'; @import 'components/secondary-button'; @import 'components/show-more'; +@import 'components/message'; @import 'views/job'; @import 'views/edit-template'; diff --git a/app/templates/components/email-message.html b/app/templates/components/email-message.html index 649c2410b..c7e7db0ae 100644 --- a/app/templates/components/email-message.html +++ b/app/templates/components/email-message.html @@ -1,32 +1,13 @@ {% macro email_message( subject, body, - name=None, - edit_link=None, from_name=None, from_address=None, recipient=None, id=None, - updated_at=None, - versions_url=None, - version=1, show_placeholder_for_recipient=False, show_id=False ) %} - {% if name %} -

- {% if edit_link %} - {{ name }} - {% else %} - {{ name }} - {% endif %} -

- {% endif %} - {% if version > 1 %} - {% if updated_at %} -

Last updated on {{ updated_at|format_date_normal }} see earlier versions

- {% endif %} - {% endif %}
{% if from_name or subject %} diff --git a/app/templates/components/sms-message.html b/app/templates/components/sms-message.html index 1bc20da49..334e3d0cd 100644 --- a/app/templates/components/sms-message.html +++ b/app/templates/components/sms-message.html @@ -1,9 +1,7 @@ {% macro sms_message( body, recipient=None, - name=None, id=None, - edit_link=None, from=None, version=1, updated_at=None, @@ -11,20 +9,6 @@ show_placeholder_for_recipient=False, show_id=False ) %} - {% if name %} -

- {% if edit_link %} - {{ name }} - {% else %} - {{ name }} - {% endif %} -

- {% endif %} - {% if version > 1 %} - {% if updated_at %} -

Last updated on {{ updated_at|format_date_normal }} see earlier versions

- {% endif %} - {% endif %} {% if recipient is not none %}

To: diff --git a/app/templates/views/styleguide.html b/app/templates/views/styleguide.html index 8ed1bf1b7..59859b151 100644 --- a/app/templates/views/styleguide.html +++ b/app/templates/views/styleguide.html @@ -118,7 +118,6 @@

{{ sms_message( 'Your vehicle tax for LC12 BFL is due on 1 March 2016. Renew online at www.gov.uk/vehicle-tax', - name='Two week reminder', ) }} {{ sms_message( template.formatted_as_markup @@ -128,9 +127,7 @@ '+44 7700 900 306' ) }} {{ sms_message( - template.formatted_as_markup, - name='Two week reminder', - edit_link='#' + template.formatted_as_markup ) }}
@@ -145,8 +142,7 @@ subject="Vehicle tax reminder", body="Dear Alice Smith,\n\nYour vehicle tax for LC12 BFL is due on 1 March 2016.\n\nRenew online at www.gov.uk/vehicle-tax", from_name="Vehicle tax", - from_address="vehicle.tax@notifications.service.gov.uk", - name="Two week reminder", + from_address="vehicle.tax@notifications.service.gov.uk" ) }} diff --git a/app/templates/views/templates/_template.html b/app/templates/views/templates/_template.html index 3c40e42ba..195ad2c08 100644 --- a/app/templates/views/templates/_template.html +++ b/app/templates/views/templates/_template.html @@ -2,30 +2,21 @@ {% from "components/sms-message.html" import sms_message %}
-{{ template.versions }} {% if 'email' == template.template_type %} {{ email_message( template.formatted_subject_as_markup, template.formatted_as_markup, - name=template.name if show_title else None, - id=template.id, - updated_at=template.get_raw('updated_at', None), - version=template.get_raw('version', 1), - versions_url=url_for('.view_template_versions', service_id=current_service.id, template_id=template.id) + id=template.id ) }} {% elif 'sms' == template.template_type %} {{ sms_message( template.formatted_as_markup, - name=template.name if show_title else None, - id=template.id, - updated_at=template.get_raw('updated_at', None), - version=template.get_raw('version', 1), - versions_url=url_for('.view_template_versions', service_id=current_service.id, template_id=template.id) + id=template.id ) }} {% endif %}
-
+
{% if current_user.has_permissions(permissions=['send_texts', 'send_emails', 'send_letters']) %} Send {{ 'text messages' if 'sms' == template.template_type else 'emails' }} diff --git a/app/templates/views/templates/_template_history.html b/app/templates/views/templates/_template_history.html index a4c990157..e0dba731c 100644 --- a/app/templates/views/templates/_template_history.html +++ b/app/templates/views/templates/_template_history.html @@ -1,41 +1,30 @@ {% from "components/email-message.html" import email_message %} {% from "components/sms-message.html" import sms_message %} +
+

{{ template.name }}

+
+
{% if 'email' == template.template_type %} {{ email_message( template.formatted_subject_as_markup, template.formatted_as_markup, - name=template.name if show_title else None, - edit_link=url_for( - '.view_template_version', - service_id=current_service.id, - template_id=template.id, - version=template.get_raw('version') - ) ) }} {% elif 'sms' == template.template_type %} {{ sms_message( - template.formatted_as_markup, - name=template.name if show_title else None, - edit_link=url_for( - '.view_template_version', - service_id=current_service.id, - template_id=template.id, - version=template.get_raw('version') - ) + template.formatted_as_markup ) }} {% endif %}
- \ No newline at end of file +
diff --git a/app/templates/views/templates/choose.html b/app/templates/views/templates/choose.html index a9be181c7..028152e80 100644 --- a/app/templates/views/templates/choose.html +++ b/app/templates/views/templates/choose.html @@ -35,9 +35,15 @@
{% endif %} diff --git a/app/templates/views/templates/choose_history.html b/app/templates/views/templates/choose_history.html index b7d65b3b0..a2dbe6e16 100644 --- a/app/templates/views/templates/choose_history.html +++ b/app/templates/views/templates/choose_history.html @@ -5,12 +5,15 @@ {% endblock %} {% block maincolumn_content %} -

{{ template.name }} version history

-
- {% for template in versions %} - {% with show_title=True %} - {% include 'views/templates/_template_history.html' %} - {% endwith %} - {% endfor %} -
+

Previous versions

+
+ {% for template in versions %} + {% with show_title=True %} + {% include 'views/templates/_template_history.html' %} + {% endwith %} + {% endfor %} +
+

+ Back to current templates +

{% endblock %}