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" >
-
+
{template.name}

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 -%} + +

Traceability

+ {% if realized_objects %} +

{{ object.name }} realizes the following objects:

+

+ {%- elif complain -%} +

{{ object.name }} doesn't seem to realize any object

+ {%- endif -%} + {% if realizing_objects %} +

{{ object.name }} is realized by the following objects:

+ + {%- elif complain -%} +

{{ 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 %} + +

Exchange Item {{ object.name if object.name else "Unnamed"}}

+{{ description(object) | safe }} + +

Usage

+

The exchange item "{{ object.name }}" is produced and used across the model in the following cases:

+ + +

Other attributes

+ +{%- set excluded = ["name", "xtype", "description", "exchanges"] -%} +{{show_other_attributes(object, excluded) | safe}} diff --git a/templates/exchange-item.yaml b/templates/exchange-item.yaml new file mode 100644 index 0000000..baf759b --- /dev/null +++ b/templates/exchange-item.yaml @@ -0,0 +1,10 @@ +# Copyright DB InfraGO AG and contributors +# SPDX-License-Identifier: Apache-2.0 + +template: exchange-item.html.j2 +name: Exchange Item +description: Specifies an exchange item, i.e. energy / material / information. +category: xc +variable: + name: object + type: ExchangeItem diff --git a/templates/system-interface.html.j2 b/templates/system-interface.html.j2 index f5857d4..5460a45 100644 --- a/templates/system-interface.html.j2 +++ b/templates/system-interface.html.j2 @@ -3,17 +3,21 @@ SPDX-License-Identifier: Apache-2.0 #} -{% from 'common_macros.html.j2' import show_other_attributes, linked_name %} +{% from 'common_macros.html.j2' import show_other_attributes, linked_name, display_traceability %} {% macro describe_exchange_direction(source, target, interface, exchanges) %}

- {{ 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 }} + +

Other object attributes

+ +{% set filtered = ["name", "description", "xtype", "allocated_functional_exchanges", "context_diagram", "parent", "realizing_component_exchanges", "realized_component_exchanges"]%} {{show_other_attributes(object, filtered) | safe}} diff --git a/templates/system_function.html.j2 b/templates/system_function.html.j2 index 2493e0b..b60b099 100644 --- a/templates/system_function.html.j2 +++ b/templates/system_function.html.j2 @@ -2,26 +2,25 @@ Copyright DB InfraGO AG and contributors SPDX-License-Identifier: Apache-2.0 #} -{% from 'common_macros.html.j2' import show_other_attributes %} +{% from 'common_macros.html.j2' import show_other_attributes, linked_name %}

{{ object.name | capitalize }}

-{% if object.description %} -

{{ 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 %} -

Function owner

-{% if object.owner %} -

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 %}

Conditional availability

{% if object.available_in_states %} -

The function is available in the following Entity states:

+

The function is available in the following states of the {{ linked_name(object.owner) | safe }}: