Skip to content

Commit

Permalink
display changes to support local council scorecards
Browse files Browse the repository at this point in the history
move range display into include
allow a range related dataset for datasets
  • Loading branch information
struan committed Apr 17, 2024
1 parent 32dc090 commit d459049
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 20 deletions.
26 changes: 6 additions & 20 deletions hub/templates/hub/area.html
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,8 @@ <h2 class="mb-3 text-primary">Place</h2>
{% for dataset in categories.place %}
{% if dataset.is_range and dataset.data|length > 9 %}
<div class="card dataset-card area-data--lg {% if dataset.is_favourite or dataset.data.is_favourite %}dataset-card--favourite{% endif %} {% if dataset.featured %} area-data--featured{% endif %}">
{% elif dataset.related_category and dataset.related_category.is_range %}
<div class="card dataset-card area-data--md {% if dataset.is_favourite or dataset.data.is_favourite %}dataset-card--favourite{% endif %} {% if dataset.featured %} area-data--featured{% endif %}">
{% elif dataset.is_range or dataset.data_type == "json" %}
<div class="card dataset-card area-data--md {% if dataset.is_favourite or dataset.data.is_favourite %}dataset-card--favourite{% endif %} {% if dataset.featured %} area-data--featured{% endif %}">
{% else %}
Expand Down Expand Up @@ -510,29 +512,13 @@ <h3 class="h5">{{ dataset.label }}</h3>
{% include 'hub/area/_json_data.html' with dataset=dataset.related_category %}
{% endif %}
{% elif dataset.is_range and dataset.data|length > 0 %}
<table class="table mb-0 js-chart" data-chart-type="bar" data-chart-direction="y">
<thead>
<tr>
<th scope="col"></th>
<th scope="col" data-color="#068670">This area</th>
<th scope="col" data-color="#ced4da">National average</th>
</tr>
</thead>
<tbody>
{% for row in dataset.data %}
<tr>
<th>
{{ row.label|html_format_dataset_name|safe }}
</th>
<td>{{ row.value|floatformat }}%</td>
<td>{{ row.average|floatformat }}%</td>
</tr>
{% endfor %}
</tbody>
</table>
{% include 'hub/area/_range_data.html' with dataset=dataset %}
{% else %}
<p class="card-text mb-0 display-6 lh-1 text-primary">{{ dataset.data.value|floatformat }}%</p>
<p class="card-text mt-2 text-muted">{{dataset.data.average|floatformat }}% national average</p>
{% if dataset.related_category and dataset.related_category.is_range %}
{% include 'hub/area/_range_data.html' with dataset=dataset.related_category %}
{% endif %}
{% endif %}
</div>
<div class="card-footer">
Expand Down
21 changes: 21 additions & 0 deletions hub/templates/hub/area/_range_data.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{% load hub_filters %}
<table class="table mb-0 js-chart" data-chart-type="bar" data-chart-direction="y">
<thead>
<tr>
<th scope="col"></th>
<th scope="col" data-color="#068670">This area</th>
<th scope="col" data-color="#ced4da">National average</th>
</tr>
</thead>
<tbody>
{% for row in dataset.data %}
<tr>
<th>
{{ row.label|html_format_dataset_name|safe }}
</th>
<td>{{ row.value|floatformat }}%</td>
<td>{{ row.average|floatformat }}%</td>
</tr>
{% endfor %}
</tbody>
</table>
1 change: 1 addition & 0 deletions hub/views/area.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,7 @@ def get_context_data(self, **kwargs):
"power_postcodes_count": "power_postcodes",
"tcc_open_letter_signatories_count": "tcc_open_letter_signatories",
"council_net_zero_date": "council_net_zero_details",
"council_action_scorecard_total": "council_action_scorecard_sections",
}

context["is_related_category"] = context["related_categories"].values()
Expand Down

0 comments on commit d459049

Please sign in to comment.