diff --git a/app/web/templates/region_card.html b/app/web/templates/region_card.html index 48fb545..3401fbe 100644 --- a/app/web/templates/region_card.html +++ b/app/web/templates/region_card.html @@ -1,27 +1,35 @@
{% set categories = component_attributes.get_unique_values("category") %} {% for cat in categories|sort %} -
-
-
- {{ cat }} -
+ {# 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 %} -
    - {% 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 %} -
  • - {{ component.name }} - {{ component_status_widget(component) }} -
  • - {% endif %} - {% endwith %} - {% endfor %} -
+ {# Display card only if there are components for the current category and region #} + {% if filtered_components %} +
+
+
+ {{ cat }} +
+
    + {% for component in filtered_components %} +
  • + {{ component.name }} + {{ component_status_widget(component) }} +
  • + {% endfor %} +
+ +
-
+ {% endif %} {% endfor %} -
+
\ No newline at end of file