From 87e76b0319f343df3deb9b5379de397418bc2765 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adina=20=C8=9Aeudan?= Date: Tue, 26 Jan 2021 21:12:56 +0200 Subject: [PATCH] Filter projects by rule set --- .../app/common/filter/utils/filter-utils.ts | 4 ++++ .../project-listing-screen.component.html | 8 +++++++ .../project-listing-screen.component.ts | 23 +++++++++++++++++-- apps/red-ui/src/assets/i18n/en.json | 3 ++- 4 files changed, 35 insertions(+), 3 deletions(-) diff --git a/apps/red-ui/src/app/common/filter/utils/filter-utils.ts b/apps/red-ui/src/app/common/filter/utils/filter-utils.ts index d634754ce..858d33161 100644 --- a/apps/red-ui/src/app/common/filter/utils/filter-utils.ts +++ b/apps/red-ui/src/app/common/filter/utils/filter-utils.ts @@ -142,6 +142,10 @@ export const projectMemberChecker = (pw: ProjectWrapper, filter: FilterModel) => return pw.hasMember(filter.key); }; +export const ruleSetChecker = (pw: ProjectWrapper, filter: FilterModel) => { + return pw.ruleSetId === filter.key; +}; + export const dueDateChecker = (pw: ProjectWrapper, filter: FilterModel) => pw.dueDateMatches(filter.key); export const addedDateChecker = (pw: ProjectWrapper, filter: FilterModel) => pw.addedDateMatches(filter.key); diff --git a/apps/red-ui/src/app/screens/project-listing-screen/project-listing-screen.component.html b/apps/red-ui/src/app/screens/project-listing-screen/project-listing-screen.component.html index 0e65ec6b1..330a52480 100644 --- a/apps/red-ui/src/app/screens/project-listing-screen/project-listing-screen.component.html +++ b/apps/red-ui/src/app/screens/project-listing-screen/project-listing-screen.component.html @@ -24,6 +24,14 @@ [filters]="needsWorkFilters" [icon]="'red:needs-work'" > +
diff --git a/apps/red-ui/src/app/screens/project-listing-screen/project-listing-screen.component.ts b/apps/red-ui/src/app/screens/project-listing-screen/project-listing-screen.component.ts index 4adfae501..f650a08ac 100644 --- a/apps/red-ui/src/app/screens/project-listing-screen/project-listing-screen.component.ts +++ b/apps/red-ui/src/app/screens/project-listing-screen/project-listing-screen.component.ts @@ -11,7 +11,8 @@ import { getFilteredEntities, processFilters, projectMemberChecker, - projectStatusChecker + projectStatusChecker, + ruleSetChecker } from '../../common/filter/utils/filter-utils'; import { TranslateService } from '@ngx-translate/core'; import { SortingOption, SortingService } from '../../utils/sorting.service'; @@ -42,6 +43,7 @@ export class ProjectListingScreenComponent implements OnInit, OnDestroy { public statusFilters: FilterModel[]; public peopleFilters: FilterModel[]; public needsWorkFilters: FilterModel[]; + public ruleSetFilters: FilterModel[]; public detailsContainerFilters: { statusFilters: FilterModel[]; @@ -55,6 +57,7 @@ export class ProjectListingScreenComponent implements OnInit, OnDestroy { @ViewChild('statusFilter') private _statusFilterComponent: FilterComponent; @ViewChild('peopleFilter') private _peopleFilterComponent: FilterComponent; @ViewChild('needsWorkFilter') private _needsWorkFilterComponent: FilterComponent; + @ViewChild('ruleSetFilter') private _ruleSetFilterComponent: FilterComponent; constructor( public readonly appStateService: AppStateService, @@ -100,6 +103,7 @@ export class ProjectListingScreenComponent implements OnInit, OnDestroy { this._statusFilterComponent?.hasActiveFilters || this._peopleFilterComponent?.hasActiveFilters || this._needsWorkFilterComponent?.hasActiveFilters || + this._ruleSetFilterComponent?.hasActiveFilters || this.searchForm.get('query').value ); } @@ -112,6 +116,7 @@ export class ProjectListingScreenComponent implements OnInit, OnDestroy { this._statusFilterComponent.deactivateAllFilters(); this._peopleFilterComponent.deactivateAllFilters(); this._needsWorkFilterComponent.deactivateAllFilters(); + this._ruleSetFilterComponent.deactivateAllFilters(); this.filtersChanged(); this.searchForm.reset({ query: '' }); } @@ -183,6 +188,7 @@ export class ProjectListingScreenComponent implements OnInit, OnDestroy { const allDistinctFileStatus = new Set(); const allDistinctPeople = new Set(); const allDistinctNeedsWork = new Set(); + const allDistinctRuleSets = new Set(); this.appStateService.allProjects.forEach((entry) => { // all people entry.project.memberIds.forEach((memberId) => allDistinctPeople.add(memberId)); @@ -199,6 +205,9 @@ export class ProjectListingScreenComponent implements OnInit, OnDestroy { if (entry.hasRequests) allDistinctNeedsWork.add('suggestion'); if (entry.hasNone) allDistinctNeedsWork.add('none'); }); + + // Rule set + allDistinctRuleSets.add(entry.ruleSetId); }); const statusFilters = []; @@ -230,6 +239,15 @@ export class ProjectListingScreenComponent implements OnInit, OnDestroy { needsWorkFilters.sort((a, b) => RedactionFilterSorter[a.key] - RedactionFilterSorter[b.key]); this.needsWorkFilters = processFilters(this.needsWorkFilters, needsWorkFilters); + + const ruleSetFilters = []; + allDistinctRuleSets.forEach((ruleSetId) => { + ruleSetFilters.push({ + key: ruleSetId, + label: this.appStateService.getRuleSetById(ruleSetId).name + }); + }); + this.ruleSetFilters = processFilters(this.ruleSetFilters, ruleSetFilters); } filtersChanged(filters?: { [key: string]: FilterModel[] }): void { @@ -252,7 +270,8 @@ export class ProjectListingScreenComponent implements OnInit, OnDestroy { checker: annotationFilterChecker, matchAll: true, checkerArgs: this.permissionsService - } + }, + { values: this.ruleSetFilters, checker: ruleSetChecker } ]; return getFilteredEntities(this.appStateService.allProjects, filters); } diff --git a/apps/red-ui/src/assets/i18n/en.json b/apps/red-ui/src/assets/i18n/en.json index ba44e6e16..a0fec885d 100644 --- a/apps/red-ui/src/assets/i18n/en.json +++ b/apps/red-ui/src/assets/i18n/en.json @@ -80,7 +80,8 @@ "created-on": "Created On", "project": "Project", "document": "Document", - "needs-work": "Analyzed" + "needs-work": "Analyzed", + "rulesets": "Rule Sets" }, "report": { "unavailable": "Redaction report is only available once all files have been approved.",