From d0965ed3b2ba2a2531e3b3e854f387844d5028f3 Mon Sep 17 00:00:00 2001
From: ewuerger
Date: Tue, 17 Sep 2024 13:20:29 +0200
Subject: [PATCH] fix: Solve various problems with templates
Co-authored-by: Martin Lehmann
---
templates/cross-cutting/classes.html.j2 | 3 ++-
templates/cross-cutting/exchange-item.html.j2 | 4 ++--
templates/operational-analysis/operational-activity.html.j2 | 2 +-
templates/operational-analysis/operational-capability.html.j2 | 4 ++--
templates/physical-architecture/sw-interface.html.j2 | 2 +-
templates/system-analysis/system-capability.html.j2 | 2 +-
templates/system-analysis/system-interface.html.j2 | 2 +-
7 files changed, 10 insertions(+), 9 deletions(-)
diff --git a/templates/cross-cutting/classes.html.j2 b/templates/cross-cutting/classes.html.j2
index 54ebcf7..ea14c4b 100644
--- a/templates/cross-cutting/classes.html.j2
+++ b/templates/cross-cutting/classes.html.j2
@@ -46,7 +46,8 @@
{% for val in property.type.literals %}
{{ val.name }} |
- {{ val.value if val.value else "0" }} |
+ {% set value = val.value if val.value else "" %}
+ {{ value.value if value.value is defined else "0" }} |
{% endfor %}
diff --git a/templates/cross-cutting/exchange-item.html.j2 b/templates/cross-cutting/exchange-item.html.j2
index f2e5485..c92c9d1 100644
--- a/templates/cross-cutting/exchange-item.html.j2
+++ b/templates/cross-cutting/exchange-item.html.j2
@@ -26,8 +26,8 @@
{%- set src = exchange.source.owner.owner if exchange.source.owner.owner else None -%}
{%- set tgt = exchange.target.owner.owner if exchange.target.owner.owner else None -%}
- {{ linked_name_with_icon(exchange) | safe }}
- , produced by {{ linked_name_with_icon(exchange.source.owner) | safe }} of {{ linked_name_with_icon(src) | safe if src else "Unassigned" }}
+ {{ linked_name_with_icon(exchange) | safe }},
+ produced by {{ linked_name_with_icon(exchange.source.owner) | safe }} of {{ linked_name_with_icon(src) | safe if src else "Unassigned" }}
and consumed by {{ linked_name_with_icon(exchange.target.owner) | safe }} of {{ linked_name_with_icon(tgt) | safe if tgt else "Unassigned" }}
{%- endfor -%}
diff --git a/templates/operational-analysis/operational-activity.html.j2 b/templates/operational-analysis/operational-activity.html.j2
index c787e90..5806b68 100644
--- a/templates/operational-analysis/operational-activity.html.j2
+++ b/templates/operational-analysis/operational-activity.html.j2
@@ -50,7 +50,7 @@
{%- if object.owner -%}
{% set partners = partners | rejectattr("uuid", "equalto", object.owner.uuid) | list %}
{%- endif -%}
-{%- for partner in partners | unique -%} {{ linked_name_with_icon(partner) | safe }}, {%- endfor -%}
+{%- for partner in partners | unique(attribute="uuid") -%} {{ linked_name_with_icon(partner) | safe }}, {%- endfor -%}
diff --git a/templates/operational-analysis/operational-capability.html.j2 b/templates/operational-analysis/operational-capability.html.j2
index e237d9a..9126910 100644
--- a/templates/operational-analysis/operational-capability.html.j2
+++ b/templates/operational-analysis/operational-capability.html.j2
@@ -47,10 +47,10 @@
Involved entities and activities
To enable the Capability, the following entities and activities are involved:
-{%- set entities = object.involved_entities | list + object.involved_activities | map(attribute="owner") | unique | list -%}
+{%- set entities = object.involved_entities | list + object.involved_activities | map(attribute="owner") | unique(attribute="uuid") | list -%}
{%- if entities -%}
- {%- for entity in entities | unique -%}
+ {%- for entity in entities -%}
{%- set activities = object.involved_activities | selectattr("owner", "equalto", entity) | list -%}
{%- if activities -%}
-
diff --git a/templates/physical-architecture/sw-interface.html.j2 b/templates/physical-architecture/sw-interface.html.j2
index cbbf428..42f6c5d 100644
--- a/templates/physical-architecture/sw-interface.html.j2
+++ b/templates/physical-architecture/sw-interface.html.j2
@@ -81,7 +81,7 @@ This interface control document defines functional interactions between the foll
{% set _none = items.append(item) %}
{% endfor %}
{% endfor %}
- {% for item in items | unique %}
+ {% for item in items | unique(attribute="uuid") %}
- {{ linked_name_with_icon(item) | safe }}
{% endfor %}
diff --git a/templates/system-analysis/system-capability.html.j2 b/templates/system-analysis/system-capability.html.j2
index 6dbc353..681e840 100644
--- a/templates/system-analysis/system-capability.html.j2
+++ b/templates/system-analysis/system-capability.html.j2
@@ -42,7 +42,7 @@
This section provides a summary of what functions are required from the
System and the actors to enable the system Capability.
-{% set real_entities = object.involved_functions | selectattr("owner") | map(attribute="owner") | unique %}
+{% set real_entities = object.involved_functions | selectattr("owner") | map(attribute="owner") | unique(attribute="uuid") %}
{% for entity in real_entities %}
{{ entity.name }}
diff --git a/templates/system-analysis/system-interface.html.j2 b/templates/system-analysis/system-interface.html.j2
index a1cb6f7..d9050e9 100644
--- a/templates/system-analysis/system-interface.html.j2
+++ b/templates/system-analysis/system-interface.html.j2
@@ -16,7 +16,7 @@
{%- endif -%}
{% endfor %}
via {{ interface.name }} interface (component exchange) so that {{ linked_name(target) | safe }} could
- {%- for fnc in exchanges | map(attribute='target.owner') | unique -%}
+ {%- for fnc in exchanges | map(attribute='target.owner') | unique(attribute="uuid") -%}
{{ linked_name(fnc) | safe }}{% if not loop.last %}, {% else %} {% endif %}
{%- endfor -%}