improvements in dossier-states-listing
This commit is contained in:
parent
b7d290778e
commit
1094495e26
@ -23,7 +23,7 @@ export class ConfirmDeleteDossierStateDialogComponent {
|
||||
readonly dialogRef: MatDialogRef<ConfirmDeleteDossierStateDialogComponent>,
|
||||
@Inject(MAT_DIALOG_DATA) readonly data: DialogData,
|
||||
) {
|
||||
this.form = this._getForm();
|
||||
this.form = this.#getForm();
|
||||
}
|
||||
|
||||
get translateArgs() {
|
||||
@ -42,14 +42,10 @@ export class ConfirmDeleteDossierStateDialogComponent {
|
||||
}
|
||||
|
||||
get afterCloseValue(): string | true {
|
||||
if (this.replaceDossierStatusId) {
|
||||
return this.replaceDossierStatusId;
|
||||
}
|
||||
|
||||
return true;
|
||||
return this.replaceDossierStatusId ?? true;
|
||||
}
|
||||
|
||||
private _getForm(): FormGroup {
|
||||
#getForm(): FormGroup {
|
||||
return this._formBuilder.group({
|
||||
replaceDossierStatusId: [null],
|
||||
});
|
||||
|
||||
@ -56,8 +56,8 @@ export class DossierStatesListingScreenComponent extends ListingComponent<Dossie
|
||||
this.#dossierTemplateId = _route.snapshot.paramMap.get('dossierTemplateId');
|
||||
}
|
||||
|
||||
async ngOnInit(): Promise<void> {
|
||||
await this.#loadData();
|
||||
ngOnInit(): Promise<void> {
|
||||
return this.#loadData();
|
||||
}
|
||||
|
||||
openAddEditStateDialog($event: MouseEvent, dossierState?: IDossierState) {
|
||||
@ -109,27 +109,18 @@ export class DossierStatesListingScreenComponent extends ListingComponent<Dossie
|
||||
await firstValueFrom(this._dossiersService.loadAll());
|
||||
|
||||
try {
|
||||
const templateId = this.#dossierTemplateId;
|
||||
const dossierStates = this.dossierStateService.all.filter(d => d.dossierTemplateId === templateId);
|
||||
this.#setStatesCount();
|
||||
this.chartData = this.#loadChartData();
|
||||
const dossierStates = this.dossierStateService.all.filter(d => d.dossierTemplateId === this.#dossierTemplateId);
|
||||
this.#setStatesCount(dossierStates);
|
||||
this.chartData = this.dossierStateService.all.map(state => {
|
||||
return { value: state.dossierCount, label: state.name, key: state.name, color: state.color };
|
||||
});
|
||||
|
||||
this.entitiesService.setEntities(dossierStates || []);
|
||||
} catch (e) {}
|
||||
this._loadingService.stop();
|
||||
}
|
||||
|
||||
#loadChartData(): DoughnutChartConfig[] {
|
||||
const config: DoughnutChartConfig[] = [];
|
||||
this.dossierStateService.all.forEach(state => {
|
||||
config.push({ value: state.dossierCount, label: state.name, key: state.name, color: state.color });
|
||||
});
|
||||
|
||||
return config;
|
||||
}
|
||||
|
||||
#setStatesCount(): void {
|
||||
this.dossierStateService.all.forEach(
|
||||
state => (state.dossierCount = this._dossiersService.getCountWithState(state.dossierStatusId)),
|
||||
);
|
||||
#setStatesCount(dossierStates: DossierState[]): void {
|
||||
dossierStates.forEach(state => (state.dossierCount = this._dossiersService.getCountWithState(state.dossierStatusId)));
|
||||
}
|
||||
}
|
||||
|
||||
@ -72,8 +72,8 @@ export class EditDossierGeneralInfoComponent implements OnInit, EditDossierSecti
|
||||
}
|
||||
|
||||
async ngOnInit() {
|
||||
this._filterInvalidDossierTemplates();
|
||||
this.form = this._getForm();
|
||||
this.#filterInvalidDossierTemplates();
|
||||
this.form = this.#getForm();
|
||||
if (!this.permissionsService.canEditDossier(this.dossier)) {
|
||||
this.form.disable();
|
||||
}
|
||||
@ -132,11 +132,11 @@ export class EditDossierGeneralInfoComponent implements OnInit, EditDossierSecti
|
||||
this._dialogService.openDialog('confirm', null, data, async () => {
|
||||
await firstValueFrom(this._dossiersService.delete(this.dossier));
|
||||
this._editDossierDialogRef.close();
|
||||
this._router.navigate(['main', 'dossiers']).then(() => this._notifyDossierDeleted());
|
||||
this._router.navigate(['main', 'dossiers']).then(() => this.#notifyDossierDeleted());
|
||||
});
|
||||
}
|
||||
|
||||
private _getForm(): FormGroup {
|
||||
#getForm(): FormGroup {
|
||||
return this._formBuilder.group({
|
||||
dossierName: [this.dossier.dossierName, Validators.required],
|
||||
dossierTemplateId: [
|
||||
@ -154,11 +154,11 @@ export class EditDossierGeneralInfoComponent implements OnInit, EditDossierSecti
|
||||
});
|
||||
}
|
||||
|
||||
private _notifyDossierDeleted() {
|
||||
#notifyDossierDeleted() {
|
||||
this._toaster.success(_('edit-dossier-dialog.delete-successful'), { params: { dossierName: this.dossier.dossierName } });
|
||||
}
|
||||
|
||||
private _filterInvalidDossierTemplates() {
|
||||
#filterInvalidDossierTemplates() {
|
||||
this.dossierTemplates = this._dossierTemplatesService.all.filter(r => {
|
||||
if (this.dossier?.dossierTemplateId === r.dossierTemplateId) {
|
||||
return true;
|
||||
|
||||
@ -14,15 +14,15 @@ export class TableItemComponent implements OnChanges {
|
||||
@Input() dossier!: Dossier;
|
||||
|
||||
readonly stats$: Observable<DossierStats>;
|
||||
private readonly _ngOnChanges$ = new BehaviorSubject<string>(undefined);
|
||||
readonly #ngOnChanges$ = new BehaviorSubject<string>(undefined);
|
||||
|
||||
constructor(readonly dossierStatsService: DossierStatsService) {
|
||||
this.stats$ = this._ngOnChanges$.pipe(switchMap(dossierId => this.dossierStatsService.watch$(dossierId)));
|
||||
this.stats$ = this.#ngOnChanges$.pipe(switchMap(dossierId => this.dossierStatsService.watch$(dossierId)));
|
||||
}
|
||||
|
||||
ngOnChanges() {
|
||||
if (this.dossier) {
|
||||
this._ngOnChanges$.next(this.dossier.dossierId);
|
||||
this.#ngOnChanges$.next(this.dossier.dossierId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user