[Fix] Filter Scenarios with Parent (#311) (#323)

The scenarios lists both in /scenarios and /package/<id>/scenario no longer show related scenarios (children).
All related scenarios are shown on the scenario page under Related Scenarios if there are any.
<img width="500" alt="{C2D38DED-A402-4A27-A241-BC2302C62A50}.png" src="attachments/1371c177-220c-42d5-94ff-56f9fbab761f">

Co-authored-by: Tim Lorsbach <tim@lorsba.ch>
Reviewed-on: enviPath/enviPy#323
Co-authored-by: Liam Brydon <lbry121@aucklanduni.ac.nz>
Co-committed-by: Liam Brydon <lbry121@aucklanduni.ac.nz>
This commit is contained in:
2026-02-11 23:19:20 +13:00
committed by jebus
parent 27c5bad9c5
commit 73f0202267
6 changed files with 139 additions and 8 deletions

View File

@ -171,6 +171,82 @@
</div>
</div>
{% if scenario.parent %}
<div class="card bg-base-100">
<div class="card-body">
<h3 class="card-title mb-4 text-lg">
Parent Scenario Additional Information
</h3>
<div
x-data="{
items: [],
schemas: {},
loading: true,
error: null,
async init() {
try {
// Use the unified API client for loading data
const { items, schemas } = await window.AdditionalInformationApi.loadSchemasAndItems('{{ scenario.parent.uuid }}');
this.items = items;
this.schemas = schemas;
} catch (err) {
this.error = err.message;
console.error('Error loading additional information:', err);
} finally {
this.loading = false;
}
},
}"
>
<!-- Loading state -->
<template x-if="loading">
<div class="flex items-center justify-center p-4">
<span class="loading loading-spinner loading-md"></span>
</div>
</template>
<!-- Error state -->
<template x-if="error">
<div class="alert alert-error mb-4">
<span x-text="error"></span>
</div>
</template>
<!-- Items list -->
<template x-if="!loading && !error">
<div class="space-y-4">
<template x-if="items.length === 0">
<p class="text-base-content/60">
No additional information available.
</p>
</template>
<template x-for="item in items" :key="item.uuid">
<div class="card bg-base-200 shadow-sm">
<div class="card-body p-4">
<div class="flex items-start justify-between">
<div
class="flex-1"
x-data="schemaRenderer({
rjsf: schemas[item.type.toLowerCase()],
data: item.data,
mode: 'view'
})"
x-init="init()"
>
{% include "components/schema_form.html" %}
</div>
</div>
</div>
</div>
</template>
</div>
</template>
</div>
</div>
</div>
{% endif %}
<!-- Pathways -->
{% if scenario.related_pathways %}
<div class="collapse-arrow bg-base-200 collapse">
@ -189,6 +265,43 @@
</div>
</div>
{% endif %}
<!-- Related Scenarios -->
{% if children.exists %}
<div class="collapse-arrow bg-base-200 collapse">
<input type="checkbox" />
<div class="collapse-title text-xl font-medium">Related Scenarios</div>
<div class="collapse-content">
<ul class="menu bg-base-100 rounded-box">
{% for s in children %}
<li>
<a href="{{ s.url }}" class="hover:bg-base-200"
>{{ s.name }} <i>({{ s.package.name }})</i></a
>
</li>
{% endfor %}
</ul>
</div>
</div>
{% endif %}
<!-- Parent Scenarios -->
{% if scenario.parent %}
<div class="collapse-arrow bg-base-200 collapse">
<input type="checkbox" />
<div class="collapse-title text-xl font-medium">Parent Scenario</div>
<div class="collapse-content">
<ul class="menu bg-base-100 rounded-box">
<li>
<a href="{{ scenario.parent.url }}" class="hover:bg-base-200"
>{{ scenario.parent.name }}
<i>({{ scenario.parent.package.name }})</i></a
>
</li>
</ul>
</div>
</div>
{% endif %}
</div>
<script>