Skip to content

Commit

Permalink
Merge pull request #1211 from eclipse-tractusx/chore/#1105-fe-adjust-…
Browse files Browse the repository at this point in the history
…contract-asset-reference

chore(contracts): 1105 adjust part reference in contracts
  • Loading branch information
ds-mmaul authored Jul 16, 2024
2 parents edde1a7 + 073b1ab commit 35b14aa
Show file tree
Hide file tree
Showing 10 changed files with 27 additions and 44 deletions.
24 changes: 16 additions & 8 deletions frontend/src/app/mocks/services/admin-mock/admin.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,8 @@ export const getContracts = (): PaginationResponse<ContractResponse> => {
"creationDate": "2024-02-26T13:38:07+01:00",
"endDate": null,
"state": ContractState.FINALIZED,
"policy": "jsontextaspolicy"
'policy': 'jsontextaspolicy',
'globalAssetId': 'uuid-1',
},
{
"contractId": "abc2",
Expand All @@ -235,7 +236,8 @@ export const getContracts = (): PaginationResponse<ContractResponse> => {
"creationDate": "2022-05-01T12:34:12",
"endDate": null,
"state": ContractState.FINALIZED,
"policy": "jsontextaspolicy"
'policy': 'jsontextaspolicy',
'globalAssetId': 'uuid-2',
},
{
"contractId": "abc3",
Expand All @@ -244,7 +246,8 @@ export const getContracts = (): PaginationResponse<ContractResponse> => {
"creationDate": "2022-05-01T12:34:12",
"endDate": null,
"state": ContractState.FINALIZED,
"policy": "jsontextaspolicy"
'policy': 'jsontextaspolicy',
'globalAssetId': 'uuid-3',
},
{
"contractId": "abc4",
Expand All @@ -253,7 +256,8 @@ export const getContracts = (): PaginationResponse<ContractResponse> => {
"creationDate": "2022-05-01T12:34:12",
"endDate": null,
"state": ContractState.FINALIZED,
"policy": "jsontextaspolicy"
'policy': 'jsontextaspolicy',
'globalAssetId': 'uuid-4',
},
{
"contractId": "abc5",
Expand All @@ -262,7 +266,8 @@ export const getContracts = (): PaginationResponse<ContractResponse> => {
"creationDate": "2022-05-01T12:34:12",
"endDate": null,
"state": ContractState.FINALIZED,
"policy": "jsontextaspolicy"
'policy': 'jsontextaspolicy',
'globalAssetId': 'uuid-5',
},
{
"contractId": "abc6",
Expand All @@ -271,7 +276,8 @@ export const getContracts = (): PaginationResponse<ContractResponse> => {
"creationDate": "2022-05-01T12:34:12",
"endDate": null,
"state": ContractState.FINALIZED,
"policy": "jsontextaspolicy"
'policy': 'jsontextaspolicy',
'globalAssetId': 'uuid-6',
},
{
"contractId": "abc7",
Expand All @@ -280,7 +286,8 @@ export const getContracts = (): PaginationResponse<ContractResponse> => {
"creationDate": "2022-05-01T12:34:12",
"endDate": null,
"state": ContractState.FINALIZED,
"policy": "jsontextaspolicy"
'policy': 'jsontextaspolicy',
'globalAssetId': 'uuid-7',
},
{
"contractId": "abc8",
Expand All @@ -289,7 +296,8 @@ export const getContracts = (): PaginationResponse<ContractResponse> => {
"creationDate": "2022-05-01T12:34:12",
"endDate": null,
"state": ContractState.FINALIZED,
"policy": "jsontextaspolicy"
'policy': 'jsontextaspolicy',
'globalAssetId': 'uuid-8',
},
{
"contractId": "abc9",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@ describe('TableSettingsService', () => {

it('should return PartsAsPlannedConfigurationModel for AS_PLANNED_OWN', () => {
const result: TableViewConfig = service.initializeTableViewSettings(TableType.AS_PLANNED_OWN);
expect(result.displayedColumns.length).toBe(21);
expect(result.displayedColumns.length).toBe(20);
});

it('should return PartsAsBuiltConfigurationModel for AS_BUILT_OWN', () => {
const result: TableViewConfig = service.initializeTableViewSettings(TableType.AS_BUILT_OWN);
expect(result.displayedColumns.length).toBe(23);
expect(result.displayedColumns.length).toBe(22);
});

it('should return NotificationsSentConfigurationModel for SENT_NOTIFICATION', () => {
Expand Down
9 changes: 6 additions & 3 deletions frontend/src/app/modules/page/admin/core/admin.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ export interface Contract {
creationDate: CalendarDateModel,
endDate: CalendarDateModel,
state: ContractState,
policy: string
policy: string,
globalAssetId?: string,
}

export interface ContractResponse {
Expand All @@ -69,7 +70,8 @@ export interface ContractResponse {
creationDate: string,
endDate: string,
state: ContractState,
policy: string
policy: string,
globalAssetId?: string,
}

export enum ContractType {
Expand All @@ -90,7 +92,8 @@ export function assembleContract(contractResponse: ContractResponse): Contract {
creationDate: new CalendarDateModel(contractResponse.creationDate),
endDate: new CalendarDateModel(contractResponse.endDate),
state: contractResponse.state,
policy: contractResponse.policy
policy: contractResponse.policy,
globalAssetId: contractResponse.globalAssetId,
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,8 @@ describe('ContractTableComponent', () => {

let result = componentInstance.convertArrayOfObjectsToCSV([ getContracts().content[0] ]);

expect(result).toEqual('contractId,contractType,counterpartyAddress,creationDate,endDate,state,policy\n' +
'abc1,ASSET_AS_BUILT,https://trace-x-edc-e2e-a.dev.demo.catena-x.net/api/v1/dsp,2024-02-26T13:38:07+01:00,,Finalized,jsontextaspolicy');
expect(result).toEqual('contractId,contractType,counterpartyAddress,creationDate,endDate,state,policy,globalAssetId\n' +
'abc1,ASSET_AS_BUILT,https://trace-x-edc-e2e-a.dev.demo.catena-x.net/api/v1/dsp,2024-02-26T13:38:07+01:00,,Finalized,jsontextaspolicy,uuid-1');

});
it('should download CSV file', async () => {
Expand Down Expand Up @@ -186,21 +186,6 @@ describe('ContractTableComponent', () => {
expect(toastServiceMock.error).toHaveBeenCalledWith('pageAdmin.contracts.noItemsFoundError');
});


it('should show error when contractType is not NOTIFICATION and no parts are found', async () => {
partsServiceMock.getPartsByFilter.and.returnValue(of({ content: [] }));

const { fixture } = await renderContractTableComponent();
const { componentInstance } = fixture;
const data = { contractId: 'contract-id', contractType: ContractType.ASSET_AS_BUILT };

componentInstance.viewItemsClicked.emit(data);
fixture.detectChanges();

expect(partsServiceMock.getPartsByFilter).toHaveBeenCalledWith({ contractAgreementId: 'contract-id' }, true);
expect(toastServiceMock.error).toHaveBeenCalledWith('pageAdmin.contracts.noItemsFoundError');
});

it('should filter contract type', async () => {
const { fixture } = await renderContractTableComponent();
const { componentInstance } = fixture;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,7 @@ export class ContractsComponent {
},
);
} else {
this.partsService.getPartsByFilter({ contractAgreementId: contractId }, data?.contractType === ContractType.ASSET_AS_BUILT).subscribe({
next: data => {
data?.content?.length > 0 ? this.router.navigate([ 'parts', data?.content[0]?.id ], { queryParams: { isAsBuilt: data?.content[0]?.partId !== undefined } }) : this.toastService.error('pageAdmin.contracts.noItemsFoundError');
},
error: error => this.toastService.error(error),

});
this.router.navigate([ 'parts', data?.globalAssetId ], { queryParams: { isAsBuilt: data?.contractType === ContractType.ASSET_AS_BUILT } });
}
});

Expand Down
2 changes: 0 additions & 2 deletions frontend/src/app/modules/page/parts/model/parts.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ export interface Part {
owner: Owner;
semanticDataModel: SemanticDataModel;
classification: string;
contractAgreementId?: string;

mainAspectType: MainAspectType;

Expand Down Expand Up @@ -101,7 +100,6 @@ export interface PartResponse {
receivedQualityInvestigationIdsInStatusActive: string[]
importNote?: string,
importState?: ImportState,
contractAgreementId?: string,
tombstone?: string,
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ export class PartsAssembler {
semanticDataModel: partResponse.semanticDataModel,
classification: partResponse.classification,
semanticModel: createdSemanticModel,
contractAgreementId: partResponse.contractAgreementId,

mainAspectType: mainAspectType,

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ export class PartsAsBuiltConfigurationModel extends TableFilterConfiguration {
sentActiveInvestigations: true,
importState: true,
importNote: true,
contractAgreementId: true,
menu: false,
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ export class PartsAsPlannedConfigurationModel extends TableFilterConfiguration {
functionValidUntil: true,
importState: true,
importNote: true,
contractAgreementId: true,
menu: false,
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,6 @@ describe('PartsTableComponent', () => {
'filtersentActiveInvestigations',
'filterimportState',
'filterimportNote',
'filtercontractAgreementId',
'Menu',
]);
});
Expand Down Expand Up @@ -173,7 +172,6 @@ describe('PartsTableComponent', () => {
'filterfunctionValidUntil',
'filterimportState',
'filterimportNote',
'filtercontractAgreementId',
'Menu',
]);
});
Expand Down

0 comments on commit 35b14aa

Please sign in to comment.