Pull request #355: Fix dossier states

Merge in RED/ui from fix_dossier_states to master

* commit 'aedb4990e36978fc818e16a6a872053e57c30738':
  refactored group reducer
  group states by name and color for chart
  added dossier status filters
This commit is contained in:
Eduard Cziszter 2022-02-18 11:23:13 +01:00
commit a3939ea4f0
7 changed files with 56 additions and 21 deletions

View File

@ -111,7 +111,7 @@ export class DossierStatesListingScreenComponent extends ListingComponent<Dossie
try {
const dossierStates = this.dossierStateService.all.filter(d => d.dossierTemplateId === this.#dossierTemplateId);
this.#setStatesCount(dossierStates);
this.chartData = this.dossierStateService.all.map(state => {
this.chartData = dossierStates.map(state => {
return { value: state.dossierCount, label: state.name, key: state.name, color: state.color };
});

View File

@ -229,7 +229,7 @@ export class ConfigService {
filterGroups.push({
slug: 'statusFilters',
label: this._translateService.instant('filters.status'),
label: this._translateService.instant('filters.documents-status'),
icon: 'red:status',
filters: statusFilters.sort((a, b) => StatusSorter[a.id] - StatusSorter[b.id]),
checker: keyChecker('workflowStatus'),

View File

@ -3,7 +3,7 @@ import { DoughnutChartConfig } from '@shared/components/simple-doughnut-chart/si
import { FilterService, mapEach } from '@iqser/common-ui';
import { DossiersService } from '@services/entity-services/dossiers.service';
import { combineLatest, Observable } from 'rxjs';
import { Dossier, DossierStats, FileCountPerWorkflowStatus, StatusSorter } from '@red/domain';
import { DossierStats, FileCountPerWorkflowStatus, StatusSorter } from '@red/domain';
import { workflowFileStatusTranslations } from '../../../../translations/file-status-translations';
import { TranslateChartService } from '@services/translate-chart.service';
import { filter, map, switchMap } from 'rxjs/operators';
@ -36,23 +36,32 @@ export class DossiersListingDetailsComponent {
map(stats => this._toChartData(stats)),
);
this.dossiersChartData$ = this.dossiersService.all$.pipe(switchMap(dossiers => this._toDossierChartData(dossiers)));
this.dossiersChartData$ = this.dossiersService.all$.pipe(switchMap(dossiers => this._toDossierChartData()));
}
private async _toDossierChartData(dossiers: Dossier[]): Promise<DoughnutChartConfig[]> {
const config: DoughnutChartConfig[] = [];
this._dossierStateService.all.forEach(state => {
state.dossierCount = this.dossiersService.getCountWithState(state.dossierStatusId);
config.push({ value: state.dossierCount, label: state.name, color: state.color });
});
const notAssignedLength = this.dossiersService.all.length - config.map(v => v.value).reduce((acc, val) => acc + val, 0);
config.push({
private async _toDossierChartData(): Promise<DoughnutChartConfig[]> {
this._dossierStateService.all.forEach(
state => (state.dossierCount = this.dossiersService.getCountWithState(state.dossierStatusId)),
);
const configArray: DoughnutChartConfig[] = [
...this._dossierStateService.all
.reduce((acc, { color, dossierCount, name }) => {
const key = name + '-' + color;
const item = acc.get(key) ?? Object.assign({}, { value: 0, label: name, color: color });
return acc.set(key, { ...item, value: item.value + dossierCount });
}, new Map<string, DoughnutChartConfig>())
.values(),
];
const notAssignedLength = this.dossiersService.all.length - configArray.map(v => v.value).reduce((acc, val) => acc + val, 0);
configArray.push({
value: notAssignedLength,
label: this._translateService.instant('edit-dossier-dialog.general-info.form.dossier-status.placeholder'),
color: '#E2E4E9',
});
// TODO: deleted dossiers count should come with stats
return config;
return configArray;
}
private _toChartData(stats: DossierStats[]) {

View File

@ -6,10 +6,11 @@ import { TranslateService } from '@ngx-translate/core';
import { UserPreferenceService } from '@services/user-preference.service';
import { UserService } from '@services/user.service';
import { workflowFileStatusTranslations } from '../../translations/file-status-translations';
import { dossierMemberChecker, dossierTemplateChecker, RedactionFilterSorter } from '@utils/index';
import { dossierMemberChecker, dossierStateChecker, dossierTemplateChecker, RedactionFilterSorter } from '@utils/index';
import { workloadTranslations } from '../../translations/workload-translations';
import { DossierTemplatesService } from '@services/entity-services/dossier-templates.service';
import { DossierStatsService } from '@services/entity-services/dossier-stats.service';
import { DossierStateService } from '../../../../services/entity-services/dossier-state.service';
@Injectable()
export class ConfigService {
@ -19,6 +20,7 @@ export class ConfigService {
private readonly _userService: UserService,
private readonly _dossierTemplatesService: DossierTemplatesService,
private readonly _dossierStatsService: DossierStatsService,
private readonly _dossierStateService: DossierStateService,
) {}
get tableConfig(): TableColumnConfig<Dossier>[] {
@ -61,12 +63,16 @@ export class ConfigService {
const allDistinctPeople = new Set<string>();
const allDistinctNeedsWork = new Set<string>();
const allDistinctDossierTemplates = new Set<string>();
const allDistinctDossierStates = new Set<string>();
const filterGroups: IFilterGroup[] = [];
entities?.forEach(entry => {
entry.memberIds.forEach(f => allDistinctPeople.add(f));
allDistinctDossierTemplates.add(entry.dossierTemplateId);
if (entry.dossierStatusId) {
allDistinctDossierStates.add(entry.dossierStatusId);
}
const stats = this._dossierStatsService.get(entry.dossierId);
if (!stats) {
@ -89,6 +95,23 @@ export class ConfigService {
}
});
const dossierStatesFilters = [...allDistinctDossierStates].map(
id =>
new NestedFilter({
id: id,
label: this._dossierStateService.find(id).name,
}),
);
filterGroups.push({
slug: 'dossierStatesFilters',
label: this._translateService.instant('filters.dossier-status'),
icon: 'red:status',
hide: dossierStatesFilters.length <= 1,
filters: dossierStatesFilters,
checker: dossierStateChecker,
});
const statusFilters = [...allDistinctFileStatus].map(
status =>
new NestedFilter({
@ -99,7 +122,7 @@ export class ConfigService {
filterGroups.push({
slug: 'statusFilters',
label: this._translateService.instant('filters.status'),
label: this._translateService.instant('filters.documents-status'),
icon: 'red:status',
filters: statusFilters.sort((a, b) => StatusSorter[a.id] - StatusSorter[b.id]),
checker: (dossier: Dossier, filter: INestedFilter) => this._dossierStatusChecker(dossier, filter),

View File

@ -77,6 +77,8 @@ export const dossierMemberChecker = (dw: Dossier, filter: INestedFilter) => dw.h
export const dossierTemplateChecker = (dw: Dossier, filter: INestedFilter) => dw.dossierTemplateId === filter.id;
export const dossierStateChecker = (dw: Dossier, filter: INestedFilter) => dw.dossierStatusId === filter.id;
export const dossierApproverChecker = (dw: Dossier, filter: INestedFilter) => dw.approverIds.includes(filter.id);
export const userTypeFilters: { [key in UserType]: (user: User) => boolean } = {

View File

@ -1,7 +1,7 @@
{
"ADMIN_CONTACT_NAME": null,
"ADMIN_CONTACT_URL": null,
"API_URL": "https://rosa1.iqser.cloud/redaction-gateway-v1",
"API_URL": "https://dev-04.iqser.cloud/redaction-gateway-v1",
"APP_NAME": "RedactManager",
"AUTO_READ_TIME": 3,
"BACKEND_APP_VERSION": "4.4.40",
@ -17,7 +17,7 @@
"MAX_RETRIES_ON_SERVER_ERROR": 3,
"OAUTH_CLIENT_ID": "redaction",
"OAUTH_IDP_HINT": null,
"OAUTH_URL": "https://rosa1.iqser.cloud/auth/realms/redaction",
"OAUTH_URL": "https://dev-04.iqser.cloud/auth/realms/redaction",
"RECENT_PERIOD_IN_HOURS": 24,
"SELECTION_MODE": "structural",
"MANUAL_BASE_URL": "https://docs.redactmanager.com"

View File

@ -733,7 +733,6 @@
"assign-approver": "Assign Approver",
"assign-me": "Assign To Me",
"assign-reviewer": "Assign User",
"import-redactions": "Import redactions from other file",
"bulk": {
"delete": "Delete Documents",
"reanalyse": "Analyze Documents"
@ -781,6 +780,7 @@
"edit": "Edit Dossier",
"upload-document": "Upload Document"
},
"import-redactions": "Import redactions from other file",
"new-rule": {
"toast": {
"actions": {
@ -1289,12 +1289,13 @@
},
"filters": {
"assigned-people": "Assignee(s)",
"documents-status": "Documents Status",
"dossier-status": "Dossier Status",
"dossier-templates": "Dossier Templates",
"empty": "Empty",
"filter-by": "Filter:",
"needs-work": "Workload",
"people": "Dossier Member(s)",
"status": "Status"
"people": "Dossier Member(s)"
},
"general-config-screen": {
"actions": {