Skip to content

Commit

Permalink
feat: filter requirements assessment by status
Browse files Browse the repository at this point in the history
  • Loading branch information
Mohamed-Hacene committed Feb 19, 2025
1 parent 554deae commit ea490d6
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,13 @@
}
return false;
}
function areAllChildrenHiddenRecursive(node: TreeViewNode): boolean {
if (!node.children || node.children.length === 0) return false;
return node.children.every(
(child) => child.contentProps.hidden || areAllChildrenHiddenRecursive(child)
);
}
</script>

{#if nodes && nodes.length > 0}
Expand All @@ -140,7 +147,9 @@
bind:group
bind:name
bind:value={node.id}
classProp={node.contentProps.hidden === true ? 'hidden' : ''}
classProp={node.contentProps.hidden === true || areAllChildrenHiddenRecursive(node)
? 'hidden'
: ''}
mappingInference={hasMappingInference(node)}
hideLead={!node.lead}
hideChildren={!node.children || node.children.length === 0}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,19 +106,24 @@
return resultCounts;
};
const filterStatus = ['done', 'to_do'];
function transformToTreeView(nodes: Node[]) {
return nodes.map(([id, node]) => {
node.resultCounts = countResults(node);
const hasAssessableChildren = Object.keys(node.children || {}).length > 0;
const hidden = !(!$displayOnlyAssessableNodes || node.assessable || hasAssessableChildren);
const hidden =
!(!$displayOnlyAssessableNodes || node.assessable || hasAssessableChildren) ||
(!filterStatus.includes(node.status) && node.assessable);
return {
id: id,
content: TreeViewItemContent,
contentProps: {
...node,
canEditRequirementAssessment,
hidden
hidden,
filterStatus
},
lead: TreeViewItemLead,
leadProps: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
export let reference_controls: z.infer<typeof ReferenceControlSchema>[] | undefined = undefined;
export let children: Record<string, Record<string, unknown>> | undefined = undefined;
export let canEditRequirementAssessment: boolean;
export let filterStatus: string[][];
export let resultCounts: Record<string, number> | undefined;
export let assessable: boolean;
export let max_score: number;
Expand Down Expand Up @@ -155,14 +156,14 @@
</div>
<div>
{#if hasAssessableChildren}
{#each Object.entries(complianceStatusColorMap) as status}
{#if resultCounts[status[0]]}
{#each Object.entries(complianceStatusColorMap) as [status, color]}
{#if resultCounts[status] && filterStatus.includes(status)}
<span
class="badge mr-1"
style="background-color: {status[1] + '44'}; color: {darkenColor(status[1], 0.3)}"
style="background-color: {color + '44'}; color: {darkenColor(color, 0.3)}"
>
{resultCounts[status[0]]}
{safeTranslate(status[0])}
{resultCounts[status]}
{safeTranslate(status)}
</span>
{/if}
{/each}
Expand Down

0 comments on commit ea490d6

Please sign in to comment.