input letter address data in a single block

rather than in multiple placeholders - this is the first step towards
making postcodes non-required, which is the first step towards
international letters.

they still populate address_line_# and postcode fields under the hood -
to keep validation working the same, the last line always goes into
`postcode`.

the form normalises whitespace, removes extra new lines, and enforces
that you have between three and seven lines.

if the letter repeats address placeholders further down (eg "Dear
((address_line_1))"), then it'll fill those in as well. It'll still
prompt you to fill them in, but they'll be pre-filled.
This commit is contained in:
Leo Hemsted
2020-03-10 15:12:19 +00:00
parent df51bf6f5f
commit c4d839d4f5
7 changed files with 411 additions and 13 deletions

View File

@@ -0,0 +1,45 @@
{% extends "withnav_template.html" %}
{% from "components/page-header.html" import page_header %}
{% from "components/page-footer.html" import page_footer %}
{% from "components/message-count-label.html" import recipient_count_label %}
{% from "components/textbox.html" import textbox %}
{% from "components/form.html" import form_wrapper %}
{% block service_page_title %}
{{ page_title }}
{% endblock %}
{% block maincolumn_content %}
{{ page_header(
page_title,
back_link=back_link
) }}
{% call form_wrapper(
class='send-one-off-form',
module="autofocus",
data_kwargs={'force-focus': True}
) %}
<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds {% if form.placeholder_value.label.text == 'phone number' %}extra-tracking{% endif %}">
{{ textbox(
form.address,
rows=4,
width='1-1',
autofocus=True,
autosize=True,
) }}
</div>
</div>
<p>
<a class="govuk-link govuk-link--no-visited-state" href="{{ url_for('.send_messages', service_id=current_service.id, template_id=template.id) }}">
Upload a list of {{ recipient_count_label(999, template.template_type) }}
</a>
</p>
{{ page_footer('Continue') }}
{% endcall %}
{{ template|string }}
{% endblock %}

View File

@@ -16,11 +16,11 @@
<div class="bottom-gutter-2-3">
<div class="govuk-grid-row">
{% if template.template_type == 'letter' %}
{% if letter_too_long %}
{% call banner_wrapper(type='dangerous') %}
{% include "partials/check/letter-too-long.html" %}
{% endcall %}
{% endif %}
{% if letter_too_long %}
{% call banner_wrapper(type='dangerous') %}
{% include "partials/check/letter-too-long.html" %}
{% endcall %}
{% endif %}
{% if current_user.has_permissions('send_messages', restrict_admin_usage=True) and not letter_too_long %}
<div class="govuk-grid-column-one-half">
<a href="{{ url_for(".set_sender", service_id=current_service.id, template_id=template.id) }}" class="govuk-link govuk-link--no-visited-state pill-separate-item">