Don’t show template stats if one template used

If you’ve only used one template then this section of the page isn’t
doing its job, which is to show a comparison of the different kinds of
message you’re showing.

I think our initial assumption was that everyone would be using multiple
templates, so it was good to show this part of the page during the
onboarding, to show users where the information was going to appear.

But we have lots of services who only send one template now, typically
where they’re populating the contents of the template themselves. In
which case this part of the page doesn’t offer them any value.
This commit is contained in:
Chris Hill-Scott
2019-10-25 15:52:22 +01:00
parent 58cfce8760
commit 88a557f6c8
3 changed files with 89 additions and 47 deletions

View File

@@ -33,13 +33,7 @@
'See messages sent per month'
) }}
{% if partials['has_template_statistics'] %}
{{ ajax_block(partials, updates_url, 'template-statistics', interval=5) }}
{{ show_more(
url_for('.template_usage', service_id=current_service.id),
'See templates used by month'
) }}
{% endif %}
{{ ajax_block(partials, updates_url, 'template-statistics', interval=5) }}
{% if partials['has_jobs'] %}
{{ ajax_block(partials, updates_url, 'jobs', interval=5) }}

View File

@@ -2,46 +2,55 @@
{% from "components/message-count-label.html" import message_count_label %}
{% from "components/big-number.html" import big_number %}
{% from "components/table.html" import list_table, field, right_aligned_field_heading, row_heading, spark_bar_field %}
{% from "components/show-more.html" import show_more %}
<div class='dashboard-table'>
{% call(item, row_number) list_table(
template_statistics,
caption="Templates used",
caption_visible=False,
empty_message='',
field_headings=[
'Template',
'Messages sent'
],
field_headings_visible=True
) %}
<div class="ajax-block-container">
{% if template_statistics|length > 1 %}
<div class='dashboard-table'>
{% call(item, row_number) list_table(
template_statistics,
caption="Templates used",
caption_visible=False,
empty_message='',
field_headings=[
'Template',
'Messages sent'
],
field_headings_visible=True
) %}
{% call row_heading() %}
{% if item.is_precompiled_letter %}
<span class="file-list-filename">
Provided as PDF
</span>
<span class="file-list-hint">
Letter
</span>
{% else %}
<a class="file-list-filename" href="{{ url_for('.view_template', service_id=current_service.id, template_id=item.template_id) }}">{{ item.template_name }}</a>
<span class="file-list-hint">
{{ message_count_label(1, item.template_type, suffix='template')|capitalize }}
</span>
{% endif %}
{% endcall %}
{% if template_statistics|length > 1 %}
{{ spark_bar_field(item.count, most_used_template_count, id=item.template_id) }}
{% else %}
{% call field() %}
<span id='{{item.template_id}}' class="heading-small">
{{ big_number(
item.count,
smallest=True
) }}
</span>
{% call row_heading() %}
{% if item.is_precompiled_letter %}
<span class="file-list-filename">
Provided as PDF
</span>
<span class="file-list-hint">
Letter
</span>
{% else %}
<a class="file-list-filename" href="{{ url_for('.view_template', service_id=current_service.id, template_id=item.template_id) }}">{{ item.template_name }}</a>
<span class="file-list-hint">
{{ message_count_label(1, item.template_type, suffix='template')|capitalize }}
</span>
{% endif %}
{% endcall %}
{% if template_statistics|length > 1 %}
{{ spark_bar_field(item.count, most_used_template_count, id=item.template_id) }}
{% else %}
{% call field() %}
<span id='{{item.template_id}}' class="heading-small">
{{ big_number(
item.count,
smallest=True
) }}
</span>
{% endcall %}
{% endif %}
{% endcall %}
{% endif %}
{% endcall %}
{{ show_more(
url_for('.template_usage', service_id=current_service.id),
'See templates used by month'
) }}
</div>
{% endif %}
</div>