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 87e8458a4..b5524821d 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 b4408e4ce..d7736785c 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: '' }); } @@ -187,6 +192,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)); @@ -203,6 +209,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 = []; @@ -234,6 +243,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 { @@ -256,7 +274,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 d74d7bf38..c266e6bc9 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.",