Skip to content

Commit

Permalink
category filter added (#133)
Browse files Browse the repository at this point in the history
Filter for category in region card

Before:

After:

Reviewed-by: Vladimir Hasko <[email protected]>
  • Loading branch information
bakhterets authored Nov 15, 2024
1 parent c606677 commit 5ea648a
Showing 1 changed file with 28 additions and 20 deletions.
48 changes: 28 additions & 20 deletions app/web/templates/region_card.html
Original file line number Diff line number Diff line change
@@ -1,27 +1,35 @@
<div class="container row row-cols-1 row-cols-md-3 g-4">
{% set categories = component_attributes.get_unique_values("category") %}
{% for cat in categories|sort %}
<div class="col">
<div class="card">
<h5 class="card-header">
{{ cat }}
</h2>
{# Filtering components for category #}
{% set filtered_components = [] %}
{% for component in all_components_with_incidents %}
{% with attrs = component.get_attributes_as_dict() %}
{% if 'region' in attrs and attrs['region'] == region and 'category' in attrs and attrs['category'] == cat %}
{% set _ = filtered_components.append(component) %}
{% endif %}
{% endwith %}
{% endfor %}

<ul class="list-group list-group-flush">
{% for component in all_components_with_incidents %}
{% with attrs = component.get_attributes_as_dict() %}
{% if 'region' in attrs and attrs['region'] == region and 'category' in attrs and attrs['category'] == cat %}
<li class="list-group-item d-flex justify-content-between
align-items-center">
{{ component.name }}
{{ component_status_widget(component) }}
</li>
{% endif %}
{% endwith %}
{% endfor %}
</ul>
{# Display card only if there are components for the current category and region #}
{% if filtered_components %}
<div class="col">
<div class="card">
<h5 class="card-header">
{{ cat }}
</h5>

<ul class="list-group list-group-flush">
{% for component in filtered_components %}
<li class="list-group-item d-flex justify-content-between align-items-center">
{{ component.name }}
{{ component_status_widget(component) }}
</li>
{% endfor %}
</ul>

</div>
</div>
</div>
{% endif %}
{% endfor %}
</div>
</div>

0 comments on commit 5ea648a

Please sign in to comment.