Pull request #108: RED-1007: Filter projects by rule set

Merge in RED/ui from RED-1007 to master

* commit '87e76b0319f343df3deb9b5379de397418bc2765':
  Filter projects by rule set
This commit is contained in:
Timo Bejan 2021-01-27 18:45:11 +01:00
commit 3ecf195c82
4 changed files with 35 additions and 3 deletions

View File

@ -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);

View File

@ -24,6 +24,14 @@
[filters]="needsWorkFilters"
[icon]="'red:needs-work'"
></redaction-filter>
<redaction-filter
*ngIf="ruleSetFilters.length > 1"
#ruleSetFilter
(filtersChanged)="filtersChanged()"
[filterLabel]="'filters.rulesets'"
[filters]="ruleSetFilters"
[icon]="'red:template'"
></redaction-filter>
<form [formGroup]="searchForm">
<div class="red-input-group w-250">
<input [placeholder]="'project-listing.search' | translate" class="with-icon mt-0" formControlName="query" name="query" type="text" />

View File

@ -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<string>();
const allDistinctPeople = new Set<string>();
const allDistinctNeedsWork = new Set<string>();
const allDistinctRuleSets = new Set<string>();
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);
}

View File

@ -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.",