Skip to content

Commit

Permalink
indicate if filters are unavailable for an area type
Browse files Browse the repository at this point in the history
Include area types available with filter list returned from server and
use this to highlight is a filter isn't available for the chosen
area type

Part of #336
  • Loading branch information
struan committed Nov 9, 2023
1 parent a65d68b commit 2bc9ed1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
4 changes: 3 additions & 1 deletion hub/templates/hub/explore.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ <h2 class="h5 mt-4 mt-lg-5 mb-3 mb-lg-4 text-primary">Step 1: Select an output f
<h2 class="h5 mt-4 mt-lg-5 mb-4 text-primary">Step 2: Filter constituencies</h2>

<div ref="filtersContainer" class="mb-4" hidden>
<div v-for="filter in filters" class="bg-gray-100 border p-3 rounded filter">
<template v-for="filter in filters">
<div class="border p-3 rounded filter" :class="{ 'bg-gray-100': filter.areas_available.includes(area_type), 'bg-red-100': !filter.areas_available.includes(area_type) }">
<div class="filter__header">
<h3 class="h6">${ filter.title }</h3>
<button @click="removeFilter(filter.name)" type="button" class="btn-close p-0" aria-label="Remove filter"></button>
Expand Down Expand Up @@ -86,6 +87,7 @@ <h3 class="h6">${ filter.title }</h3>
</table>
</details>
</div>
</template>
</div>

<button @click="selectFilter" type="button" class="btn btn-outline-secondary p-3 w-100">
Expand Down
1 change: 1 addition & 0 deletions hub/views/explore.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ def render_to_response(self, context, **response_kwargs):
is_in=True if d.comparators[0]["field_lookup"] == "in" else False,
is_range=d.is_range,
data_type=d.data_type,
areas_available=[t.code for t in d.areas_available.all()],
)
if d.release_date is not None:
ds["release_date"] = d.release_date
Expand Down

0 comments on commit 2bc9ed1

Please sign in to comment.