added filters dmp listing (pending: reference filters)

This commit is contained in:
Sofia Papacharalampous 2024-06-26 16:44:47 +03:00
parent 6f34132dbc
commit b7cc78ef4f
11 changed files with 218 additions and 110 deletions

View File

@ -53,6 +53,8 @@ public class DmpQuery extends QueryBase<DmpEntity> {
private DmpDescriptionTemplateQuery dmpDescriptionTemplateQuery; private DmpDescriptionTemplateQuery dmpDescriptionTemplateQuery;
private DmpBlueprintQuery dmpBlueprintQuery;
private DmpReferenceQuery dmpReferenceQuery; private DmpReferenceQuery dmpReferenceQuery;
private EntityDoiQuery entityDoiQuery; private EntityDoiQuery entityDoiQuery;
@ -223,6 +225,11 @@ public class DmpQuery extends QueryBase<DmpEntity> {
return this; return this;
} }
public DmpQuery dmpBlueprintSubQuery(DmpBlueprintQuery subQuery) {
this.dmpBlueprintQuery = subQuery;
return this;
}
public DmpQuery dmpUserSubQuery(DmpUserQuery subQuery) { public DmpQuery dmpUserSubQuery(DmpUserQuery subQuery) {
this.dmpUserQuery = subQuery; this.dmpUserQuery = subQuery;
return this; return this;
@ -374,6 +381,11 @@ public class DmpQuery extends QueryBase<DmpEntity> {
predicates.add(queryContext.CriteriaBuilder.in(queryContext.Root.get(DmpEntity._id)).value(subQuery.Query)); predicates.add(queryContext.CriteriaBuilder.in(queryContext.Root.get(DmpEntity._id)).value(subQuery.Query));
} }
if (this.dmpBlueprintQuery != null) {
QueryContext<DmpBlueprintEntity, UUID> subQuery = this.applySubQuery(this.dmpBlueprintQuery, queryContext, UUID.class, dmpBlueprintEntityRoot -> dmpBlueprintEntityRoot.get(DmpBlueprintEntity._id));
predicates.add(queryContext.CriteriaBuilder.in(queryContext.Root.get(DmpEntity._blueprintId)).value(subQuery.Query));
}
if (this.dmpReferenceQuery != null) { if (this.dmpReferenceQuery != null) {
QueryContext<DmpReferenceEntity, UUID> subQuery = this.applySubQuery(this.dmpReferenceQuery, queryContext, UUID.class, dmpReferenceEntityRoot -> dmpReferenceEntityRoot.get(DmpReferenceEntity._dmpId)); QueryContext<DmpReferenceEntity, UUID> subQuery = this.applySubQuery(this.dmpReferenceQuery, queryContext, UUID.class, dmpReferenceEntityRoot -> dmpReferenceEntityRoot.get(DmpReferenceEntity._dmpId));
predicates.add(queryContext.CriteriaBuilder.in(queryContext.Root.get(DmpEntity._id)).value(subQuery.Query)); predicates.add(queryContext.CriteriaBuilder.in(queryContext.Root.get(DmpEntity._id)).value(subQuery.Query));

View File

@ -33,6 +33,7 @@ public class DmpLookup extends Lookup {
private DmpDescriptionTemplateLookup dmpDescriptionTemplateSubQuery; private DmpDescriptionTemplateLookup dmpDescriptionTemplateSubQuery;
private DmpUserLookup dmpUserSubQuery; private DmpUserLookup dmpUserSubQuery;
private DmpBlueprintLookup dmpBlueprintSubQuery;
public String getLike() { public String getLike() {
return this.like; return this.like;
@ -122,6 +123,10 @@ public class DmpLookup extends Lookup {
this.dmpUserSubQuery = dmpUserSubQuery; this.dmpUserSubQuery = dmpUserSubQuery;
} }
public DmpBlueprintLookup getDmpBlueprintSubQuery() { return this.dmpBlueprintSubQuery; }
public void setDmpBlueprintLookup(DmpBlueprintLookup dmpBlueprintSubQuery) { this.dmpBlueprintSubQuery = dmpBlueprintSubQuery; }
public DmpQuery enrich(QueryFactory queryFactory) { public DmpQuery enrich(QueryFactory queryFactory) {
DmpQuery query = queryFactory.query(DmpQuery.class); DmpQuery query = queryFactory.query(DmpQuery.class);
if (this.like != null) query.like(this.like); if (this.like != null) query.like(this.like);
@ -135,6 +140,7 @@ public class DmpLookup extends Lookup {
if (this.versionStatuses != null) query.versionStatuses(this.versionStatuses); if (this.versionStatuses != null) query.versionStatuses(this.versionStatuses);
if (this.dmpDescriptionTemplateSubQuery != null) query.dmpDescriptionTemplateSubQuery(this.dmpDescriptionTemplateSubQuery.enrich(queryFactory)); if (this.dmpDescriptionTemplateSubQuery != null) query.dmpDescriptionTemplateSubQuery(this.dmpDescriptionTemplateSubQuery.enrich(queryFactory));
if (this.dmpUserSubQuery != null) query.dmpUserSubQuery(this.dmpUserSubQuery.enrich(queryFactory)); if (this.dmpUserSubQuery != null) query.dmpUserSubQuery(this.dmpUserSubQuery.enrich(queryFactory));
if (this.dmpBlueprintSubQuery != null) query.dmpBlueprintSubQuery(this.dmpBlueprintSubQuery.enrich(queryFactory));
this.enrichCommon(query); this.enrichCommon(query);
@ -153,7 +159,7 @@ public class DmpLookup extends Lookup {
if (this.versionStatuses != null) query.versionStatuses(this.versionStatuses); if (this.versionStatuses != null) query.versionStatuses(this.versionStatuses);
if (this.dmpDescriptionTemplateSubQuery != null) query.dmpDescriptionTemplateSubQuery(this.dmpDescriptionTemplateSubQuery.enrichElasticInner(queryFactory)); if (this.dmpDescriptionTemplateSubQuery != null) query.dmpDescriptionTemplateSubQuery(this.dmpDescriptionTemplateSubQuery.enrichElasticInner(queryFactory));
if (this.dmpUserSubQuery != null) query.dmpSubQuery(this.dmpUserSubQuery.enrichElasticInner(queryFactory)); if (this.dmpUserSubQuery != null) query.dmpSubQuery(this.dmpUserSubQuery.enrichElasticInner(queryFactory));
// TODO ??
this.enrichCommon(query); this.enrichCommon(query);
return query; return query;
@ -171,7 +177,7 @@ public class DmpLookup extends Lookup {
if (this.versionStatuses != null) query.versionStatuses(this.versionStatuses); if (this.versionStatuses != null) query.versionStatuses(this.versionStatuses);
if (this.dmpDescriptionTemplateSubQuery != null) throw new UnsupportedOperationException(""); if (this.dmpDescriptionTemplateSubQuery != null) throw new UnsupportedOperationException("");
if (this.dmpUserSubQuery != null) query.dmpSubQuery(this.dmpUserSubQuery.enrichElasticInner(queryFactory)); if (this.dmpUserSubQuery != null) query.dmpSubQuery(this.dmpUserSubQuery.enrichElasticInner(queryFactory));
// TODO ??
return query; return query;
} }

View File

@ -7,6 +7,7 @@ import { IsActive } from '../common/enum/is-active.enum';
import { DmpDescriptionTemplateLookup } from './dmp-description-template.lookup'; import { DmpDescriptionTemplateLookup } from './dmp-description-template.lookup';
import { UntypedFormBuilder, UntypedFormGroup } from '@angular/forms'; import { UntypedFormBuilder, UntypedFormGroup } from '@angular/forms';
import { DmpUserLookup } from './dmp-user.lookup'; import { DmpUserLookup } from './dmp-user.lookup';
import { DmpBlueprintLookup } from './dmp-blueprint.lookup';
export class DmpLookup extends Lookup implements DmpFilter { export class DmpLookup extends Lookup implements DmpFilter {
ids: Guid[]; ids: Guid[];
@ -17,13 +18,11 @@ export class DmpLookup extends Lookup implements DmpFilter {
statuses: DmpStatus[]; statuses: DmpStatus[];
accessTypes: DmpAccessType[]; accessTypes: DmpAccessType[];
versions: Number[]; versions: Number[];
dmpDescriptionTemplateSubQuery: DmpDescriptionTemplateLookup;
groupIds: Guid[]; groupIds: Guid[];
dmpUserSubQuery: DmpUserLookup; dmpUserSubQuery: DmpUserLookup;
dmpBlueprintSubQuery: DmpBlueprintLookup;
dmpBlueprintIds: Guid[]; //TODO dmpDescriptionTemplateSubQuery: DmpDescriptionTemplateLookup;
descriptionTemplateIds: Guid[]; //TODO
constructor() { constructor() {
super(); super();
@ -32,16 +31,16 @@ export class DmpLookup extends Lookup implements DmpFilter {
from(formGroup: UntypedFormGroup): void { from(formGroup: UntypedFormGroup): void {
this.statuses = formGroup.get('status')?.value ? [formGroup.get('status')?.value] : null; this.statuses = formGroup.get('status')?.value ? [formGroup.get('status')?.value] : null;
// this.roleInDmp = formGroup.get('role')?.value ? [formGroup.get('role')?.value] : null; // this.roleInDmp = formGroup.get('role')?.value ? [formGroup.get('role')?.value] : null;
this.dmpBlueprintIds = formGroup.get('dmpBlueprintIds')?.value ? formGroup.get('dmpBlueprintIds')?.value : null; // this.dmpBlueprintIds = formGroup.get('dmpBlueprintIds')?.value ? formGroup.get('dmpBlueprintIds')?.value : null;
this.descriptionTemplateIds = formGroup.get('descriptionTemplateIds')?.value ? formGroup.get('descriptionTemplateIds')?.value : null; // this.descriptionTemplateIds = formGroup.get('descriptionTemplateIds')?.value ? formGroup.get('descriptionTemplateIds')?.value : null;
} }
buildForm(): UntypedFormGroup { buildForm(): UntypedFormGroup {
return (new UntypedFormBuilder()).group({ return (new UntypedFormBuilder()).group({
status: [this.statuses ? this.statuses[0] : null], status: [this.statuses ? this.statuses[0] : null],
// role: [this.roleInDmp ? this.roleInDmp[0] : null], // role: [this.roleInDmp ? this.roleInDmp[0] : null],
dmpBlueprintIds: [this.dmpBlueprintIds], // dmpBlueprintIds: [this.dmpBlueprintIds],
descriptionTemplateIds: [this.descriptionTemplateIds], // descriptionTemplateIds: [this.descriptionTemplateIds],
}); });
} }
} }
@ -58,7 +57,6 @@ export interface DmpFilter {
groupIds: Guid[]; groupIds: Guid[];
dmpUserSubQuery: DmpUserLookup; dmpUserSubQuery: DmpUserLookup;
dmpBlueprintSubQuery: DmpBlueprintLookup;
dmpBlueprintIds: Guid[]; //TODO dmpDescriptionTemplateSubQuery: DmpDescriptionTemplateLookup;
descriptionTemplateIds: Guid[]; //TODO
} }

View File

@ -31,7 +31,7 @@ export class AnalyticsService {
public static DescriptionOverview: string = 'Description Overview'; public static DescriptionOverview: string = 'Description Overview';
public static DmpEditor: string = 'DMP Editor'; public static DmpEditor: string = 'DMP Editor';
public static DmpListing: string = 'DMPs'; public static DmpListing: string = 'DMPs';
public static DmpCriteriaDialog: string = 'DMP Criteria'; public static DmpFilterDialog: string = 'DMP Criteria';
public static DmpListingItem: string = 'DMP Listing Item'; public static DmpListingItem: string = 'DMP Listing Item';
public static StartNewDmpDialog: string = 'Start New DMP Dialog'; public static StartNewDmpDialog: string = 'Start New DMP Dialog';
public static DmpUploadDialog: string = 'DMP Upload Dialog'; public static DmpUploadDialog: string = 'DMP Upload Dialog';

View File

@ -19,7 +19,6 @@ export class DescriptionFilterDialogComponent implements OnInit {
private analyticsService: AnalyticsService, private analyticsService: AnalyticsService,
@Inject(MAT_DIALOG_DATA) public data: { @Inject(MAT_DIALOG_DATA) public data: {
isPublic: boolean, isPublic: boolean,
status: Number,
filterForm: UntypedFormGroup, filterForm: UntypedFormGroup,
} }
) { ) {

View File

@ -1,3 +1,5 @@
{{ lookup | json }}
<div class="main-content listing-main-container h-100"> <div class="main-content listing-main-container h-100">
<div class="container-fluid"> <div class="container-fluid">
<div class="row"> <div class="row">
@ -15,7 +17,8 @@
<app-navigation-breadcrumb /> <app-navigation-breadcrumb />
</div> </div>
<!-- TODO: implement filters --> <!-- TODO: implement filters -->
<div *ngIf="listingItems && listingItems.length > 0 || this.lookup.like" class="filter-btn" [style.right]="dialog.getDialogById('filters') ? '446px' : '0px'" [style.width]="listingItems.length > 2 ? '57px' : '37px'" (click)="openFiltersDialog()"> <!-- <div *ngIf="listingItems && listingItems.length > 0 || this.lookup.like" class="filter-btn" [style.right]="dialog.getDialogById('filters') ? '446px' : '0px'" [style.width]="listingItems.length > 2 ? '57px' : '37px'" (click)="openFiltersDialog()"> -->
<div class="filter-btn" [style.right]="dialog.getDialogById('filters') ? '446px' : '0px'" [style.width]="listingItems.length > 2 ? '57px' : '37px'" (click)="openFiltersDialog()">
<button mat-raised-button class="p-0"> <button mat-raised-button class="p-0">
<mat-icon class="mr-4 filter-icon">filter_alt</mat-icon> <mat-icon class="mr-4 filter-icon">filter_alt</mat-icon>
</button> </button>

View File

@ -1,5 +1,5 @@
import { Component, OnInit, ViewChild } from '@angular/core'; 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 { MatDialog } from '@angular/material/dialog';
import { MatPaginator } from '@angular/material/paginator'; import { MatPaginator } from '@angular/material/paginator';
import { MatSort } from '@angular/material/sort'; import { MatSort } from '@angular/material/sort';
@ -33,6 +33,11 @@ import { QueryResult } from '@common/model/query-result';
import { Observable } from 'rxjs'; import { Observable } from 'rxjs';
import { UiNotificationService } from '@app/core/services/notification/ui-notification-service'; import { UiNotificationService } from '@app/core/services/notification/ui-notification-service';
import { QueryParamsService } from '@app/core/services/utilities/query-params.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({ @Component({
selector: 'app-dmp-listing-component', selector: 'app-dmp-listing-component',
@ -92,7 +97,7 @@ export class DmpListingComponent extends BaseListingComponent<BaseDmp, DmpLookup
private authService: AuthService, private authService: AuthService,
private guidedTourService: GuidedTourService, private guidedTourService: GuidedTourService,
private analyticsService: AnalyticsService, private analyticsService: AnalyticsService,
private formBuilder: FormBuilder,
) { ) {
super(router, route, uiNotificationService, httpErrorHandlingService, queryParamsService); super(router, route, uiNotificationService, httpErrorHandlingService, queryParamsService);
} }
@ -283,7 +288,6 @@ export class DmpListingComponent extends BaseListingComponent<BaseDmp, DmpLookup
} }
openFiltersDialog(): void { openFiltersDialog(): void {
//TODO: Add filters dialog
let dialogRef = this.dialog.open(DmpFilterDialogComponent, { let dialogRef = this.dialog.open(DmpFilterDialogComponent, {
width: '456px', width: '456px',
height: '100%', height: '100%',
@ -293,15 +297,22 @@ export class DmpListingComponent extends BaseListingComponent<BaseDmp, DmpLookup
panelClass: 'dialog-side-panel', panelClass: 'dialog-side-panel',
data: { data: {
isPublic: this.isPublic ?? true, isPublic: this.isPublic ?? true,
filterForm: this.lookup.buildForm(), filterForm: this._buildFormFromLookup(this.lookup, null),
updateDataFn: this.updateDataFn.bind(this) // filterForm: this._buildFormFromLookup(this.lookup, this.referenceFilters),
}
});
dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => {
if (result) {
this.updateDataFn(result);
} }
}); });
} }
updateDataFn(filterForm: UntypedFormGroup): void { updateDataFn(filterForm: UntypedFormGroup): void {
let testLookup = this.lookup; // this.referenceFilters = this._patchReferenceFiltersFromForm(filterForm);
testLookup.from(filterForm); this.lookup = this._patchLookupFromForm(this.lookup, filterForm);
this.filterChanged(this.lookup)
} }
hasScrollbar(): boolean { hasScrollbar(): boolean {
@ -359,6 +370,77 @@ export class DmpListingComponent extends BaseListingComponent<BaseDmp, DmpLookup
} }
} }
private _patchLookupFromForm(lookup: DmpLookup, formGroup: UntypedFormGroup): DmpLookup {
if (!formGroup) return;
lookup.statuses = formGroup.get("status")?.value !== null ? [formGroup.get("status")?.value] : null;
// Description Templates
let descriptionTemplates = formGroup.get("descriptionTemplates")?.value ?? null;
if (descriptionTemplates && descriptionTemplates?.length > 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[] { private get _lookupFields(): string[] {
return [ return [
@ -409,10 +491,51 @@ export class DmpListingComponent extends BaseListingComponent<BaseDmp, DmpLookup
[nameof<Dmp>(x => x.dmpReferences), nameof<DmpReference>(x => x.reference), nameof<Reference>(x => x.type), nameof<ReferenceType>(x => x.id)].join('.'), [nameof<Dmp>(x => x.dmpReferences), nameof<DmpReference>(x => x.reference), nameof<Reference>(x => x.type), nameof<ReferenceType>(x => x.id)].join('.'),
[nameof<Dmp>(x => x.dmpReferences), nameof<DmpReference>(x => x.isActive)].join('.'), [nameof<Dmp>(x => x.dmpReferences), nameof<DmpReference>(x => x.isActive)].join('.'),
[nameof<Dmp>(x => x.dmpDescriptionTemplates), nameof<DmpDescriptionTemplate>(x => x.descriptionTemplateGroupId)].join('.'),
[nameof<Dmp>(x => x.dmpDescriptionTemplates), nameof<DmpDescriptionTemplate>(x => x.sectionId)].join('.'), [nameof<Dmp>(x => x.dmpDescriptionTemplates), nameof<DmpDescriptionTemplate>(x => x.sectionId)].join('.'),
[nameof<Dmp>(x => x.dmpDescriptionTemplates), nameof<DmpDescriptionTemplate>(x => x.descriptionTemplateGroupId)].join('.'), [nameof<Dmp>(x => x.dmpDescriptionTemplates), nameof<DmpDescriptionTemplate>(x => x.descriptionTemplateGroupId)].join('.'),
[nameof<Dmp>(x => x.dmpDescriptionTemplates), nameof<DmpDescriptionTemplate>(x => x.isActive)].join('.'), [nameof<Dmp>(x => x.dmpDescriptionTemplates), nameof<DmpDescriptionTemplate>(x => x.isActive)].join('.'),
]; ];
} }
protected initializeDmpDescriptionTemplateLookup(): DmpDescriptionTemplateLookup {
const lookup = new DmpDescriptionTemplateLookup();
lookup.metadata = { countAll: true };
lookup.isActive = [IsActive.Active];
lookup.project = {
fields: [
[nameof<Dmp>(x => x.dmpDescriptionTemplates), nameof<DmpDescriptionTemplate>(x => x.descriptionTemplateGroupId)].join('.'),
[nameof<Dmp>(x => x.dmpDescriptionTemplates), nameof<DmpDescriptionTemplate>(x => x.dmp), nameof<Dmp>(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<Dmp>(x => x.blueprint), nameof<DmpBlueprint>(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<Dmp>(x => x.dmpUsers), nameof<DmpUser>(x => x.role)].join('.'),
]
};
return lookup;
}
} }

View File

@ -1,7 +1,6 @@
<a class="col-auto d-flex pointer" (click)="onClose()"><span class="ml-auto mt-3 material-icons clear-icon">clear</span></a> <a class="col-auto d-flex pointer" (click)="onClose()"><span class="ml-auto mt-3 material-icons clear-icon">clear</span></a>
<app-dmp-filter-component <app-dmp-filter-component
[showGrant]="data.showGrant"
[isPublic]="data.isPublic"
[filterFormGroup]="data.filterForm" [filterFormGroup]="data.filterForm"
(filtersChanged)="onFilterChanged($event)" [isPublic]="data.isPublic"
(filterChanged)="onFilterChanged($event)"
></app-dmp-filter-component> ></app-dmp-filter-component>

View File

@ -12,21 +12,18 @@ import { DmpFilterComponent } from '../dmp-filter.component';
export class DmpFilterDialogComponent implements OnInit { export class DmpFilterDialogComponent implements OnInit {
@ViewChild(DmpFilterComponent, { static: true }) criteria: DmpFilterComponent; @ViewChild(DmpFilterComponent, { static: true }) filter: DmpFilterComponent;
constructor( constructor(
public dialogRef: MatDialogRef<DmpFilterDialogComponent>, public dialogRef: MatDialogRef<DmpFilterDialogComponent>,
private analyticsService: AnalyticsService, private analyticsService: AnalyticsService,
@Inject(MAT_DIALOG_DATA) public data: { @Inject(MAT_DIALOG_DATA) public data: {
showGrant: boolean,
isPublic: boolean, isPublic: boolean,
filterForm: UntypedFormGroup, filterForm: UntypedFormGroup,
updateDataFn: Function,
}) { } }) { }
ngOnInit() { ngOnInit() {
this.analyticsService.trackPageView(AnalyticsService.DmpCriteriaDialog); this.analyticsService.trackPageView(AnalyticsService.DmpFilterDialog);
} }
onNoClick(): void { onNoClick(): void {
@ -38,7 +35,7 @@ export class DmpFilterDialogComponent implements OnInit {
} }
onFilterChanged(formGroup: UntypedFormGroup) { onFilterChanged(formGroup: UntypedFormGroup) {
this.data.updateDataFn(formGroup); this.dialogRef.close(formGroup);
} }
} }

View File

@ -7,24 +7,13 @@
</div> </div>
<!-- <h6 class="filters-title">{{'CRITERIA.FILTERS'| translate}}</h6> --> <!-- <h6 class="filters-title">{{'CRITERIA.FILTERS'| translate}}</h6> -->
<div class="row" style="justify-content: center;" *ngIf="formGroup"> <div class="row" style="justify-content: center;" *ngIf="formGroup">
<!-- Search Filter-->
<!-- <mat-form-field class="col-11 search">
<input matInput placeholder="{{'CRITERIA.DMP.LIKE'| translate}}" name="likeCriteria"
[formControl]="formGroup.get('like')">
<mat-error *ngIf="formGroup.get('like').hasError('backendError')">
{{formGroup.get('like').getError('backendError').message}}</mat-error>
<mat-icon matSuffix class="style-icon">search</mat-icon>
</mat-form-field> -->
<!-- End of Search Filter -->
<!-- Visibility Filter--> <!-- Visibility Filter-->
<div *ngIf="!isPublic" class="col-10"> <div *ngIf="!isPublic" class="col-10">
<h6 class="category-title">{{ 'DMP-LISTING.FILTERS.STATUS.NAME' | translate }}</h6> <h6 class="category-title">{{ 'DMP-LISTING.FILTERS.STATUS.NAME' | translate }}</h6>
<mat-radio-group aria-label="Select an option" [formControl]="formGroup.get('status')" class="row"> <mat-radio-group aria-label="Select an option" [formControl]="formGroup.get('status')" class="row">
<mat-radio-button value="null" [checked]="!formGroup.get('status').value" class="col-12">{{ 'DMP-LISTING.FILTERS.STATUS.TYPE.ANY' | translate }}</mat-radio-button> <mat-radio-button [value]="null" [checked]="formGroup.get('status')?.value == null" class="col-12">{{ 'DMP-LISTING.FILTERS.STATUS.TYPE.ANY' | translate }}</mat-radio-button>
<mat-radio-button value="2" class="col-12">{{ 'DMP-LISTING.FILTERS.STATUS.TYPE.PUBLIC' | translate }}</mat-radio-button> <mat-radio-button [value]="status.Draft" class="col-12">{{ 'DMP-LISTING.FILTERS.STATUS.TYPE.DRAFT' | translate }}</mat-radio-button>
<mat-radio-button value="1" class="col-12">{{ 'DMP-LISTING.FILTERS.STATUS.TYPE.FINALIZED' | translate }}</mat-radio-button> <mat-radio-button [value]="status.Finalized" class="col-12">{{ 'DMP-LISTING.FILTERS.STATUS.TYPE.FINALIZED' | translate }}</mat-radio-button>
<mat-radio-button value="0" class="col-12">{{ 'DMP-LISTING.FILTERS.STATUS.TYPE.DRAFT' | translate }}</mat-radio-button>
</mat-radio-group> </mat-radio-group>
<hr> <hr>
</div> </div>
@ -44,13 +33,11 @@
<!-- End of Grant Status --> <!-- End of Grant Status -->
<!-- Related Dataset Templates Filter --> <!-- Related Dataset Templates Filter -->
<!-- TODO -->
<!-- <div *ngIf="showGrant" class="col-10"> -->
<div class="col-10"> <div class="col-10">
<h6 class="category-title">{{ 'DMP-LISTING.FILTERS.RELATED-DESCRIPTION-TEMPLATES.NAME' | translate}}</h6> <h6 class="category-title">{{ 'DMP-LISTING.FILTERS.RELATED-DESCRIPTION-TEMPLATES.NAME' | translate}}</h6>
<mat-form-field class="w-100"> <mat-form-field class="w-100">
<mat-label>{{ 'DMP-LISTING.FILTERS.RELATED-DESCRIPTION-TEMPLATES.PLACEHOLDER' | translate }}</mat-label> <mat-label>{{ 'DMP-LISTING.FILTERS.RELATED-DESCRIPTION-TEMPLATES.PLACEHOLDER' | translate }}</mat-label>
<app-multiple-auto-complete [formControl]="formGroup.get('descriptionTemplateIds')" [configuration]="descriptionTemplateAutoCompleteConfiguration"></app-multiple-auto-complete> <app-multiple-auto-complete [formControl]="formGroup.get('descriptionTemplates')" [configuration]="descriptionTemplateAutoCompleteConfiguration"></app-multiple-auto-complete>
</mat-form-field> </mat-form-field>
<hr> <hr>
</div> </div>
@ -61,48 +48,21 @@
<h6 class="category-title">{{ 'DMP-LISTING.FILTERS.ASSOCIATED-DMP-BLUEPRINTS.NAME' | translate}}</h6> <h6 class="category-title">{{ 'DMP-LISTING.FILTERS.ASSOCIATED-DMP-BLUEPRINTS.NAME' | translate}}</h6>
<mat-form-field class="w-100"> <mat-form-field class="w-100">
<mat-label>{{ 'DMP-LISTING.FILTERS.ASSOCIATED-DMP-BLUEPRINTS.PLACEHOLDER' | translate }}</mat-label> <mat-label>{{ 'DMP-LISTING.FILTERS.ASSOCIATED-DMP-BLUEPRINTS.PLACEHOLDER' | translate }}</mat-label>
<app-multiple-auto-complete [formControl]="formGroup.get('dmpBlueprintIds')" [configuration]="dmpBlueprintAutoCompleteConfiguration"></app-multiple-auto-complete> <app-multiple-auto-complete [formControl]="formGroup.get('dmpBlueprints')" [configuration]="dmpBlueprintAutoCompleteConfiguration"></app-multiple-auto-complete>
</mat-form-field> </mat-form-field>
<hr> <hr>
</div> </div>
<!-- End of Dmp Blueprint Filter --> <!-- End of Dmp Blueprint Filter -->
<!-- Related Grant Filters -->
<!-- TODO -->
<!-- <div *ngIf="showGrant" class="col-10">
<h6 class="category-title">{{ 'DMP-RELATED-GRANT.RELATED-GRANT' | translate}}</h6>
<mat-form-field>
<mat-label>{{ 'CRITERIA.DMP.SELECT-GRANTS' | translate }}</mat-label>
<app-multiple-auto-complete [formControl]="formGroup.get('grants')"
[configuration]="grantAutoCompleteConfiguration">
</app-multiple-auto-complete>
</mat-form-field>
<hr>
</div> -->
<!-- End of Related Grants Filters -->
<!-- Collaborators Filter -->
<!-- TODO -->
<!-- <div *ngIf="isAuthenticated()" class="col-10">
<h6 class="category-title">{{ 'CRITERIA.DMP.RELATED-COLLABORATORS' | translate}}</h6>
<mat-form-field>
<mat-label>{{'CRITERIA.DMP.SELECT-COLLABORATORS' | translate}}</mat-label>
<app-multiple-auto-complete [formControl]="formGroup.get('collaborators')"
[configuration]="collaboratorsAutoCompleteConfiguration">
</app-multiple-auto-complete>
</mat-form-field>
<hr>
</div> -->
<!-- End of Collaborators Filter -->
<!-- Role Filter --> <!-- Role Filter -->
<!-- TODO -->
<div *ngIf="isAuthenticated()" class="col-10"> <div *ngIf="isAuthenticated()" class="col-10">
<h6 class="category-title">{{ 'DMP-LISTING.FILTERS.ROLE.NAME' | translate }}</h6> <h6 class="category-title">{{ 'DMP-LISTING.FILTERS.ROLE.NAME' | translate }}</h6>
<mat-radio-group aria-label="Select an option" [formControl]="formGroup.get('role')" class="row"> <mat-radio-group aria-label="Select an option" [formControl]="formGroup.get('role')" class="row">
<mat-radio-button value="null" [checked]="!formGroup.get('role').value" class="col-12">{{ 'DMP-LISTING.FILTERS.ROLE.TYPE.ANY' | translate }}</mat-radio-button> <mat-radio-button [value]="null" [checked]="formGroup.get('role')?.value == null" class="col-12">{{ 'DMP-LISTING.FILTERS.ROLE.TYPE.ANY' | translate }}</mat-radio-button>
<mat-radio-button value="0" class="col-12">{{ 'DMP-LISTING.FILTERS.ROLE.TYPE.OWNER' | translate }}</mat-radio-button> <mat-radio-button [value]="role.Owner" class="col-12">{{ 'DMP-LISTING.FILTERS.ROLE.TYPE.OWNER' | translate }}</mat-radio-button>
<mat-radio-button value="1" class="col-12">{{ 'DMP-LISTING.FILTERS.ROLE.TYPE.MEMBER' | translate }}</mat-radio-button> <mat-radio-button [value]="role.Viewer" class="col-12">{{ 'DMP-LISTING.FILTERS.ROLE.TYPE.MEMBER' | translate }}</mat-radio-button>
<mat-radio-button [value]="role.DescriptionContributor" class="col-12">{{ 'DMP-LISTING.FILTERS.ROLE.TYPE.DescriptionContributor' | translate }}</mat-radio-button>
<mat-radio-button [value]="role.Reviewer" class="col-12">{{ 'DMP-LISTING.FILTERS.ROLE.TYPE.Reviewer' | translate }}</mat-radio-button>
</mat-radio-group> </mat-radio-group>
<hr> <hr>
</div> </div>
@ -121,6 +81,12 @@
</div> --> </div> -->
<!-- End of Related Organization Filter --> <!-- End of Related Organization Filter -->
<div class="col-auto ml-auto mb-4">
<button class="normal-btn-sm" (click)="controlModified()">
{{'DMP-LISTING.FILTERS.APPLY-FILTERS' | translate}}
</button>
</div>
</div> </div>
</div> </div>
</div> </div>

View File

@ -4,11 +4,12 @@ import { UntypedFormBuilder, UntypedFormGroup } from '@angular/forms';
import { BaseCriteriaComponent } from '@app/ui/misc/criteria/base-criteria.component'; import { BaseCriteriaComponent } from '@app/ui/misc/criteria/base-criteria.component';
import { ValidationErrorModel } from '@common/forms/validation/error-model/validation-error-model'; import { ValidationErrorModel } from '@common/forms/validation/error-model/validation-error-model';
import { TranslateService } from '@ngx-translate/core'; import { TranslateService } from '@ngx-translate/core';
import { takeUntil } from 'rxjs/operators';
import { AuthService } from '@app/core/services/auth/auth.service'; import { AuthService } from '@app/core/services/auth/auth.service';
import { DescriptionTemplateTypeService } from '@app/core/services/description-template-type/description-template-type.service';
import { MultipleAutoCompleteConfiguration } from '@app/library/auto-complete/multiple/multiple-auto-complete-configuration'; import { MultipleAutoCompleteConfiguration } from '@app/library/auto-complete/multiple/multiple-auto-complete-configuration';
import { DmpBlueprintService } from '@app/core/services/dmp/dmp-blueprint.service'; import { DmpBlueprintService } from '@app/core/services/dmp/dmp-blueprint.service';
import { DmpStatus } from '@app/core/common/enum/dmp-status';
import { DescriptionTemplateService } from '@app/core/services/description-template/description-template.service';
import { DmpUserRole } from '@app/core/common/enum/dmp-user-role';
@Component({ @Component({
selector: 'app-dmp-filter-component', selector: 'app-dmp-filter-component',
@ -20,26 +21,26 @@ export class DmpFilterComponent extends BaseCriteriaComponent implements OnInit,
@Input() showGrant: boolean; @Input() showGrant: boolean;
@Input() isPublic: boolean; @Input() isPublic: boolean;
@Input() filterFormGroup: UntypedFormGroup; @Input() filterFormGroup: UntypedFormGroup;
@Output() filtersChanged: EventEmitter<any> = new EventEmitter(); @Output() filterChanged: EventEmitter<any> = new EventEmitter();
status = DmpStatus;
role = DmpUserRole;
filteringGrantsAsync = false; filteringGrantsAsync = false;
sizeError = false; sizeError = false;
maxFileSize: number = 1048576; maxFileSize: number = 1048576;
filteringOrganisationsAsync = false; filteringOrganisationsAsync = false;
get descriptionTemplateAutoCompleteConfiguration(): MultipleAutoCompleteConfiguration { descriptionTemplateAutoCompleteConfiguration: MultipleAutoCompleteConfiguration;
return this.descriptionTemplateTypeService.getMultipleAutoCompleteSearchConfiguration(); dmpBlueprintAutoCompleteConfiguration: MultipleAutoCompleteConfiguration;
}; // get dmpBlueprintAutoCompleteConfiguration(): MultipleAutoCompleteConfiguration {
// return this.dmpBlueprintService.multipleAutocompleteConfiguration;
get dmpBlueprintAutoCompleteConfiguration(): MultipleAutoCompleteConfiguration { // };
return this.dmpBlueprintService.multipleAutocompleteConfiguration;
};
constructor( constructor(
public language: TranslateService, public language: TranslateService,
public formBuilder: UntypedFormBuilder, public formBuilder: UntypedFormBuilder,
private authentication: AuthService, private authentication: AuthService,
private descriptionTemplateTypeService: DescriptionTemplateTypeService, private descriptionTemplateService: DescriptionTemplateService,
private dmpBlueprintService: DmpBlueprintService, private dmpBlueprintService: DmpBlueprintService,
) { ) {
super(new ValidationErrorModel()); super(new ValidationErrorModel());
@ -53,18 +54,22 @@ export class DmpFilterComponent extends BaseCriteriaComponent implements OnInit,
if (changes['filterFormGroup']) { if (changes['filterFormGroup']) {
this.formGroup = this.filterFormGroup; this.formGroup = this.filterFormGroup;
this.formGroup.get('role')?.valueChanges this.descriptionTemplateAutoCompleteConfiguration = this.descriptionTemplateService.descriptionTempalteGroupMultipleAutocompleteConfiguration;
.pipe(takeUntil(this._destroyed)) this.dmpBlueprintAutoCompleteConfiguration = this.dmpBlueprintService.multipleAutocompleteConfiguration;
.subscribe(x => this.controlModified());
this.formGroup.get('status')?.valueChanges
.pipe(takeUntil(this._destroyed)) // this.formGroup.get('role')?.valueChanges
.subscribe(x => this.controlModified()); // .pipe(takeUntil(this._destroyed))
this.formGroup.get('descriptionTemplateIds')?.valueChanges // .subscribe(x => this.controlModified());
.pipe(takeUntil(this._destroyed)) // this.formGroup.get('status')?.valueChanges
.subscribe(x => this.controlModified()); // .pipe(takeUntil(this._destroyed))
this.formGroup.get('dmpBlueprintIds')?.valueChanges // .subscribe(x => this.controlModified());
.pipe(takeUntil(this._destroyed)) // this.formGroup.get('descriptionTemplateIds')?.valueChanges
.subscribe(x => this.controlModified()); // .pipe(takeUntil(this._destroyed))
// .subscribe(x => this.controlModified());
// this.formGroup.get('dmpBlueprintIds')?.valueChanges
// .pipe(takeUntil(this._destroyed))
// .subscribe(x => this.controlModified());
} }
} }
@ -74,7 +79,7 @@ export class DmpFilterComponent extends BaseCriteriaComponent implements OnInit,
controlModified(): void { controlModified(): void {
this.clearErrorModel(); this.clearErrorModel();
this.filtersChanged.emit(this.formGroup); this.filterChanged.emit(this.formGroup);
if (this.refreshCallback != null && if (this.refreshCallback != null &&
(this.formGroup.get('like').value == null || this.formGroup.get('like').value.length === 0 || this.formGroup.get('like').value.length > 2) (this.formGroup.get('like').value == null || this.formGroup.get('like').value.length === 0 || this.formGroup.get('like').value.length > 2)
) { ) {