Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -153,19 +153,6 @@ export class FilingHoldingSchemeComponent implements OnInit, OnDestroy {

FilingHoldingSchemeHandler.setCountRecursively(this.nestedDataSourceLeaves.data, facets);

const withKeyValueNodes = this.nestedDataSourceLeaves.data.filter((node) => node.unitType === UnitType.WITH_KEY_VALUE);
if (!isEmpty(withKeyValueNodes)) {
this.nestedDataSourceLeaves.data = FilingHoldingSchemeHandler.removeWithKeyValueNodeFromTree(
this.nestedDataSourceLeaves.data,
withKeyValueNodes,
);
FilingHoldingSchemeHandler.addKeyValueNodeFromTree(
this.nestedDataSourceLeaves.data,
withKeyValueNodes,
this.translateService.instant('COLLECT.FILING_SCHEMA.KEY_VALUE_NODE'),
withKeyValueNodes.length,
);
}
this.addOrRemoveOrphansNode(numberOfOrphanNodes);
}),
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,12 +166,7 @@ export class LeavesTreeComponent implements OnInit, OnChanges, OnDestroy {
return;
}
if (this.firstToggle(node)) {
if (node.id === 'KEY_VALUE_NODE') {
node.canLoadMoreChildren = false;
node.canLoadMoreMatchingChildren = false;
} else {
await this.leavesTreeService.loadNodeChildrenOnFirstToggle(node, this.showEveryNodes);
}
await this.leavesTreeService.loadNodeChildrenOnFirstToggle(node, this.showEveryNodes);
this.refreshTreeNodes();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ import { UnitType } from '../units';
import { DescriptionLevel } from '../../../../lib/models/description-level.enum';

export const ORPHANS_NODE_ID = 'ORPHANS_NODE';
export const KEY_VALUE_NODE_ID = 'KEY_VALUE_NODE';
export const PATH_SEPARATOR = '/';

export class FilingHoldingSchemeHandler {
Expand Down Expand Up @@ -177,39 +176,6 @@ export class FilingHoldingSchemeHandler {
}
}

public static addKeyValueNodeFromTree(
parentNodes: FilingHoldingSchemeNode[],
childrenNodes: FilingHoldingSchemeNode[],
nodeTitle: string,
count: number,
): void {
const existingNode = parentNodes.find((node) => node.vitamId === 'KEY_VALUE_NODE');

if (!existingNode) {
const nodeWithKeyValue: FilingHoldingSchemeNode = {
checked: false,
children: childrenNodes,
id: KEY_VALUE_NODE_ID,
title: nodeTitle,
vitamId: KEY_VALUE_NODE_ID,
count: count,
};
parentNodes.unshift(nodeWithKeyValue);
} else {
existingNode.count = count;
}
}

public static removeWithKeyValueNodeFromTree(
source: FilingHoldingSchemeNode[],
toRemove: FilingHoldingSchemeNode[],
): FilingHoldingSchemeNode[] {
if (!isEmpty(source) && !isEmpty(toRemove)) {
return source.filter((parent) => !toRemove.some((child) => parent.id === child.id));
}
return source;
}

public static removeOrphansNodeFromTree(parentNodes: FilingHoldingSchemeNode[]) {
if (isEmpty(parentNodes) || !FilingHoldingSchemeHandler.isOrphansNode(parentNodes[0])) {
return;
Expand Down
Loading