Skip to content

Commit

Permalink
feat: default templates
Browse files Browse the repository at this point in the history
  • Loading branch information
vik378 committed Apr 23, 2024
1 parent 8681682 commit 13184ad
Show file tree
Hide file tree
Showing 5 changed files with 83 additions and 26 deletions.
6 changes: 5 additions & 1 deletion templates/common_macros.html.j2
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,12 @@

{% macro description(obj) %}
{% if obj.description %}
{{ obj.description | safe }}
<p>{{ obj.description | safe }}</p>
{% else %}
<p style="color:red">No description available.</p>
{% endif %}
{% endmacro %}

{% macro typed_name(object) %}
<b>{{ object.__class__.__name__ }}</b> <a href="{{ object | make_href }}">{{ object.name }}</a>
{% endmacro %}
12 changes: 2 additions & 10 deletions templates/logical-component.html.j2
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,10 @@
Copyright DB InfraGO AG and contributors
SPDX-License-Identifier: Apache-2.0
#}
{% from 'common_macros.html.j2' import show_other_attributes %}

{% macro description(obj) %}
{% if obj.description %}
<p>{{ obj.description }}</p>
{% else %}
<p style="color:red">No description available.</p>
{% endif %}
{% endmacro %}
{% from 'common_macros.html.j2' import show_other_attributes, description %}

<h1>{{ object.name }}</h1>
{{ description(object) }}
{{ description(object) | safe }}

<h2>Logical Component Context</h2>

Expand Down
31 changes: 31 additions & 0 deletions templates/operational-activity.html.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{#
Copyright DB InfraGO AG and contributors
SPDX-License-Identifier: Apache-2.0
#}
{% from 'common_macros.html.j2' import show_other_attributes, description %}

<h1>{{ object.name }}</h1>
{{ description(object) | safe }}

{% if object.owner %}
<p>This activity is performed by
<b>{{ object.owner.__class__.__name__}}</b>
<a href="{{ object.owner | make_href }}">{{ object.owner.name }}</a>.
</p>
{%%}
{% else %}
<p style="color: red;">No entity is responsible for performing this activity at the moment.</p>
{% endif %}


<h2>Operational Activity Context</h2>

<p>
The figure below provides an overview of the interactions between the activity of interest and other activities.
</p>

{{ object.context_diagram.as_svg|safe }}

<h2>Other properties of "{{ object.name }}"</h2>
{% set excluded = ["name", "context_diagram", "xtype", "parent"] %}
{{ show_other_attributes(object, excluded) | safe }}
11 changes: 11 additions & 0 deletions templates/operational-activity.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Copyright DB InfraGO AG and contributors
# SPDX-License-Identifier: Apache-2.0

template: operational-activity.html.j2
name: Operational Activity
description: Specifies an operational activity.
category: oa
variable:
name: object
type: OperationalActivity
below: oa
49 changes: 34 additions & 15 deletions templates/operational-entity.html.j2
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
{% from 'common_macros.html.j2' import show_other_attributes, description, render_reqs_by_type %}
{% from 'common_macros.html.j2' import show_other_attributes, description, render_reqs_by_type, typed_name %}

<h1>{{ object.name }}</h1>
{{ description(object) | safe }}

<p style="margin-top:1.5em; "><b>Parent:</b> {{object.parent._short_html_()}}</p>
<p style="margin-top:1.5em; "><b>Parent:</b> {{ typed_name(object.parent) | safe }}</p>

{% if object.capabilities %}
<p><b>{{ object.name }}</b> is involved in the following operational capabilities:
<p><i>{{ object.name }} {% if object.is_human %}(human){% endif %}</i> is involved in the following operational capabilities:
{%- for cap in object.capabilities -%}
<a href="{{ cap | make_href }}">{{ cap.name }}</a>;
{%- endfor -%}
</p>
{% endif %}

{% if object.state_machines %}
<h2>State Machines</h2>
<p>The following state machines describe the entity modes and states:</p>
<h2>States and Modes</h2>
<p>The following state machines describe modes and states of <i>{{ object.name }}</i>:</p>
{% for stm in object.state_machines %}
<h3>{{ stm.name }}</h3>
{% if stm.regions | length > 1 %}
Expand All @@ -28,8 +28,8 @@
{% elif stm.regions | length == 1 %}
{% set region = stm.regions | first %}
<ul>
{% for state in region.states %}
<li>{{ state._short_html_() }}: {{ description(state) | safe }}</li>
{% for state in region.states if state.__class__.__name__ in ["State", "Mode"] %}
<li><b>{{ state.__class__.__name__ }}</b> <a href="{{ state | make_href }}">{{ state.name }}</a>{{ ": " + state.description | safe if state.description else ""}}
{% endfor %}
</ul>
{% else %}
Expand All @@ -39,18 +39,26 @@
{% endif %}

{% if object.activities %}
<h2>Operational Activities</h2>
<p><b>{{object.name}}</b> is responsible for the following operational activities:</p>
<h2>Activities</h2>
<p><i>{{object.name}}</i> is responsible for the following operational activities:</p>
<ul>
{% for activity in object.activities %}
<li>
<a href="{{ activity | make_href }}">{{activity.name}}</a>: {{ description(activity) | safe }}
<p><b>{{ activity.name }}</b> is involved in the following operational capabilities:
<a href="{{ activity | make_href }}">{{activity.name}}</a>{{ ": " + activity.description | safe if activity.description else ""}}
{%- set involving_caps = [] -%}
{%- for cap in object.capabilities -%}
{%- if activity in cap.involved_activities -%}
<a href="{{ cap | make_href }}">{{ cap.name }}</a>;
{%- endif -%}
{%- if activity in cap.involved_activities -%}
{%- set _ = involving_caps.append(cap) -%}
{%- endif -%}
{%- endfor -%}
{%- if involving_caps -%}
<p>involving operational capabilities:
{%- for cap in object.capabilities -%}
{%- if activity in cap.involved_activities -%}
<a href="{{ cap | make_href }}">{{ cap.name }}</a>;
{%- endif -%}
{%- endfor -%}
{%- endif -%}
</p>
</li>
{% endfor %}
Expand All @@ -74,5 +82,16 @@
</ul>
{% endif %}

{% set filtered = ["description", "xtype", "entities", "owner", "parent", "parts", "requirements", "state_machines", "activities", "capabilities", "name"]%}
{% if object.realizing_system_components %}
<h2>Realizations of {{ object.name }}</h2>
<p><i>{{object.name}}</i> is realized by the following system components:</p>
<ul>
{% for comp in object.realizing_system_components %}
<li><a href="{{ comp | make_href }}">{{comp.name}}</a></li>
{% endfor %}
{% endif%}

<h2>Other attributes</h2>

{% set filtered = ["description", "realizing_system_components", "realizing_components", "xtype", "is_actor", "is_human", "entities", "owner", "parent", "parts", "requirements", "state_machines", "activities", "capabilities", "name"]%}
{{ show_other_attributes(object, filtered) | safe}}

0 comments on commit 13184ad

Please sign in to comment.