diff --git a/frontend/src/components/TemplateCard.jsx b/frontend/src/components/TemplateCard.jsx index 583b6cb..9ed7ea6 100644 --- a/frontend/src/components/TemplateCard.jsx +++ b/frontend/src/components/TemplateCard.jsx @@ -9,7 +9,7 @@ export const TemplateCard = ({ template, onClickCallback }) => ( className="m-2 mt-6 max-w-sm cursor-pointer rounded-lg bg-gray-200 shadow-md hover:bg-custom-light dark:bg-custom-dark-2 dark:shadow-dark dark:hover:bg-custom-dark-4" >
diff --git a/templates/common_macros.html.j2 b/templates/common_macros.html.j2 index 99a0b55..258a582 100644 --- a/templates/common_macros.html.j2 +++ b/templates/common_macros.html.j2 @@ -75,3 +75,35 @@ {%- macro typed_name(object) -%}{{ object.__class__.__name__ }} {{ object.name | trim }}{%- endmacro -%} {%- macro linked_name(object) -%}{{ object.name | trim }}{%- endmacro -%} + +{%- macro display_traceability(object, complain=False) -%} + {%- set realized_attrs = [] -%} + {%- set realizing_attrs = [] -%} + {%- for attr in object.__dir__() -%} + {%- if attr.startswith("realized_") -%} + {% set _none = realized_attrs.append(attr) %} + {%- elif attr.startswith("realizing_") -%} + {% set _none = realizing_attrs.append(attr) %} + {%- endif-%} + {%- endfor -%} + {%- set realized_objects = object[realized_attrs | first] if realized_attrs else None -%} + {%- set realizing_objects = object[realizing_attrs | first] if realizing_attrs else None -%} + +
{{ object.name }} realizes the following objects:
+
{{ object.name }} doesn't seem to realize any object
+ {%- endif -%} + {% if realizing_objects %} +{{ object.name }} is realized by the following objects:
+{{ object.name }} doesn't seem to be realized by any object
+ {% endif %} +{%- endmacro -%} \ No newline at end of file diff --git a/templates/exchange-item.html.j2 b/templates/exchange-item.html.j2 new file mode 100644 index 0000000..a65b0cb --- /dev/null +++ b/templates/exchange-item.html.j2 @@ -0,0 +1,27 @@ +{# + Copyright DB InfraGO AG and contributors + SPDX-License-Identifier: Apache-2.0 +#} + +{% from 'common_macros.html.j2' import show_other_attributes, description, typed_name %} + +The exchange item "{{ object.name }}" is produced and used across the model in the following cases:
+- {{ linked_name(source) | safe }} should provide - {% for fex in exchanges %} - {{ fex.name }}{% if not loop.last %}, {% else %} and {% endif %} + {%- set unique_exchange_names = [] -%} + {{ linked_name(source) | safe }} should provide + {%- for fex in exchanges -%} + {%- if fex.name not in unique_exchange_names -%} + {{ fex.name }}{% if not loop.last %}, {% else %} {% endif %} + {%- set _none = unique_exchange_names.append(fex.name) -%} + {%- endif -%} {% endfor %} - via {{ interface.name }} interface (component exchange) so that {{ linked_name(target) | safe }} could + via {{ interface.name }} interface (component exchange) so that {{ linked_name(target) | safe }} could {%- for fnc in exchanges | map(attribute='target.owner') | unique -%} - {{ linked_name(fnc) | safe }}{% if not loop.last %}, {% else %} and {% endif %} + {{ linked_name(fnc) | safe }}{% if not loop.last %}, {% else %} {% endif %} {%- endfor -%}
{% endmacro %} @@ -46,5 +50,9 @@The functional interactions between interface partners via {{ object.name }} are summarized by the diagram below:
{{ object.context_diagram.as_svg | safe }} -{% set filtered = ["name", "description", "xtype", "allocated_functional_exchanges", "context_diagram"]%} +{{ display_traceability(object, complain=False) | safe }} + +{{ object.description }}
+{% if object.owner %} +A function of {{ linked_name(object.owner) | safe }}
{% else %} -No description available.
+This function is not allocated to any entity / no entity is responsible for it.
{% endif %} -An Entity that is responsible for providing this function: {{object.owner.name}}.
+{% if object.description %} +{{ object.description }}
{% else %} -This function is not allocated to any entity / no entity is responsible for it.
+No description available.
{% endif %}The function is available in the following Entity states:
+The function is available in the following states of the {{ linked_name(object.owner) | safe }}: