diff --git a/dmp-frontend/src/app/ui/dmp/listing/dmp-listing.component.ts b/dmp-frontend/src/app/ui/dmp/listing/dmp-listing.component.ts index feb894a42..73d7e3ae0 100644 --- a/dmp-frontend/src/app/ui/dmp/listing/dmp-listing.component.ts +++ b/dmp-frontend/src/app/ui/dmp/listing/dmp-listing.component.ts @@ -34,10 +34,11 @@ import { Observable } from 'rxjs'; import { UiNotificationService } from '@app/core/services/notification/ui-notification-service'; import { QueryParamsService } from '@app/core/services/utilities/query-params.service'; import { ReferencesWithType } from '@app/core/query/description.lookup'; -import { DescriptionTemplateLookup } from '@app/core/query/description-template.lookup'; import { DmpDescriptionTemplateLookup } from '@app/core/query/dmp-description-template.lookup'; import { DmpBlueprintLookup } from '@app/core/query/dmp-blueprint.lookup'; import { DmpUserLookup } from '@app/core/query/dmp-user.lookup'; +import { Guid } from '@common/types/guid'; +import { DmpReferenceLookup } from '@app/core/query/reference.lookup'; @Component({ selector: 'app-dmp-listing-component', @@ -58,6 +59,7 @@ export class DmpListingComponent extends BaseListingComponent { - // if (!result) { return []; } - // this.totalCount = result.count; - // if (lookup?.page?.offset === 0) this.listingItems = []; - // this.listingItems.push(...result.items); - // this.hasListingItems = true; - // }, - // error => this.httpErrorHandlingService.handleBackedRequestError(error)); - - // } else { - // this.dmpService.query(lookup).pipe(takeUntil(this._destroyed)) - // .subscribe(result => { - // if (!result) { return []; } - // this.totalCount = result.count; - // if (lookup?.page?.offset === 0) this.listingItems = []; - // result.items.forEach(x => { - // if (x.descriptions) { - // if (x.status == DmpStatus.Finalized) { - // x.descriptions = x.descriptions.filter(x => x.isActive === IsActive.Active && x.status === DescriptionStatus.Finalized); - // } else { - // x.descriptions = x.descriptions.filter(x => x.isActive === IsActive.Active && x.status !== DescriptionStatus.Canceled); - // } - // } - // x.dmpUsers = x.dmpUsers.filter(x => x.isActive === IsActive.Active); - // this.listingItems.push(x); - // }) - // this.hasListingItems = true; - // }, - // error => this.httpErrorHandlingService.handleBackedRequestError(error)); - // } - // } - controlModified(): void { this.lookup.like = this.formGroup.get("like").value; this.lookup.page = { size: this.pageSize, offset: 0 }; this.filterChanged(this.lookup, true); } - openShareDialog(rowId: any, rowName: any) { //TODO: add this } @@ -297,8 +258,7 @@ export class DmpListingComponent extends BaseListingComponent 0) { lookup.dmpBlueprintSubQuery = this.initializeDmpBlueprintLookup(); @@ -398,46 +357,39 @@ export class DmpListingComponent extends BaseListingComponent 0) { - // lookup.descriptionTagSubQuery = this.initializeTagLookup(); - // lookup.descriptionTagSubQuery.tagIds = tags; - // } else lookup.descriptionTagSubQuery = null; + let references: Guid[] = formGroup.get("references")?.value + ?.filter((reference: ReferencesWithType) => reference.referenceType != null && reference.references?.length > 0) + ?.flatMap((referencesWithType: ReferencesWithType) => referencesWithType.references) as Guid[]; - // // References - // let references: Guid[] = formGroup.get("references")?.value - // ?.filter((reference: ReferencesWithType) => reference.referenceType != null && reference.references?.length > 0) - // ?.flatMap((referencesWithType: ReferencesWithType) => referencesWithType.references) as Guid[]; - - // if (references && references?.length > 0) { - // lookup.descriptionReferenceSubQuery = this.initializeReferenceLookup(); - // lookup.descriptionReferenceSubQuery.referenceIds = references; - // } else lookup.descriptionReferenceSubQuery = null; + if (references && references?.length > 0) { + lookup.dmpReferenceSubQuery = this.initializeDmpReferenceLookup(); + lookup.dmpReferenceSubQuery.referenceIds = references; + } else lookup.dmpReferenceSubQuery = null; + return lookup; } + _patchReferenceFiltersFromForm(formGroup: UntypedFormGroup): ReferencesWithType[] { + return formGroup?.get("references")?.value?.filter(reference => reference.referenceType != null && reference.references?.length > 0) ?? null; + } + private _buildFormFromLookup(lookup: DmpLookup, referenceFilters: ReferencesWithType[]): UntypedFormGroup { const formArray = this.formBuilder.array([]) as UntypedFormArray; - // referenceFilters?.forEach(reference => { - // let referenceForm = this.formBuilder.group({ - // referenceType: reference.referenceType, - // references: reference.references?.length > 0 ? [reference.references] : [] - // }); - // formArray.push(referenceForm); - // }); + referenceFilters?.forEach(reference => { + let referenceForm = this.formBuilder.group({ + referenceType: reference.referenceType, + references: reference.references?.length > 0 ? [reference.references] : [] + }); + formArray.push(referenceForm); + }); return (new UntypedFormBuilder()).group({ status: [lookup.statuses?.length > 0 ? lookup.statuses[0] : null], descriptionTemplates: lookup.dmpDescriptionTemplateSubQuery?.descriptionTemplateGroupIds ? [lookup.dmpDescriptionTemplateSubQuery?.descriptionTemplateGroupIds] : [], dmpBlueprints: lookup.dmpBlueprintSubQuery?.ids ? [lookup.dmpBlueprintSubQuery?.ids]: [], role: lookup.dmpUserSubQuery?.userRoles ? lookup.dmpUserSubQuery?.userRoles[0] : null, - // showAllVersions: [lookup.showAllVersions ?? false], - // descriptionTemplates: lookup.descriptionTemplateSubQuery?.ids ? [lookup.descriptionTemplateSubQuery?.ids] : [], - // associatedDmpIds: lookup.dmpSubQuery?.ids ? [lookup.dmpSubQuery?.ids] : [], - // tags: lookup.descriptionTagSubQuery?.tagIds ? [lookup.descriptionTagSubQuery?.tagIds] : [], references: formArray }); } @@ -538,4 +490,17 @@ export class DmpListingComponent extends BaseListingComponent(x => x.dmpReferences), nameof(x => x.id)].join('.'), + ] + }; + + return lookup; + } } diff --git a/dmp-frontend/src/app/ui/dmp/listing/filtering/dmp-filter.component.html b/dmp-frontend/src/app/ui/dmp/listing/filtering/dmp-filter.component.html index 095bd6eb2..036f2c459 100644 --- a/dmp-frontend/src/app/ui/dmp/listing/filtering/dmp-filter.component.html +++ b/dmp-frontend/src/app/ui/dmp/listing/filtering/dmp-filter.component.html @@ -5,7 +5,6 @@
{{'DMP-LISTING.FILTERS.NAME'| translate}}
-
@@ -19,19 +18,6 @@
- - - - -
{{ 'DMP-LISTING.FILTERS.RELATED-DESCRIPTION-TEMPLATES.NAME' | translate}}
@@ -68,19 +54,47 @@
- - - - + +
+
{{'DESCRIPTION-LISTING.FILTERS.REFERENCE-TYPES.NAME' | translate }}
+ +
+
+ + {{'DESCRIPTION-LISTING.FILTERS.REFERENCE-TYPES.REFERENCE-TYPE' | translate}} + + + +
+
+
+
+ + {{'DESCRIPTION-LISTING.FILTERS.REFERENCE-TYPES.REFERENCE' | translate}} + + + +
+
+ + +
+
+
+ + + {{'DESCRIPTION-LISTING.ACTIONS.ADD-REFERENCE-TYPE' | translate}} + +
+
+
+ +