Show confirmation after pressing big green button

There’s no immediate feedback with letter jobs, unlike email or text
messages jobs where you see the numbers starting to tick over straight
away.

We need to reassure the user that the thing they asked us to do (send
letters) is underway. ‘Printing’ feels like the natural first state of
the letter-making process. So this commit adds a banner to tell the
user that printing is the thing that’s happening.
This commit is contained in:
Chris Hill-Scott
2017-07-13 11:28:37 +01:00
parent ad897cd820
commit 3950c6938d
5 changed files with 61 additions and 10 deletions

View File

@@ -110,6 +110,13 @@ def view_job(service_id, job_id):
total_notifications = job.get('notification_count', 0)
processed_notifications = job.get('notifications_delivered', 0) + job.get('notifications_failed', 0)
template = service_api_client.get_service_template(
service_id=service_id,
template_id=job['template'],
version=job['template_version']
)['data']
return render_template(
'views/jobs/job.html',
finished=(total_notifications == processed_notifications),
@@ -122,7 +129,11 @@ def view_job(service_id, job_id):
job_id=job['id'],
status=request.args.get('status', ''),
),
partials=get_job_partials(job),
partials=get_job_partials(job, template),
just_sent=bool(
request.args.get('just_sent') == 'yes' and
template['template_type'] == 'letter'
)
)
@@ -171,8 +182,16 @@ def cancel_job(service_id, job_id):
@main.route("/services/<service_id>/jobs/<job_id>.json")
@user_has_permissions('view_activity', admin_override=True)
def view_job_updates(service_id, job_id):
job = job_api_client.get_job(service_id, job_id)['data']
return jsonify(**get_job_partials(
job_api_client.get_job(service_id, job_id)['data']
job,
service_api_client.get_service_template(
service_id=current_service['id'],
template_id=job['template'],
version=job['template_version']
)['data'],
))
@@ -343,17 +362,12 @@ def _get_job_counts(job):
]
def get_job_partials(job):
def get_job_partials(job, template):
filter_args = _parse_filter_args(request.args)
filter_args['status'] = _set_status_filters(filter_args)
notifications = notification_api_client.get_notifications_for_service(
job['service'], job['id'], status=filter_args['status']
)
template = service_api_client.get_service_template(
service_id=current_service['id'],
template_id=job['template'],
version=job['template_version']
)['data']
if template['template_type'] == 'letter':
counts = render_template(

View File

@@ -499,7 +499,13 @@ def start_job(service_id, upload_id):
)
return redirect(
url_for('main.view_job', job_id=upload_id, service_id=service_id, help=request.form.get('help'))
url_for(
'main.view_job',
job_id=upload_id,
service_id=service_id,
help=request.form.get('help'),
just_sent='yes',
)
)

View File

@@ -13,7 +13,11 @@
{{ uploaded_file_name }}
</h1>
{{ ajax_block(partials, updates_url, 'status', finished=finished) }}
{% if just_sent %}
{{ banner('Weve started printing your letters', type='default', with_tick=True) }}
{% else %}
{{ ajax_block(partials, updates_url, 'status', finished=finished) }}
{% endif %}
{{ ajax_block(partials, updates_url, 'counts', finished=finished) }}
{{ ajax_block(partials, updates_url, 'notifications', finished=finished) }}