RED-6394: fix dossier state name
This commit is contained in:
parent
63eac9f053
commit
01420bf08f
@ -4,7 +4,7 @@
|
||||
</div>
|
||||
|
||||
<div class="dialog-content">
|
||||
<div class="heading">{{ 'confirm-delete-dossier-state.warning' | translate : translateArgs }}</div>
|
||||
<div [innerHTML]="'confirm-delete-dossier-state.warning' | translate : translateArgs" class="heading"></div>
|
||||
|
||||
<form *ngIf="data.dossierCount !== 0 && data.otherStates.length > 0" [formGroup]="form" class="mt-16">
|
||||
<div class="iqser-input-group">
|
||||
|
||||
@ -1,14 +1,13 @@
|
||||
import { ChangeDetectionStrategy, Component, Inject } from '@angular/core';
|
||||
import { DossierState } from '@red/domain';
|
||||
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
|
||||
import { UntypedFormBuilder, UntypedFormGroup } from '@angular/forms';
|
||||
import { FormBuilder } from '@angular/forms';
|
||||
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
|
||||
import { firstValueFrom, forkJoin } from 'rxjs';
|
||||
import { combineLatest, firstValueFrom } from 'rxjs';
|
||||
import { DossierStatesService } from '@services/entity-services/dossier-states.service';
|
||||
import { IconButtonTypes, LoadingService, Toaster } from '@iqser/common-ui';
|
||||
import { ActiveDossiersService } from '@services/dossiers/active-dossiers.service';
|
||||
import { ArchivedDossiersService } from '@services/dossiers/archived-dossiers.service';
|
||||
import { take } from 'rxjs/operators';
|
||||
|
||||
interface DialogData {
|
||||
readonly toBeDeletedState: DossierState;
|
||||
@ -17,17 +16,20 @@ interface DialogData {
|
||||
}
|
||||
|
||||
@Component({
|
||||
selector: 'redaction-confirm-delete-dossier-state-dialog',
|
||||
templateUrl: './confirm-delete-dossier-state-dialog.component.html',
|
||||
styleUrls: ['./confirm-delete-dossier-state-dialog.component.scss'],
|
||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||
})
|
||||
export class ConfirmDeleteDossierStateDialogComponent {
|
||||
readonly iconButtonTypes = IconButtonTypes;
|
||||
readonly form: UntypedFormGroup;
|
||||
readonly form = this.#form;
|
||||
readonly translateArgs = {
|
||||
name: this.data.toBeDeletedState.name,
|
||||
count: this.data.dossierCount,
|
||||
};
|
||||
|
||||
constructor(
|
||||
private readonly _formBuilder: UntypedFormBuilder,
|
||||
private readonly _formBuilder: FormBuilder,
|
||||
private readonly _loadingService: LoadingService,
|
||||
private readonly _toaster: Toaster,
|
||||
private readonly _dossierStatesService: DossierStatesService,
|
||||
@ -35,40 +37,31 @@ export class ConfirmDeleteDossierStateDialogComponent {
|
||||
private readonly _activeDossiersService: ActiveDossiersService,
|
||||
private readonly _archivedDossiersService: ArchivedDossiersService,
|
||||
@Inject(MAT_DIALOG_DATA) readonly data: DialogData,
|
||||
) {
|
||||
this.form = this.#getForm();
|
||||
}
|
||||
|
||||
get translateArgs() {
|
||||
return {
|
||||
name: this.data.toBeDeletedState.name,
|
||||
count: this.data.dossierCount,
|
||||
};
|
||||
}
|
||||
) {}
|
||||
|
||||
get label(): string {
|
||||
return this.#replaceDossierStatusId ? _('confirm-delete-dossier-state.delete-replace') : _('confirm-delete-dossier-state.delete');
|
||||
}
|
||||
|
||||
get #replaceDossierStatusId(): string {
|
||||
return this.form.get('replace').value ? this.form.get('replaceDossierStatusId').value : undefined;
|
||||
return this.form.controls.replace.value ? this.form.controls.replaceDossierStatusId.value : undefined;
|
||||
}
|
||||
|
||||
async save(): Promise<void> {
|
||||
this._loadingService.start();
|
||||
await firstValueFrom(this._dossierStatesService.deleteState(this.data.toBeDeletedState, this.#replaceDossierStatusId));
|
||||
await firstValueFrom(
|
||||
forkJoin([this._activeDossiersService.loadAll().pipe(take(1)), this._archivedDossiersService.loadAll().pipe(take(1))]),
|
||||
);
|
||||
this._toaster.success(_('confirm-delete-dossier-state.success'));
|
||||
this._dialogRef.close();
|
||||
this._loadingService.stop();
|
||||
}
|
||||
|
||||
#getForm(): UntypedFormGroup {
|
||||
get #form() {
|
||||
return this._formBuilder.group({
|
||||
replace: [false],
|
||||
replaceDossierStatusId: [null],
|
||||
});
|
||||
}
|
||||
|
||||
async save() {
|
||||
this._loadingService.start();
|
||||
|
||||
await this._dossierStatesService.deleteState(this.data.toBeDeletedState, this.#replaceDossierStatusId);
|
||||
await firstValueFrom(combineLatest([this._activeDossiersService.loadAll(), this._archivedDossiersService.loadAll()]));
|
||||
|
||||
this._toaster.success(_('confirm-delete-dossier-state.success'));
|
||||
this._dialogRef.close();
|
||||
this._loadingService.stop();
|
||||
}
|
||||
}
|
||||
|
||||
@ -37,7 +37,7 @@
|
||||
[config]="chartConfig"
|
||||
[radius]="80"
|
||||
[strokeWidth]="15"
|
||||
[subtitles]="['dossier-states-listing.chart.dossier-states' | translate: { count: chartConfig.length }]"
|
||||
[subtitles]="['dossier-states-listing.chart.dossier-states' | translate : { count: chartConfig.length }]"
|
||||
[totalType]="'simpleLabel'"
|
||||
></redaction-donut-chart>
|
||||
</div>
|
||||
@ -88,6 +88,7 @@
|
||||
[type]="circleButtonTypes.dark"
|
||||
icon="iqser:edit"
|
||||
></iqser-circle-button>
|
||||
|
||||
<iqser-circle-button
|
||||
(action)="openConfirmDeleteStateDialog($event, state)"
|
||||
[tooltip]="'dossier-states-listing.action.delete' | translate"
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { ChangeDetectionStrategy, Component, OnDestroy, OnInit } from '@angular/core';
|
||||
import { Component, OnDestroy, OnInit } from '@angular/core';
|
||||
import {
|
||||
CircleButtonTypes,
|
||||
getParam,
|
||||
@ -8,7 +8,7 @@ import {
|
||||
SortingOrders,
|
||||
TableColumnConfig,
|
||||
} from '@iqser/common-ui';
|
||||
import { DonutChartConfig, DossierState, IDossierState } from '@red/domain';
|
||||
import { type DonutChartConfig, DOSSIER_TEMPLATE_ID, type DossierState, type IDossierState } from '@red/domain';
|
||||
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
|
||||
import { firstValueFrom, Observable } from 'rxjs';
|
||||
import { AdminDialogService } from '../../services/admin-dialog.service';
|
||||
@ -20,7 +20,6 @@ import { PermissionsService } from '@services/permissions.service';
|
||||
@Component({
|
||||
templateUrl: './dossier-states-listing-screen.component.html',
|
||||
styleUrls: ['./dossier-states-listing-screen.component.scss'],
|
||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||
providers: listingProvidersFactory(DossierStatesListingScreenComponent),
|
||||
})
|
||||
export class DossierStatesListingScreenComponent extends ListingComponent<DossierState> implements OnInit, OnDestroy {
|
||||
@ -32,8 +31,8 @@ export class DossierStatesListingScreenComponent extends ListingComponent<Dossie
|
||||
{ label: _('dossier-states-listing.table-col-names.rank'), sortByKey: 'rank', class: 'flex-center' },
|
||||
{ label: _('dossier-states-listing.table-col-names.dossiers-count'), class: 'flex-center' },
|
||||
];
|
||||
chartConfig$: Observable<DonutChartConfig[]>;
|
||||
readonly #dossierTemplateId = getParam('dossierTemplateId');
|
||||
readonly chartConfig$: Observable<DonutChartConfig[]>;
|
||||
readonly #dossierTemplateId = getParam(DOSSIER_TEMPLATE_ID);
|
||||
|
||||
constructor(
|
||||
private readonly _dialogService: AdminDialogService,
|
||||
|
||||
@ -52,10 +52,9 @@ export class DossierStatesService extends EntitiesService<IDossierState, Dossier
|
||||
);
|
||||
}
|
||||
|
||||
deleteState(dossierState: IDossierState, replaceDossierStatusId?: string): Observable<unknown> {
|
||||
async deleteState(dossierState: IDossierState, replaceDossierStatusId?: string) {
|
||||
const queryParams = replaceDossierStatusId ? [{ key: 'replaceDossierStatusId', value: replaceDossierStatusId }] : null;
|
||||
return super
|
||||
.delete(dossierState.dossierStatusId, this._defaultModelPath, queryParams)
|
||||
.pipe(switchMap(() => this.loadAllForTemplate(dossierState.dossierTemplateId)));
|
||||
await firstValueFrom(super.delete(dossierState.dossierStatusId, this._defaultModelPath, queryParams));
|
||||
return firstValueFrom(this.loadAllForTemplate(dossierState.dossierTemplateId));
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user