@@ -15,7 +17,8 @@
-
+ +
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 4cf8e8ec1..feb894a42 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 @@ -1,5 +1,5 @@ import { Component, OnInit, ViewChild } from '@angular/core'; -import { UntypedFormBuilder, UntypedFormControl, UntypedFormGroup } from '@angular/forms'; +import { FormBuilder, UntypedFormArray, UntypedFormBuilder, UntypedFormControl, UntypedFormGroup } from '@angular/forms'; import { MatDialog } from '@angular/material/dialog'; import { MatPaginator } from '@angular/material/paginator'; import { MatSort } from '@angular/material/sort'; @@ -33,6 +33,11 @@ import { QueryResult } from '@common/model/query-result'; 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'; @Component({ selector: 'app-dmp-listing-component', @@ -92,7 +97,7 @@ export class DmpListingComponent extends BaseListingComponent { + if (result) { + this.updateDataFn(result); } }); } updateDataFn(filterForm: UntypedFormGroup): void { - let testLookup = this.lookup; - testLookup.from(filterForm); + // this.referenceFilters = this._patchReferenceFiltersFromForm(filterForm); + this.lookup = this._patchLookupFromForm(this.lookup, filterForm); + this.filterChanged(this.lookup) } hasScrollbar(): boolean { @@ -359,6 +370,77 @@ export class DmpListingComponent extends BaseListingComponent 0) { + lookup.dmpDescriptionTemplateSubQuery = this.initializeDmpDescriptionTemplateLookup(); + lookup.dmpDescriptionTemplateSubQuery.descriptionTemplateGroupIds = descriptionTemplates; + } else lookup.dmpDescriptionTemplateSubQuery = null; + + // Blueprints + + // let dmpBlueprints: lookup.dmpBlueprintSubQuery?.ids ? [lookup.dmpBlueprintSubQuery?.ids]: [], + let dmpBlueprints = formGroup.get("dmpBlueprints")?.value ?? null; + if (dmpBlueprints && dmpBlueprints?.length > 0) { + lookup.dmpBlueprintSubQuery = this.initializeDmpBlueprintLookup(); + lookup.dmpBlueprintSubQuery.ids = dmpBlueprints; + } else lookup.dmpBlueprintSubQuery = null; + + // Dmps + let roles = formGroup.get("role")?.value !== null ? [formGroup.get("role")?.value] : null; + if (roles && roles?.length > 0) { + lookup.dmpUserSubQuery = this.initializeDmpUserLookup(); + lookup.dmpUserSubQuery.userRoles = roles; + } else lookup.dmpUserSubQuery = null; + + // // Tags + // let tags = formGroup.get("tags")?.value ?? null; + // if (tags && tags?.length > 0) { + // lookup.descriptionTagSubQuery = this.initializeTagLookup(); + // lookup.descriptionTagSubQuery.tagIds = tags; + // } else lookup.descriptionTagSubQuery = null; + + // // 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; + + return lookup; + } + + 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); + // }); + + 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 + }); + } private get _lookupFields(): string[] { return [ @@ -409,10 +491,51 @@ export class DmpListingComponent extends BaseListingComponent(x => x.dmpReferences), nameof(x => x.reference), nameof(x => x.type), nameof(x => x.id)].join('.'), [nameof(x => x.dmpReferences), nameof(x => x.isActive)].join('.'), + [nameof(x => x.dmpDescriptionTemplates), nameof(x => x.descriptionTemplateGroupId)].join('.'), [nameof(x => x.dmpDescriptionTemplates), nameof(x => x.sectionId)].join('.'), [nameof(x => x.dmpDescriptionTemplates), nameof(x => x.descriptionTemplateGroupId)].join('.'), [nameof(x => x.dmpDescriptionTemplates), nameof(x => x.isActive)].join('.'), ]; } + + protected initializeDmpDescriptionTemplateLookup(): DmpDescriptionTemplateLookup { + const lookup = new DmpDescriptionTemplateLookup(); + lookup.metadata = { countAll: true }; + lookup.isActive = [IsActive.Active]; + lookup.project = { + fields: [ + [nameof(x => x.dmpDescriptionTemplates), nameof(x => x.descriptionTemplateGroupId)].join('.'), + [nameof(x => x.dmpDescriptionTemplates), nameof(x => x.dmp), nameof(x => x.id)].join('.'), + ] + }; + + return lookup; + } + + protected initializeDmpBlueprintLookup(): DmpBlueprintLookup { + const lookup = new DmpBlueprintLookup(); + lookup.metadata = { countAll: true }; + lookup.isActive = [IsActive.Active]; + lookup.project = { + fields: [ + [nameof(x => x.blueprint), nameof(x => x.id)].join('.'), + ] + }; + + return lookup; + } + + protected initializeDmpUserLookup(): DmpUserLookup { + const lookup = new DmpUserLookup(); + lookup.metadata = { countAll: true }; + lookup.isActive = [IsActive.Active]; + lookup.project = { + fields: [ + [nameof(x => x.dmpUsers), nameof(x => x.role)].join('.'), + ] + }; + + return lookup; + } } diff --git a/dmp-frontend/src/app/ui/dmp/listing/filtering/dmp-filter-dialog/dmp-filter-dialog.component.html b/dmp-frontend/src/app/ui/dmp/listing/filtering/dmp-filter-dialog/dmp-filter-dialog.component.html index ec6b8c6d2..15ecec516 100644 --- a/dmp-frontend/src/app/ui/dmp/listing/filtering/dmp-filter-dialog/dmp-filter-dialog.component.html +++ b/dmp-frontend/src/app/ui/dmp/listing/filtering/dmp-filter-dialog/dmp-filter-dialog.component.html @@ -1,7 +1,6 @@ clear diff --git a/dmp-frontend/src/app/ui/dmp/listing/filtering/dmp-filter-dialog/dmp-filter-dialog.component.ts b/dmp-frontend/src/app/ui/dmp/listing/filtering/dmp-filter-dialog/dmp-filter-dialog.component.ts index 647e62f4c..2b58d9bcc 100644 --- a/dmp-frontend/src/app/ui/dmp/listing/filtering/dmp-filter-dialog/dmp-filter-dialog.component.ts +++ b/dmp-frontend/src/app/ui/dmp/listing/filtering/dmp-filter-dialog/dmp-filter-dialog.component.ts @@ -12,21 +12,18 @@ import { DmpFilterComponent } from '../dmp-filter.component'; export class DmpFilterDialogComponent implements OnInit { - @ViewChild(DmpFilterComponent, { static: true }) criteria: DmpFilterComponent; + @ViewChild(DmpFilterComponent, { static: true }) filter: DmpFilterComponent; constructor( public dialogRef: MatDialogRef, private analyticsService: AnalyticsService, - @Inject(MAT_DIALOG_DATA) public data: { - showGrant: boolean, isPublic: boolean, filterForm: UntypedFormGroup, - updateDataFn: Function, }) { } ngOnInit() { - this.analyticsService.trackPageView(AnalyticsService.DmpCriteriaDialog); + this.analyticsService.trackPageView(AnalyticsService.DmpFilterDialog); } onNoClick(): void { @@ -38,7 +35,7 @@ export class DmpFilterDialogComponent implements OnInit { } onFilterChanged(formGroup: UntypedFormGroup) { - this.data.updateDataFn(formGroup); + this.dialogRef.close(formGroup); } } 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 d29feaab1..095bd6eb2 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 @@ -7,24 +7,13 @@
- - - -
{{ 'DMP-LISTING.FILTERS.STATUS.NAME' | translate }}
- {{ 'DMP-LISTING.FILTERS.STATUS.TYPE.ANY' | translate }} - {{ 'DMP-LISTING.FILTERS.STATUS.TYPE.PUBLIC' | translate }} - {{ 'DMP-LISTING.FILTERS.STATUS.TYPE.FINALIZED' | translate }} - {{ 'DMP-LISTING.FILTERS.STATUS.TYPE.DRAFT' | translate }} + {{ 'DMP-LISTING.FILTERS.STATUS.TYPE.ANY' | translate }} + {{ 'DMP-LISTING.FILTERS.STATUS.TYPE.DRAFT' | translate }} + {{ 'DMP-LISTING.FILTERS.STATUS.TYPE.FINALIZED' | translate }}
@@ -44,13 +33,11 @@ - -
{{ 'DMP-LISTING.FILTERS.RELATED-DESCRIPTION-TEMPLATES.NAME' | translate}}
{{ 'DMP-LISTING.FILTERS.RELATED-DESCRIPTION-TEMPLATES.PLACEHOLDER' | translate }} - +
@@ -61,48 +48,21 @@
{{ 'DMP-LISTING.FILTERS.ASSOCIATED-DMP-BLUEPRINTS.NAME' | translate}}
{{ 'DMP-LISTING.FILTERS.ASSOCIATED-DMP-BLUEPRINTS.PLACEHOLDER' | translate }} - +
- - - - - - - - - - -
{{ 'DMP-LISTING.FILTERS.ROLE.NAME' | translate }}
- {{ 'DMP-LISTING.FILTERS.ROLE.TYPE.ANY' | translate }} - {{ 'DMP-LISTING.FILTERS.ROLE.TYPE.OWNER' | translate }} - {{ 'DMP-LISTING.FILTERS.ROLE.TYPE.MEMBER' | translate }} + {{ 'DMP-LISTING.FILTERS.ROLE.TYPE.ANY' | translate }} + {{ 'DMP-LISTING.FILTERS.ROLE.TYPE.OWNER' | translate }} + {{ 'DMP-LISTING.FILTERS.ROLE.TYPE.MEMBER' | translate }} + {{ 'DMP-LISTING.FILTERS.ROLE.TYPE.DescriptionContributor' | translate }} + {{ 'DMP-LISTING.FILTERS.ROLE.TYPE.Reviewer' | translate }}
@@ -121,6 +81,12 @@
--> +
+ +
+