Skip to content

Commit

Permalink
fix(assessments.component.ts): fixed build break due to deprecated Fi…
Browse files Browse the repository at this point in the history
…lterUtils

Replaced `FilterUtils` with `FilterService`
  • Loading branch information
alejandrosaenz117 committed Dec 14, 2020
1 parent 992dc1a commit d7c2ae3
Showing 1 changed file with 27 additions and 23 deletions.
50 changes: 27 additions & 23 deletions frontend/src/app/assessments/assessments.component.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Component, OnInit, ViewChild } from '@angular/core';
import { FilterUtils } from 'primeng/utils';
import { SelectItem, FilterService, FilterMatchMode } from 'primeng/api';
import { AppService } from '../app.service';
import { AlertService } from '../alert/alert.service';
import { ActivatedRoute, Router } from '@angular/router';
Expand Down Expand Up @@ -28,12 +28,12 @@ export class AssessmentsComponent implements OnInit {
cols = [
{
field: 'id',
filterMatchMode: 'contains',
filterMatchMode: FilterMatchMode.CONTAINS,
header: 'Assessment ID',
},
{
field: 'name',
filterMatchMode: 'contains',
filterMatchMode: FilterMatchMode.CONTAINS,
header: 'Assessment Name',
},
{
Expand All @@ -43,17 +43,17 @@ export class AssessmentsComponent implements OnInit {
},
{
field: 'jiraId',
filterMatchMode: 'contains',
filterMatchMode: FilterMatchMode.CONTAINS,
header: 'Jira ID',
},
{
field: 'startDate',
filterMatchMode: 'equals',
filterMatchMode: FilterMatchMode.EQUALS,
header: 'Start Date',
},
{
field: 'startDate',
filterMatchMode: 'equals',
filterMatchMode: FilterMatchMode.EQUALS,
header: 'End Date',
},
];
Expand All @@ -64,14 +64,13 @@ export class AssessmentsComponent implements OnInit {
public appService: AppService,
public alertService: AlertService,
public userService: UserService,
private filterService: FilterService
) {}

ngOnInit() {
this.activatedRoute.data.subscribe(
({assessments}) => {
this.assessmentAry = assessments;
},
);
this.activatedRoute.data.subscribe(({ assessments }) => {
this.assessmentAry = assessments;
});
this.activatedRoute.params.subscribe((params) => {
this.assetId = params.assetId;
this.orgId = params.orgId;
Expand All @@ -87,6 +86,23 @@ export class AssessmentsComponent implements OnInit {
this.addArrayCompareTableFilter();
}

/**
* Create custom table filter "matchMode" to compare multiselect filter array values to array of values in a table row field
*/
private addArrayCompareTableFilter() {
this.filterService.register(
'arrayCompare',
(values: User[], selections: FormattedUser[]): boolean => {
console.log(values, selections);
return values.some((value) => {
return !!selections.some(
(selection) => selection.name === this.formatName(value)
);
});
}
);
}

/**
* Function responsible for directing the user to the vulnerability details
* @param id of vulnerability to load
Expand Down Expand Up @@ -154,18 +170,6 @@ export class AssessmentsComponent implements OnInit {
}
}

/**
* Create custom table filter "matchMode" to compare multiselect filter array values to array of values in a table row field
*/
private addArrayCompareTableFilter() {
// @ts-ignore-next-line
FilterUtils.arrayCompare = (values: User[], selections: FormattedUser[]) => {
return values.some((value) => {
return !!selections.some((selection) => selection.name === this.formatName(value));
});
};
}

/**
* Format composite name from first and last name fields
*/
Expand Down

0 comments on commit d7c2ae3

Please sign in to comment.