added description-dmp filter

This commit is contained in:
Sofia Papacharalampous 2024-06-26 12:15:52 +03:00
parent 42c7712763
commit 0fbb473a4a
3 changed files with 26 additions and 7 deletions

View File

@ -22,7 +22,6 @@ export class DescriptionLookup extends Lookup implements DescriptionFilter {
showAllVersions: boolean; //TODO
descriptionTemplateIds: Guid[]; //TODO
associatedDmpIds: Guid[]; //TODO
roleInDmp: DmpUserRole[]; //TODO
descriptionTagSubQuery: DescriptionTagLookup;
descriptionReferenceSubQuery: DescriptionReferenceLookup;
@ -45,7 +44,6 @@ export interface DescriptionFilter {
statuses: DescriptionStatus[];
showAllVersions: boolean;
descriptionTemplateIds: Guid[];
associatedDmpIds: Guid[];
roleInDmp: DmpUserRole[];
descriptionTagSubQuery: DescriptionTagLookup;
descriptionReferenceSubQuery: DescriptionReferenceLookup;

View File

@ -29,7 +29,7 @@
</button>
</div>
</div>
<div *ngIf="listingItems && listingItems.length > 0 || lookup.like || lookup.descriptionTemplateIds || lookup.associatedDmpIds || lookup.roleInDmp || lookup.descriptionTagSubQuery || lookup.descriptionReferenceSubQuery"
<div *ngIf="listingItems && listingItems.length > 0 || lookup.like || lookup.descriptionTemplateIds || lookup.dmpSubQuery || lookup.roleInDmp || lookup.descriptionTagSubQuery || lookup.descriptionReferenceSubQuery"
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">
<mat-icon class="mr-4 filter-icon">filter_alt</mat-icon>

View File

@ -39,6 +39,8 @@ import { Guid } from '@common/types/guid';
import { DescriptionReferenceLookup } from '@app/core/query/reference.lookup';
import { DescriptionTagLookup } from '@app/core/query/tag.lookup';
import { Tag } from '@app/core/model/tag/tag';
import { D } from '@angular/cdk/keycodes';
import { DmpLookup } from '@app/core/query/dmp.lookup';
@Component({
selector: 'app-description-listing-component',
@ -217,6 +219,19 @@ export class DescriptionListingComponent extends BaseListingComponent<BaseDescri
return lookup;
}
protected initializeDmpLookup(): DmpLookup {
const lookup = new DmpLookup();
lookup.metadata = { countAll: true };
lookup.isActive = [IsActive.Active];
lookup.project = {
fields: [
[nameof<Description>(x => x.dmp), nameof<Dmp>(x => x.id)].join('.'),
]
};
return lookup;
}
protected setupColumns() {
}
@ -394,12 +409,18 @@ export class DescriptionListingComponent extends BaseListingComponent<BaseDescri
lookup.statuses = formGroup.get("status")?.value !== null ? [formGroup.get("status")?.value] : null;
lookup.showAllVersions = formGroup.get("showAllVersions")?.value ?? false;
lookup.roleInDmp = formGroup.get("role")?.value !== null ? [formGroup.get("role")?.value] : null;
lookup.associatedDmpIds = formGroup.get("associatedDmpIds")?.value ?? null;
lookup.descriptionTemplateIds = formGroup.get("descriptionTemplates")?.value ?? null;
// Dmps
let dmps = formGroup.get("associatedDmpIds")?.value ?? null;
if (dmps && dmps?.length > 0) {
lookup.dmpSubQuery = this.initializeDmpLookup();
lookup.dmpSubQuery.ids = dmps;
} else lookup.dmpSubQuery = null;
// Tags
let tags = formGroup.get("tags")?.value ?? null;
if (tags && tags.length > 0) {
if (tags && tags?.length > 0) {
lookup.descriptionTagSubQuery = this.initializeTagLookup();
lookup.descriptionTagSubQuery.tagIds = tags;
} else lookup.descriptionTagSubQuery = null;
@ -438,7 +459,7 @@ export class DescriptionListingComponent extends BaseListingComponent<BaseDescri
role: [lookup.roleInDmp?.length > 0 ? lookup.roleInDmp[0] : null],
showAllVersions: [lookup.showAllVersions ?? false],
descriptionTemplates: [lookup.descriptionTemplateIds],
associatedDmpIds: [lookup.associatedDmpIds],
associatedDmpIds: lookup.dmpSubQuery?.ids ? [lookup.dmpSubQuery?.ids] : [],
tags: lookup.descriptionTagSubQuery?.tagIds ? [lookup.descriptionTagSubQuery?.tagIds] : [],
references: formArray
});