Skip to content

Commit

Permalink
fix: requirement assessed at top level
Browse files Browse the repository at this point in the history
  • Loading branch information
Mohamed-Hacene committed Apr 9, 2024
1 parent 899317d commit 998b4a3
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 11 deletions.
5 changes: 5 additions & 0 deletions backend/core/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,11 +230,16 @@ def get_sorted_requirement_nodes_rec(
for requirement_node in requirement_nodes
if requirement_node.parent_urn == node.urn
]
req_as = requirement_assessment_from_requirement_id[str(node.id)] if requirements_assessed else None
result[str(node.id)] = {
"urn": node.urn,
"parent_urn": node.parent_urn,
"ref_id": node.ref_id,
"name": node.name,
"ra_id": str(req_as.id) if requirements_assessed else None,
"status": req_as.status if requirements_assessed else None,
"status_display": req_as.get_status_display() if requirements_assessed else None,
"status_i18n": camel_case(req_as.status) if requirements_assessed else None,
"node_content": node.display_long,
"style": "node",
"assessable": node.assessable,
Expand Down
9 changes: 9 additions & 0 deletions frontend/src/lib/utils/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,12 @@ export const isURL = (url: string) => {
return false;
}
};

export function getRequirementTitle(ref_id: string, name: string) {
const pattern = (ref_id ? 2 : 0) + (name ? 1 : 0)
const title: string =
pattern == 3 ? `${ref_id} - ${name}` :
pattern == 2 ? ref_id :
pattern == 1 ? name : '';
return title;
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<script lang="ts">
import { getRequirementTitle } from "$lib/utils/helpers";
export let ref_id: string;
export let name: string;
export let description: string;
Expand Down Expand Up @@ -35,11 +36,7 @@
const assessableNodes = getAssessableNodes(node);
const pattern = (ref_id ? 2 : 0) + (name ? 1 : 0)
const title: string =
pattern == 3 ? `${ref_id} - ${name}` :
pattern == 2 ? ref_id :
pattern == 1 ? name : '';
const title: string = getRequirementTitle(ref_id, name);
let showInfo = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,18 @@
import { languageTag } from '$paraglide/runtime';
import * as m from '$paraglide/messages';
import { getRequirementTitle } from '$lib/utils/helpers';
function cancel(): void {
var currentUrl = window.location.href;
var url = new URL(currentUrl);
var nextValue = url.searchParams.get('next');
if (nextValue) window.location.href = nextValue;
}
const title =
(data.parent.display_short ? data.parent.display_short + ': ' : '') +
data.requirement.display_short;
const title = getRequirementTitle(data.requirement.ref_id, data.requirement.name) ?
getRequirementTitle(data.requirement.ref_id, data.requirement.name) :
getRequirementTitle(data.parent.ref_id, data.parent.name);
breadcrumbObject.set({
id: data.requirementAssessment.id,
name: title ?? 'Requirement assessment',
Expand Down Expand Up @@ -145,9 +147,6 @@
</script>

<div class="card space-y-2 p-4 bg-white shadow">
<h3 class="h3 font-semibold whitespace-pre-line">
{title}
</h3>
<code class="code">{data.requirement.urn}</code>
{#if data.requirement.description}
<p class="whitespace-pre-line">{data.requirement.description}</p>
Expand Down

0 comments on commit 998b4a3

Please sign in to comment.