load all states when loading dossiers and templates
This commit is contained in:
parent
8dc2eae525
commit
0180bf0119
@ -2,6 +2,7 @@ import { Injectable } from '@angular/core';
|
||||
import { CanActivate } from '@angular/router';
|
||||
import { DossiersService } from '@services/entity-services/dossiers.service';
|
||||
import { firstValueFrom } from 'rxjs';
|
||||
import { DossierStatsService } from '@services/entity-services/dossier-stats.service';
|
||||
|
||||
@Injectable({ providedIn: 'root' })
|
||||
export class DossiersGuard implements CanActivate {
|
||||
|
||||
@ -13,8 +13,8 @@
|
||||
<div class="iqser-input-group required w-300">
|
||||
<label translate="confirm-delete-dossier-state.form.status"></label>
|
||||
<mat-select
|
||||
formControlName="replaceDossierStatusId"
|
||||
[placeholder]="'confirm-delete-dossier-state.form.status-placeholder' | translate"
|
||||
formControlName="replaceDossierStatusId"
|
||||
>
|
||||
<mat-option *ngFor="let state of data.otherStates" [value]="state.dossierStatusId">
|
||||
{{ state.name }}
|
||||
@ -26,10 +26,7 @@
|
||||
</div>
|
||||
|
||||
<div class="dialog-actions">
|
||||
<button (click)="dialogRef.close(true)" color="primary" mat-flat-button>
|
||||
{{ 'confirm-delete-dossier-state.delete-only' | translate }}
|
||||
</button>
|
||||
<button (click)="dialogRef.close(replaceDossierStatusId)" mat-flat-button [disabled]="!replaceDossierStatusId">
|
||||
<button (click)="dialogRef.close(replaceDossierStatusId)" [disabled]="!replaceDossierStatusId" mat-flat-button>
|
||||
{{ 'confirm-delete-dossier-state.delete-replace' | translate }}
|
||||
</button>
|
||||
<div (click)="dialogRef.close()" [translate]="'confirm-delete-dossier-state.cancel'" class="all-caps-label cancel"></div>
|
||||
|
||||
@ -24,13 +24,6 @@ export class ConfirmDeleteDossierStateDialogComponent {
|
||||
@Inject(MAT_DIALOG_DATA) public data: DialogData,
|
||||
) {
|
||||
this.form = this._getForm();
|
||||
console.log(data);
|
||||
}
|
||||
|
||||
private _getForm(): FormGroup {
|
||||
return this._formBuilder.group({
|
||||
replaceDossierStatusId: [null],
|
||||
});
|
||||
}
|
||||
|
||||
get translateArgs() {
|
||||
@ -43,4 +36,10 @@ export class ConfirmDeleteDossierStateDialogComponent {
|
||||
get replaceDossierStatusId(): string {
|
||||
return this.form.get('replaceDossierStatusId').value;
|
||||
}
|
||||
|
||||
private _getForm(): FormGroup {
|
||||
return this._formBuilder.group({
|
||||
replaceDossierStatusId: [null],
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@ -73,13 +73,9 @@ export class DossierStatesListingScreenComponent extends ListingComponent<Dossie
|
||||
otherStates: this.entitiesService.all.filter(state => state.dossierStatusId !== dossierState.dossierStatusId),
|
||||
dossierCount: this._getDossiersWithStateAndTemplateCount(dossierState.dossierStatusId, templateId),
|
||||
};
|
||||
this._dialogService.openDialog('deleteDossierState', $event, data, async (value: string | true) => {
|
||||
this._dialogService.openDialog('deleteDossierState', $event, data, async (value: string) => {
|
||||
if (value) {
|
||||
if (value === true) {
|
||||
console.log('asteptam');
|
||||
} else {
|
||||
await firstValueFrom(this._dossierStateService.deleteAndReplace(dossierState.dossierStatusId, value));
|
||||
}
|
||||
await firstValueFrom(this._dossierStateService.deleteAndReplace(dossierState.dossierStatusId, value));
|
||||
}
|
||||
|
||||
await this._appStateService.refreshDossierTemplate(templateId);
|
||||
@ -104,7 +100,7 @@ export class DossierStatesListingScreenComponent extends ListingComponent<Dossie
|
||||
|
||||
try {
|
||||
const templateId = this._dossierTemplatesService.activeDossierTemplateId;
|
||||
const dossierStates = await firstValueFrom(this._dossierStateService.loadAllForTemplate(templateId));
|
||||
const dossierStates = this._dossierStateService.all.filter(d => d.dossierTemplateId === templateId);
|
||||
dossierStates.forEach(state => {
|
||||
state.dossierCount = this._getDossiersWithStateAndTemplateCount(state.dossierStatusId, templateId);
|
||||
});
|
||||
|
||||
@ -53,6 +53,23 @@
|
||||
</div>
|
||||
|
||||
<div class="flex fields-container">
|
||||
<div class="iqser-input-group w-300">
|
||||
<label translate="edit-dossier-dialog.general-info.form.dossier-status.label"></label>
|
||||
<mat-select
|
||||
[placeholder]="
|
||||
currentStatus ? currentStatus.name : ('edit-dossier-dialog.general-info.form.dossier-status.label' | translate)
|
||||
"
|
||||
formControlName="dossierStatusId"
|
||||
>
|
||||
<mat-option *ngFor="let state of states" [value]="state.dossierStatusId">
|
||||
<div class="flex-align-items-center">
|
||||
<redaction-small-chip [color]="state.description"></redaction-small-chip>
|
||||
<div>{{ state.name }}</div>
|
||||
</div>
|
||||
</mat-option>
|
||||
</mat-select>
|
||||
</div>
|
||||
|
||||
<div class="due-date">
|
||||
<mat-checkbox
|
||||
(change)="hasDueDate = !hasDueDate"
|
||||
@ -72,20 +89,6 @@
|
||||
<mat-datepicker #picker></mat-datepicker>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="iqser-input-group required w-300">
|
||||
<label translate="edit-dossier-dialog.general-info.form.dossier-status"></label>
|
||||
<mat-select
|
||||
formControlName="dossierStatusId"
|
||||
[placeholder]="
|
||||
dossier.dossierStatusId ? (stateService.getById(dossier.dossierStatusId) | async).name : 'No status assigned'
|
||||
"
|
||||
>
|
||||
<mat-option *ngFor="let state of states" [value]="dossier.dossierStatusId">
|
||||
{{ state.name }}
|
||||
</mat-option>
|
||||
</mat-select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@ -26,4 +26,12 @@
|
||||
|
||||
.fields-container {
|
||||
flex-direction: column;
|
||||
|
||||
&:first-child {
|
||||
margin-right: 40px;
|
||||
}
|
||||
}
|
||||
|
||||
redaction-small-chip {
|
||||
margin-right: 8px;
|
||||
}
|
||||
|
||||
@ -32,10 +32,11 @@ export class EditDossierGeneralInfoComponent implements OnInit, EditDossierSecti
|
||||
hasDueDate: boolean;
|
||||
dossierTemplates: IDossierTemplate[];
|
||||
states: DossierState[];
|
||||
currentStatus: DossierState;
|
||||
|
||||
constructor(
|
||||
readonly permissionsService: PermissionsService,
|
||||
readonly stateService: DossierStateService,
|
||||
private readonly _dossierStateService: DossierStateService,
|
||||
private readonly _dossierTemplatesService: DossierTemplatesService,
|
||||
private readonly _dossiersService: DossiersService,
|
||||
private readonly _dossierStatsService: DossierStatsService,
|
||||
@ -77,7 +78,10 @@ export class EditDossierGeneralInfoComponent implements OnInit, EditDossierSecti
|
||||
if (!this.permissionsService.canEditDossier(this.dossier)) {
|
||||
this.form.disable();
|
||||
}
|
||||
this.states = await firstValueFrom(this.stateService.loadAllForTemplate(this.dossier.dossierTemplateId));
|
||||
this.states = this._dossierStateService.all.filter(s => s.dossierTemplateId === this.dossier.dossierTemplateId);
|
||||
if (this.dossier.dossierStatusId) {
|
||||
this.currentStatus = this._dossierStateService.all.find(s => s.dossierStatusId === this.dossier.dossierStatusId);
|
||||
}
|
||||
this.hasDueDate = !!this.dossier.dueDate;
|
||||
}
|
||||
|
||||
|
||||
@ -1,13 +1,13 @@
|
||||
<ng-container *ngIf="dossierState$ | async as dossierState">
|
||||
<ng-container *ngIf="dossier.dossierStatusId">
|
||||
<div class="flex-align-items-center dossier-status-container">
|
||||
<div class="dossier-status-text">{{ dossierState.name }}</div>
|
||||
<div class="dossier-status-chip" [style.background-color]="dossierState.description"></div>
|
||||
<div class="dossier-status-text">{{ currentState.name }}</div>
|
||||
<redaction-small-chip [color]="currentState.description"></redaction-small-chip>
|
||||
</div>
|
||||
</ng-container>
|
||||
<ng-container *ngIf="(dossierState$ | async) === null">
|
||||
<ng-container *ngIf="!dossier.dossierStatusId">
|
||||
<div class="flex-align-items-center dossier-status-container">
|
||||
<div class="dossier-status-text">No status assigned</div>
|
||||
</div>
|
||||
</ng-container>
|
||||
|
||||
<redaction-dossiers-listing-actions [stats]="stats" [dossier]="dossier"></redaction-dossiers-listing-actions>
|
||||
<redaction-dossiers-listing-actions [dossier]="dossier" [stats]="stats"></redaction-dossiers-listing-actions>
|
||||
|
||||
@ -5,10 +5,7 @@
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.dossier-status-chip {
|
||||
width: 12px;
|
||||
height: 6px;
|
||||
border-radius: 6px;
|
||||
redaction-small-chip {
|
||||
margin-left: 8px;
|
||||
}
|
||||
|
||||
|
||||
@ -1,8 +1,7 @@
|
||||
import { ChangeDetectionStrategy, Component, Input, OnInit } from '@angular/core';
|
||||
import { DossierState } from '../../../../../../../../../../libs/red-domain/src/lib/dossier-state';
|
||||
import { Dossier, DossierStats } from '../../../../../../../../../../libs/red-domain/src';
|
||||
import { Observable } from 'rxjs';
|
||||
import { DossierStateService } from '../../../../../../services/entity-services/dossier-state.service';
|
||||
import { DossierState } from '../../../../../../../../../../libs/red-domain/src/lib/dossier-state';
|
||||
|
||||
@Component({
|
||||
selector: 'redaction-dossiers-listing-status',
|
||||
@ -11,15 +10,15 @@ import { DossierStateService } from '../../../../../../services/entity-services/
|
||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||
})
|
||||
export class DossiersListingStatusComponent implements OnInit {
|
||||
dossierState$: Observable<DossierState>;
|
||||
@Input() stats: DossierStats;
|
||||
@Input() dossier: Dossier;
|
||||
currentState: DossierState;
|
||||
|
||||
constructor(private readonly _dossierStateService: DossierStateService) {}
|
||||
|
||||
ngOnInit(): void {
|
||||
if (this.dossier.dossierStatusId) {
|
||||
this.dossierState$ = this._dossierStateService.getById(this.dossier.dossierStatusId);
|
||||
this.currentState = this._dossierStateService.all.find(s => s.dossierStatusId === this.dossier.dossierStatusId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,13 +1,15 @@
|
||||
import { Injectable, Injector } from '@angular/core';
|
||||
import { EntitiesService, RequiredParam, Validate } from '../../../../../../libs/common-ui/src';
|
||||
import { EntitiesService, mapEach, RequiredParam, Validate } from '../../../../../../libs/common-ui/src';
|
||||
import { DossierState, IDossierState } from '../../../../../../libs/red-domain/src/lib/dossier-state';
|
||||
import { Observable } from 'rxjs';
|
||||
import { forkJoin, Observable, switchMap } from 'rxjs';
|
||||
import { DossierTemplatesService } from '@services/entity-services/dossier-templates.service';
|
||||
import { map } from 'rxjs/operators';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class DossierStateService extends EntitiesService<DossierState, IDossierState> {
|
||||
constructor(protected readonly _injector: Injector) {
|
||||
constructor(protected readonly _injector: Injector, private readonly _dossierTemplatesService: DossierTemplatesService) {
|
||||
super(_injector, DossierState, 'dossier-status');
|
||||
}
|
||||
|
||||
@ -21,6 +23,15 @@ export class DossierStateService extends EntitiesService<DossierState, IDossierS
|
||||
return this.loadAll(`${this._defaultModelPath}/dossier-template/${templateId}`);
|
||||
}
|
||||
|
||||
loadAllForAllTemplates(): Observable<DossierState[]> {
|
||||
return this._dossierTemplatesService.all$.pipe(
|
||||
mapEach(template => template.dossierTemplateId),
|
||||
mapEach(id => this.loadAllForTemplate(id)),
|
||||
switchMap(all => forkJoin(all)),
|
||||
map(value => value.flatMap(item => item)),
|
||||
);
|
||||
}
|
||||
|
||||
@Validate()
|
||||
deleteAndReplace(@RequiredParam() dossierStatusId: string, @RequiredParam() replaceDossierStatusId: string) {
|
||||
const url = `${this._defaultModelPath}/${dossierStatusId}?replaceDossierStatusId=${replaceDossierStatusId}`;
|
||||
|
||||
@ -7,6 +7,7 @@ import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
|
||||
import { HttpErrorResponse, HttpStatusCode } from '@angular/common/http';
|
||||
import { DossierStatsService } from '@services/entity-services/dossier-stats.service';
|
||||
import { CHANGED_CHECK_INTERVAL } from '@utils/constants';
|
||||
import { DossierStateService } from '@services/entity-services/dossier-state.service';
|
||||
|
||||
export interface IDossiersStats {
|
||||
totalPeople: number;
|
||||
@ -37,6 +38,7 @@ export class DossiersService extends EntitiesService<Dossier, IDossier> {
|
||||
private readonly _toaster: Toaster,
|
||||
protected readonly _injector: Injector,
|
||||
private readonly _dossierStatsService: DossierStatsService,
|
||||
private readonly _dossierStateService: DossierStateService,
|
||||
) {
|
||||
super(_injector, Dossier, 'dossier');
|
||||
|
||||
@ -54,6 +56,7 @@ export class DossiersService extends EntitiesService<Dossier, IDossier> {
|
||||
mapEach(entity => new Dossier(entity)),
|
||||
/* Load stats before updating entities */
|
||||
switchMap(dossiers => this._dossierStatsService.getFor(dossierIds(dossiers)).pipe(mapTo(dossiers))),
|
||||
switchMap(dossiers => this._dossierStateService.loadAllForAllTemplates().pipe(mapTo(dossiers))),
|
||||
tap(dossiers => this.setEntities(dossiers)),
|
||||
);
|
||||
}
|
||||
|
||||
@ -429,7 +429,6 @@
|
||||
"status": "Replace Status",
|
||||
"status-placeholder": "Choose another status"
|
||||
},
|
||||
"delete-only": "Delete Only",
|
||||
"delete-replace": "Delete and Replace",
|
||||
"cancel": "Cancel"
|
||||
},
|
||||
@ -1008,7 +1007,10 @@
|
||||
"placeholder": "Enter Description"
|
||||
},
|
||||
"due-date": "Due Date",
|
||||
"dossier-status": "Dossier Status",
|
||||
"dossier-status": {
|
||||
"label": "Dossier Status",
|
||||
"placeholder": "No status assigned"
|
||||
},
|
||||
"name": {
|
||||
"label": "Dossier Name",
|
||||
"placeholder": "Enter Name"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user