remove file stats from dossier
This commit is contained in:
parent
a3e44b3d85
commit
9bd98a0c46
@ -1,18 +1,12 @@
|
|||||||
import { Injectable, TemplateRef } from '@angular/core';
|
import { Injectable, TemplateRef } from '@angular/core';
|
||||||
import { ButtonConfig, IFilterGroup, keyChecker, NestedFilter, TableColumnConfig } from '@iqser/common-ui';
|
import { ButtonConfig, IFilterGroup, INestedFilter, keyChecker, NestedFilter, TableColumnConfig } from '@iqser/common-ui';
|
||||||
import { Dossier, StatusSorter, User } from '@red/domain';
|
import { Dossier, StatusSorter, User } from '@red/domain';
|
||||||
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
|
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
|
||||||
import { TranslateService } from '@ngx-translate/core';
|
import { TranslateService } from '@ngx-translate/core';
|
||||||
import { UserPreferenceService } from '@services/user-preference.service';
|
import { UserPreferenceService } from '@services/user-preference.service';
|
||||||
import { UserService } from '@services/user.service';
|
import { UserService } from '@services/user.service';
|
||||||
import { fileStatusTranslations } from '../../translations/file-status-translations';
|
import { fileStatusTranslations } from '../../translations/file-status-translations';
|
||||||
import {
|
import { dossierMemberChecker, dossierTemplateChecker, RedactionFilterSorter } from '@utils/index';
|
||||||
annotationFilterChecker,
|
|
||||||
dossierMemberChecker,
|
|
||||||
dossierStatusChecker,
|
|
||||||
dossierTemplateChecker,
|
|
||||||
RedactionFilterSorter,
|
|
||||||
} from '@utils/index';
|
|
||||||
import { workloadTranslations } from '../../translations/workload-translations';
|
import { workloadTranslations } from '../../translations/workload-translations';
|
||||||
import { AppStateService } from '@state/app-state.service';
|
import { AppStateService } from '@state/app-state.service';
|
||||||
import { DossierTemplatesService } from '@services/entity-services/dossier-templates.service';
|
import { DossierTemplatesService } from '@services/entity-services/dossier-templates.service';
|
||||||
@ -89,29 +83,27 @@ export class ConfigService {
|
|||||||
const filterGroups: IFilterGroup[] = [];
|
const filterGroups: IFilterGroup[] = [];
|
||||||
|
|
||||||
entities?.forEach(entry => {
|
entities?.forEach(entry => {
|
||||||
// all people
|
|
||||||
entry.memberIds.forEach(f => allDistinctPeople.add(f));
|
entry.memberIds.forEach(f => allDistinctPeople.add(f));
|
||||||
// Needs work
|
|
||||||
entry.files.forEach(file => {
|
|
||||||
allDistinctFileStatus.add(file.status);
|
|
||||||
if (file.analysisRequired) {
|
|
||||||
allDistinctNeedsWork.add('analysis');
|
|
||||||
}
|
|
||||||
if (entry.hintsOnly) {
|
|
||||||
allDistinctNeedsWork.add('hint');
|
|
||||||
}
|
|
||||||
if (entry.hasRedactions) {
|
|
||||||
allDistinctNeedsWork.add('redaction');
|
|
||||||
}
|
|
||||||
if (entry.hasSuggestions) {
|
|
||||||
allDistinctNeedsWork.add('suggestion');
|
|
||||||
}
|
|
||||||
if (entry.hasNone) {
|
|
||||||
allDistinctNeedsWork.add('none');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
allDistinctDossierTemplates.add(entry.dossierTemplateId);
|
allDistinctDossierTemplates.add(entry.dossierTemplateId);
|
||||||
|
|
||||||
|
if (!entry.stats) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Object.keys(entry.stats?.fileCountPerWorkflowStatus).forEach(status => allDistinctFileStatus.add(status));
|
||||||
|
|
||||||
|
if (entry.stats.hasHintsNoRedactionsFilePresent) {
|
||||||
|
allDistinctNeedsWork.add('hint');
|
||||||
|
}
|
||||||
|
if (entry.stats.hasRedactionsFilePresent) {
|
||||||
|
allDistinctNeedsWork.add('redaction');
|
||||||
|
}
|
||||||
|
if (entry.stats.hasSuggestionsFilePresent) {
|
||||||
|
allDistinctNeedsWork.add('suggestion');
|
||||||
|
}
|
||||||
|
if (entry.stats.hasNoFlagsFilePresent) {
|
||||||
|
allDistinctNeedsWork.add('none');
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const statusFilters = [...allDistinctFileStatus].map(
|
const statusFilters = [...allDistinctFileStatus].map(
|
||||||
@ -127,7 +119,7 @@ export class ConfigService {
|
|||||||
label: this._translateService.instant('filters.status'),
|
label: this._translateService.instant('filters.status'),
|
||||||
icon: 'red:status',
|
icon: 'red:status',
|
||||||
filters: statusFilters.sort((a, b) => StatusSorter[a.id] - StatusSorter[b.id]),
|
filters: statusFilters.sort((a, b) => StatusSorter[a.id] - StatusSorter[b.id]),
|
||||||
checker: dossierStatusChecker,
|
checker: this._dossierStatusChecker,
|
||||||
});
|
});
|
||||||
|
|
||||||
const peopleFilters = [...allDistinctPeople].map(
|
const peopleFilters = [...allDistinctPeople].map(
|
||||||
@ -160,7 +152,7 @@ export class ConfigService {
|
|||||||
icon: 'red:needs-work',
|
icon: 'red:needs-work',
|
||||||
filterTemplate: needsWorkFilterTemplate,
|
filterTemplate: needsWorkFilterTemplate,
|
||||||
filters: needsWorkFilters.sort((a, b) => RedactionFilterSorter[a.id] - RedactionFilterSorter[b.id]),
|
filters: needsWorkFilters.sort((a, b) => RedactionFilterSorter[a.id] - RedactionFilterSorter[b.id]),
|
||||||
checker: annotationFilterChecker,
|
checker: this._annotationFilterChecker,
|
||||||
matchAll: true,
|
matchAll: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -206,4 +198,26 @@ export class ConfigService {
|
|||||||
|
|
||||||
return filterGroups;
|
return filterGroups;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private _dossierStatusChecker = (dossier: Dossier, filter: INestedFilter) => dossier.stats.fileCountPerWorkflowStatus[filter.id];
|
||||||
|
|
||||||
|
private _annotationFilterChecker = (dossier: Dossier, filter: INestedFilter) => {
|
||||||
|
switch (filter.id) {
|
||||||
|
// case 'analysis': {
|
||||||
|
// return stats.reanalysisRequired;
|
||||||
|
// }
|
||||||
|
case 'suggestion': {
|
||||||
|
return dossier.stats.hasSuggestionsFilePresent;
|
||||||
|
}
|
||||||
|
case 'redaction': {
|
||||||
|
return dossier.stats.hasRedactionsFilePresent;
|
||||||
|
}
|
||||||
|
case 'hint': {
|
||||||
|
return dossier.stats.hasHintsNoRedactionsFilePresent;
|
||||||
|
}
|
||||||
|
case 'none': {
|
||||||
|
return dossier.stats.hasNoFlagsFilePresent;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@ -73,8 +73,6 @@ export const annotationFilterChecker = (file: File, filter: INestedFilter) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export const dossierStatusChecker = (dw: Dossier, filter: INestedFilter) => dw.hasStatus(filter.id);
|
|
||||||
|
|
||||||
export const dossierMemberChecker = (dw: Dossier, filter: INestedFilter) => dw.hasMember(filter.id);
|
export const dossierMemberChecker = (dw: Dossier, filter: INestedFilter) => dw.hasMember(filter.id);
|
||||||
|
|
||||||
export const dossierTemplateChecker = (dw: Dossier, filter: INestedFilter) => dw.dossierTemplateId === filter.id;
|
export const dossierTemplateChecker = (dw: Dossier, filter: INestedFilter) => dw.dossierTemplateId === filter.id;
|
||||||
|
|||||||
@ -13,7 +13,6 @@ export class DossierStats implements IDossierStats {
|
|||||||
readonly numberOfPages: number;
|
readonly numberOfPages: number;
|
||||||
readonly numberOfFiles: number;
|
readonly numberOfFiles: number;
|
||||||
|
|
||||||
readonly hasNone: boolean;
|
|
||||||
readonly hasFiles: boolean;
|
readonly hasFiles: boolean;
|
||||||
|
|
||||||
constructor(stats: IDossierStats) {
|
constructor(stats: IDossierStats) {
|
||||||
@ -28,7 +27,6 @@ export class DossierStats implements IDossierStats {
|
|||||||
this.numberOfPages = stats.numberOfPages;
|
this.numberOfPages = stats.numberOfPages;
|
||||||
this.numberOfFiles = stats.numberOfFiles;
|
this.numberOfFiles = stats.numberOfFiles;
|
||||||
|
|
||||||
this.hasNone = !this.hasSuggestionsFilePresent && !this.hasRedactionsFilePresent && !this.hasHintsNoRedactionsFilePresent;
|
|
||||||
this.hasFiles = this.numberOfFiles > 0;
|
this.hasFiles = this.numberOfFiles > 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -26,13 +26,6 @@ export class Dossier implements IDossier, IListable {
|
|||||||
readonly watermarkEnabled: boolean;
|
readonly watermarkEnabled: boolean;
|
||||||
readonly hasReviewers: boolean;
|
readonly hasReviewers: boolean;
|
||||||
|
|
||||||
readonly reanalysisRequired = this.files.some(file => file.analysisRequired);
|
|
||||||
|
|
||||||
readonly hintsOnly: boolean;
|
|
||||||
readonly hasRedactions: boolean;
|
|
||||||
readonly hasSuggestions: boolean;
|
|
||||||
readonly hasNone: boolean;
|
|
||||||
|
|
||||||
readonly stats$: Observable<DossierStats>;
|
readonly stats$: Observable<DossierStats>;
|
||||||
private readonly _stats$: BehaviorSubject<DossierStats>;
|
private readonly _stats$: BehaviorSubject<DossierStats>;
|
||||||
|
|
||||||
@ -57,23 +50,6 @@ export class Dossier implements IDossier, IListable {
|
|||||||
|
|
||||||
this._stats$ = new BehaviorSubject<DossierStats>(stats);
|
this._stats$ = new BehaviorSubject<DossierStats>(stats);
|
||||||
this.stats$ = this._stats$.asObservable();
|
this.stats$ = this._stats$.asObservable();
|
||||||
|
|
||||||
let hintsOnly = false;
|
|
||||||
let hasRedactions = false;
|
|
||||||
let hasSuggestions = false;
|
|
||||||
let hasPendingOrProcessing = false;
|
|
||||||
|
|
||||||
this.files.forEach(f => {
|
|
||||||
hintsOnly = hintsOnly || f.hintsOnly;
|
|
||||||
hasRedactions = hasRedactions || f.hasRedactions;
|
|
||||||
hasSuggestions = hasSuggestions || f.hasSuggestions;
|
|
||||||
hasPendingOrProcessing = hasPendingOrProcessing || f.isPending || f.isProcessing;
|
|
||||||
});
|
|
||||||
|
|
||||||
this.hintsOnly = hintsOnly;
|
|
||||||
this.hasRedactions = hasRedactions;
|
|
||||||
this.hasSuggestions = hasSuggestions;
|
|
||||||
this.hasNone = !this.hasSuggestions && !this.hasRedactions && !this.hintsOnly;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
get id(): string {
|
get id(): string {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user