Skip to content

Commit

Permalink
[VAS] Story 8084: add orphan node in filing leaves tree view
Browse files Browse the repository at this point in the history
  • Loading branch information
laedanrex committed Jul 20, 2023
1 parent 0426a22 commit 1243447
Show file tree
Hide file tree
Showing 49 changed files with 970 additions and 689 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
@SpringBootApplication
@EnableDiscoveryClient
public class ArchiveSearchApplication implements CommandLineRunner {

@Autowired
private Environment env;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,6 @@
* knowledge of the CeCILL-C license and that you accept its terms.
*/
export * from './node.interface';
export * from './node.utils';
export * from './vitamui-tree-node.component';
export * from './vitamui-tree-node.module';
Original file line number Diff line number Diff line change
Expand Up @@ -35,67 +35,35 @@
* knowledge of the CeCILL-C license and that you accept its terms.
*/

import {Id} from '../../models';
import { Id } from '../../models';

export interface FilingHoldingSchemeNode extends Id {
title: string;
/** @deprecated: use unitType & descriptionLevel instead */
type: string;
unitType?: string;
descriptionLevel?: string;
label?: string;
children: FilingHoldingSchemeNode[];
vitamId: string;

// DISPLAY
disabledChild?: boolean;
disabled?: boolean;
checked: boolean;
disabledChild?: boolean; // TODO: try to remove - used in VitamuiTreeNodeComponent to set indeterminate
disabled?: boolean; // used in VitamuiTreeNodeComponent to disable mat-icon-button & mat-checkbox
checked: boolean; // used in VitamuiTreeNodeComponent to set ngModel of mat-checkbox
count?: number;
hidden?: boolean;

hidden?: boolean; // TODO: try to remove - may be unused
isLoadingChildren?: boolean;
// help to keep tracks on what has been loaded
paginatedChildrenLoaded?: number;
canLoadMoreChildren?: boolean;

paginatedMatchingChildrenLoaded?: number;
canLoadMoreMatchingChildren?: boolean;

toggled?: boolean;

// help to detect the unit type and the icon to show
hasObject?: boolean;
unitType?: string;
parents?: FilingHoldingSchemeNode[];
// help to keep tracks on what has been loaded
paginatedChildrenLoaded?: number; // number of element loaded under a node without criterias
canLoadMoreChildren?: boolean;
paginatedMatchingChildrenLoaded?: number; // number of element loaded under a node with main request search criterias
canLoadMoreMatchingChildren?: boolean;
}

export const nodeHasChildren = (node: FilingHoldingSchemeNode): boolean => {
return node.children && node.children.length > 0;
};

export const nodeHasMatch = (node: FilingHoldingSchemeNode): boolean => {
return node.count && node.count > 0;
};

export const copyNodeWithoutChildren = (node: FilingHoldingSchemeNode): FilingHoldingSchemeNode => {
return {
id: node.id,
title: node.title,
type: node.type,
label: node.label,
children: null,
vitamId: node.vitamId,
checked: node.checked,
count: node.count,

hasObject: node?.hasObject,
unitType: node?.unitType,

hidden: node.hidden,
isLoadingChildren: false,
canLoadMoreChildren: true,
canLoadMoreMatchingChildren: true,
};
};

export class MatchingNodesNumbers {
nodesAdded: number;
nodesAddedList: FilingHoldingSchemeNode[];
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
/**
* Copyright French Prime minister Office/SGMAP/DINSIC/Vitam Program (2015-2022)
*
* contact.vitam@culture.gouv.fr
*
* This software is a computer program whose purpose is to implement a digital archiving back-office system managing
* high volumetry securely and efficiently.
*
* This software is governed by the CeCILL 2.1 license under French law and abiding by the rules of distribution of free
* software. You can use, modify and/ or redistribute the software under the terms of the CeCILL 2.1 license as
* circulated by CEA, CNRS and INRIA at the following URL "https://cecill.info".
*
* As a counterpart to the access to the source code and rights to copy, modify and redistribute granted by the license,
* users are provided only with a limited warranty and the software's author, the holder of the economic rights, and the
* successive licensors have only limited liability.
*
* In this respect, the user's attention is drawn to the risks associated with loading, using, modifying and/or
* developing or reproducing the software by the user in light of its specific status of free software, that may mean
* that it is complicated to manipulate, and that also therefore means that it is reserved for developers and
* experienced professionals having in-depth computer knowledge. Users are therefore encouraged to load and test the
* software's suitability as regards their requirements in conditions enabling the security of their systems and/or data
* to be ensured and, more generally, to use and operate it in the same conditions as regards security.
*
* The fact that you are presently reading this means that you have had knowledge of the CeCILL 2.1 license and that you
* accept its terms.
*/
import { unitTypeToVitamuiIcon } from '../../models';
import { VitamuiIcons } from '../../vitamui-icons.enum';
import { FilingHoldingSchemeNode } from './node.interface';

export function nodeToVitamuiIcon(node: FilingHoldingSchemeNode): VitamuiIcons {
return unitTypeToVitamuiIcon(node.unitType, node.hasObject);
}

export const nodeHasChildren = (node: FilingHoldingSchemeNode): boolean => {
return node.children && node.children.length > 0;
};

export const nodeHasMatch = (node: FilingHoldingSchemeNode): boolean => {
return node.count && node.count > 0;
};

export const copyNodeWithoutChildren = (node: FilingHoldingSchemeNode): FilingHoldingSchemeNode => {
return {
id: node.id,
title: node.title,
type: node.type,
label: node.label,
children: null,
vitamId: node.vitamId,
checked: node.checked,
count: node.count,

hasObject: node?.hasObject,
unitType: node?.unitType,

hidden: node.hidden,
isLoadingChildren: false,
canLoadMoreChildren: true,
canLoadMoreMatchingChildren: true,
};
};

export function recursiveCheck(nodes: FilingHoldingSchemeNode[], show: boolean) {
if (!nodes || nodes.length === 0) {
return;
}
for (const node of nodes) {
node.hidden = false;
node.checked = show;
node.count = null;
this.recursiveCheck(node.children, show);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export class VitamuiTreeNodeComponent implements AfterContentChecked {
@Input() icon: string;
@Input() expanded: boolean;
@Input() disabled: boolean;
@Input() hasCheckBox = true;
@Input() labelIsLinkedToCheckbox = false;
@Output() nodeToggle = new EventEmitter<void>();
@Output() checkboxClick = new EventEmitter<void>();
Expand Down
1 change: 0 additions & 1 deletion ui/ui-frontend-common/src/app/modules/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,4 +119,3 @@ export * from './vitamui-global-error-handler';
export * from './vitamui-icons.enum';
export * from './vitamui-roles.enum';
export * from './vitamui-table/index';
export * from './vitamui-unit-types.enum';
7 changes: 4 additions & 3 deletions ui/ui-frontend-common/src/app/modules/models/units/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export * from './unit-api.interface';
export * from './object-group.interface';
export * from './object-group.utils';
export * from './unit.enums';
export * from './unit-object-api.interface';
export * from './unit-object-helper';
export * from './unit.interface';
export * from './unit.utils';
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@
* accept its terms.
*/

import {ObjectQualifierType} from './unit.enums';
import { ObjectQualifierType } from './unit.enums';

// TODO: rename in ObjectGroup
/** Object associated to a unit */
export interface ApiUnitObject {
'#id': string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@
* accept its terms.
*/

import {QualifierDto, VersionDto} from './unit-object-api.interface';
import {qualifiersToVersionsWithQualifier} from './unit-object-helper';
import {ObjectQualifierType} from './unit.enums';
import { QualifierDto, VersionDto } from './object-group.interface';
import { qualifiersToVersionsWithQualifier } from './object-group.utils';
import { ObjectQualifierType } from './unit.enums';

describe('unit-object-helper tests', () => {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
* The fact that you are presently reading this means that you have had knowledge of the CeCILL 2.1 license and that you
* accept its terms.
*/
import {QualifierDto, VersionDto, VersionWithQualifierDto} from './unit-object-api.interface';
import {ObjectQualifierTypeList} from './unit.enums';
import { QualifierDto, VersionDto, VersionWithQualifierDto } from './object-group.interface';
import { ObjectQualifierTypeList } from './unit.enums';

export function qualifiersToVersionsWithQualifier(qualifiers: Array<QualifierDto>): Array<VersionWithQualifierDto> {
if (!qualifiers || qualifiers.length < 1) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,9 @@ export enum ObjectQualifierType {
}

export const ObjectQualifierTypeList: Array<string> = Object.values(ObjectQualifierType);

export enum UnitTypes {
HOLDING_UNIT = 'HOLDING_UNIT',
FILING_UNIT = 'FILING_UNIT',
INGEST = 'INGEST',
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*
/**
* Copyright French Prime minister Office/SGMAP/DINSIC/Vitam Program (2015-2022)
*
* contact.vitam@culture.gouv.fr
Expand All @@ -24,9 +24,24 @@
* The fact that you are presently reading this means that you have had knowledge of the CeCILL 2.1 license and that you
* accept its terms.
*/
import { VitamuiIcons } from '../../vitamui-icons.enum';
import { UnitTypes } from './unit.enums';
import { Unit } from './unit.interface';

export enum VitamuiUnitTypes {
HOLDING_UNIT = 'HOLDING_UNIT',
FILING_UNIT = 'FILING_UNIT',
INGEST = 'INGEST',
export function unitToVitamuiIcon(unit: Unit): VitamuiIcons {
const hasObject = unit['#object'] && unit['#object'].length > 0;
return unitTypeToVitamuiIcon(unit['#unitType'], hasObject);
}

export function unitTypeToVitamuiIcon(unitType: string, hasObject: boolean): VitamuiIcons {
if (unitType === UnitTypes.HOLDING_UNIT) {
return VitamuiIcons.HOLDING_UNIT;
}
if (unitType === UnitTypes.FILING_UNIT) {
return VitamuiIcons.FILING_UNIT;
}
if (unitType === UnitTypes.INGEST && hasObject) {
return VitamuiIcons.INGEST_WITH_OBJECT;
}
return VitamuiIcons.INGEST_WITHOUT_OBJECT;
}
8 changes: 4 additions & 4 deletions ui/ui-frontend-common/src/app/modules/vitamui-icons.enum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
*/

export enum VitamuiIcons {
VITAMUI_HOLDING_UNIT_ICON_ = 'vitamui-icon-icone-arbre',
VITAMUI_FILING_UNIT_ICON_ = 'vitamui-icon-plan-classement',
VITAMUI_INGEST_WITHOUT_OBJECT_ICON_ = 'vitamui-icon-folder',
VITAMUI_INGEST_WITH_OBJECT_ICON_ = 'vitamui-icon-file',
HOLDING_UNIT = 'vitamui-icon-icone-arbre',
FILING_UNIT = 'vitamui-icon-plan-classement',
INGEST_WITHOUT_OBJECT = 'vitamui-icon-folder',
INGEST_WITH_OBJECT = 'vitamui-icon-file',
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
[title]="
(archiveUnit?.Title ? archiveUnit?.Title : archiveUnit.Title_.fr ? archiveUnit.Title_.fr : archiveUnit.Title_.en) | truncate : 29
"
[icon]="getArchiveUnitIcone(archiveUnit)"
[icon]="getArchiveUnitIcon(archiveUnit)"
[hasToolTipOnTitle]="true"
[toolTipTitleText]="archiveUnit?.Title ? archiveUnit?.Title : archiveUnit.Title_.fr ? archiveUnit.Title_.fr : archiveUnit.Title_.en"
[toolTipTitleDuration]="300"
Expand Down Expand Up @@ -46,8 +46,7 @@

<mat-tab label="{{ 'ARCHIVE_SEARCH.ARCHIVE_UNIT_PREVIEW.TABS.RULES' | translate }}">
<app-archive-unit-rules-details-tab
[archiveUnit]="archiveUnit"
[accessContract]="accessContract">
[archiveUnit]="archiveUnit">
</app-archive-unit-rules-details-tab>
</mat-tab>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ describe('ArchivePreviewComponent', () => {
beforeEach(() => {
fixture = TestBed.createComponent(ArchivePreviewComponent);
component = fixture.componentInstance;
const archiveUnit: Unit = {
component.archiveUnit = {
'#allunitups': [],
'#id': 'id',
'#object': '',
Expand All @@ -119,7 +119,6 @@ describe('ArchivePreviewComponent', () => {
Title_: { fr: 'Teste', en: 'Test' },
Description_: { fr: 'DescriptionFr', en: 'DescriptionEn' },
};
component.archiveUnit = archiveUnit;
fixture.detectChanges();
});

Expand Down Expand Up @@ -197,61 +196,12 @@ describe('ArchivePreviewComponent', () => {
};

// When
const response = component.getArchiveUnitIcone(archiveUnit);
const response = component.getArchiveUnitIcon(archiveUnit);

// Then
expect(response).toEqual(expectedResponse);
});

it('should return INGEST as response ', () => {
const archiveUnit: Unit = {
'#id': 'aeaqaaaaaehlvxukaazfaame7fyo5myaaaba',
Title: 'Porte de Bagnolet par producteur1',
DescriptionLevel: 'RecordGrp',
Description: 'Station Porte de Bagnolet ligne 3 Paris',
'#tenant': 1,
'#unitups': ['aeaqaaaaaehlvxukaazfaame7fyo5myaaaca'],
'#min': 1,
'#max': 2,
'#allunitups': ['aeaqaaaaaehlvxukaazfaame7fyo5myaaaca'],
'#unitType': 'INGEST',
'#operations': ['aeeaaaaaaghnanqdabliwame7fyokjqaaaaq'],
'#opi': 'aeeaaaaaaghnanqdabliwame7fyokjqaaaaq',
'#originating_agency': 'producteur1',
'#originating_agencies': ['producteur1'],
'#management': {
AppraisalRule: null,
HoldRule: null,
StorageRule: null,
ReuseRule: null,
ClassificationRule: null,
DisseminationRule: null,
AccessRule: null,
UpdateOperation: null,
},
StartDate: new Date('2016-06-03T15:28:00'),
EndDate: new Date('2016-06-03T15:28:00'),
Xtag: [],
Vtag: [],
'#storage': {
strategyId: 'default',
},
'#qualifiers': [],
OriginatingSystemId: ['OriginatingSystemId_00'],
PhysicalAgency: [],
PhysicalStatus: [],
PhysicalType: [],
Keyword: [],
'#approximate_creation_date': '2022-12-10T00:30:42.568',
'#approximate_update_date': '2022-12-10T00:30:42.568',
originating_agencyName: 'Service producteur1',
};

const response = component.getArchiveUnitType(archiveUnit);

expect(response).toEqual('INGEST');
});

describe('DOM', () => {
it('should have 3 mat-tab', () => {
// When
Expand Down
Loading

0 comments on commit 1243447

Please sign in to comment.