firstValueFrom instead of toPromise() in dossier module
This commit is contained in:
parent
b1d2ac55b1
commit
b7a370b2d9
@ -8,6 +8,7 @@ import { BaseDialogComponent, IconButtonTypes, SaveOptions } from '@iqser/common
|
||||
import { DossiersService } from '@services/entity-services/dossiers.service';
|
||||
import { DossierTemplatesService } from '@services/entity-services/dossier-templates.service';
|
||||
import { ReportTemplateService } from '@services/report-template.service';
|
||||
import { firstValueFrom } from 'rxjs';
|
||||
|
||||
@Component({
|
||||
templateUrl: './add-dossier-dialog.component.html',
|
||||
@ -38,27 +39,6 @@ export class AddDossierDialogComponent extends BaseDialogComponent {
|
||||
this.initialFormValue = this.form.getRawValue();
|
||||
}
|
||||
|
||||
private _getForm(): FormGroup {
|
||||
return this._formBuilder.group(
|
||||
{
|
||||
dossierName: [null, Validators.required],
|
||||
dossierTemplateId: [null, Validators.required],
|
||||
downloadFileTypes: [null],
|
||||
reportTemplateIds: [null],
|
||||
description: [null],
|
||||
dueDate: [null],
|
||||
watermarkEnabled: [true],
|
||||
watermarkPreviewEnabled: [false],
|
||||
},
|
||||
{
|
||||
validators: control =>
|
||||
control.value.reportTemplateIds?.length > 0 || control.value.downloadFileTypes?.length > 0
|
||||
? null
|
||||
: { downloadPackage: true },
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
get reportTemplateIdsLength() {
|
||||
return this.form.controls['reportTemplateIds']?.value?.length || 0;
|
||||
}
|
||||
@ -78,7 +58,7 @@ export class AddDossierDialogComponent extends BaseDialogComponent {
|
||||
reportTemplateValueMapper = (reportTemplate: IReportTemplate) => reportTemplate.templateId;
|
||||
|
||||
async save(options?: SaveOptions) {
|
||||
const savedDossier = await this._dossiersService.createOrUpdate(this._formToObject()).toPromise();
|
||||
const savedDossier = await firstValueFrom(this._dossiersService.createOrUpdate(this._formToObject()));
|
||||
if (savedDossier) {
|
||||
this._dialogRef.close({ dossier: savedDossier, addMembers: options?.addMembers });
|
||||
}
|
||||
@ -90,7 +70,7 @@ export class AddDossierDialogComponent extends BaseDialogComponent {
|
||||
|
||||
if (dossierTemplate) {
|
||||
this.availableReportTypes =
|
||||
(await this._reportTemplateController.getAvailableReportTemplates(dossierTemplate.dossierTemplateId).toPromise()) || [];
|
||||
(await firstValueFrom(this._reportTemplateController.getAvailableReportTemplates(dossierTemplate.dossierTemplateId))) || [];
|
||||
// update dropdown values
|
||||
this.form.patchValue(
|
||||
{
|
||||
@ -111,6 +91,27 @@ export class AddDossierDialogComponent extends BaseDialogComponent {
|
||||
}
|
||||
}
|
||||
|
||||
private _getForm(): FormGroup {
|
||||
return this._formBuilder.group(
|
||||
{
|
||||
dossierName: [null, Validators.required],
|
||||
dossierTemplateId: [null, Validators.required],
|
||||
downloadFileTypes: [null],
|
||||
reportTemplateIds: [null],
|
||||
description: [null],
|
||||
dueDate: [null],
|
||||
watermarkEnabled: [true],
|
||||
watermarkPreviewEnabled: [false],
|
||||
},
|
||||
{
|
||||
validators: control =>
|
||||
control.value.reportTemplateIds?.length > 0 || control.value.downloadFileTypes?.length > 0
|
||||
? null
|
||||
: { downloadPackage: true },
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
private _getDossierTemplates() {
|
||||
this.dossierTemplates = this._dossierTemplatesService.all
|
||||
.filter(r => {
|
||||
|
||||
@ -8,6 +8,7 @@ import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
|
||||
import { FilesService } from '@services/entity-services/files.service';
|
||||
import { DossiersService } from '@services/entity-services/dossiers.service';
|
||||
import { PermissionsService } from '@services/permissions.service';
|
||||
import { firstValueFrom } from 'rxjs';
|
||||
|
||||
class DialogData {
|
||||
mode: 'approver' | 'reviewer';
|
||||
@ -101,28 +102,28 @@ export class AssignReviewerApproverDialogComponent {
|
||||
this._loadingService.start();
|
||||
try {
|
||||
if (!this.selectedUser) {
|
||||
await this._filesService
|
||||
.setUnassigned(
|
||||
await firstValueFrom(
|
||||
this._filesService.setUnassigned(
|
||||
this.data.files.map(f => f.fileId),
|
||||
this.dossier.id,
|
||||
)
|
||||
.toPromise();
|
||||
),
|
||||
);
|
||||
} else if (this.data.mode === 'reviewer') {
|
||||
await this._filesService
|
||||
.setReviewerFor(
|
||||
await firstValueFrom(
|
||||
this._filesService.setReviewerFor(
|
||||
this.data.files.map(f => f.fileId),
|
||||
this.dossier.id,
|
||||
this.selectedUser,
|
||||
)
|
||||
.toPromise();
|
||||
),
|
||||
);
|
||||
} else {
|
||||
await this._filesService
|
||||
.setUnderApprovalFor(
|
||||
await firstValueFrom(
|
||||
this._filesService.setUnderApprovalFor(
|
||||
this.data.files.map(f => f.fileId),
|
||||
this.dossier.id,
|
||||
this.selectedUser,
|
||||
)
|
||||
.toPromise();
|
||||
),
|
||||
);
|
||||
}
|
||||
} catch (error) {
|
||||
this._toaster.error(_('error.http.generic'), { params: error });
|
||||
|
||||
@ -7,6 +7,7 @@ import { DossiersService } from '@services/entity-services/dossiers.service';
|
||||
import { JustificationsService } from '@services/entity-services/justifications.service';
|
||||
import { Dossier } from '@red/domain';
|
||||
import { BaseDialogComponent } from '@iqser/common-ui';
|
||||
import { firstValueFrom } from 'rxjs';
|
||||
|
||||
export interface LegalBasisOption {
|
||||
label?: string;
|
||||
@ -40,7 +41,7 @@ export class ChangeLegalBasisDialogComponent extends BaseDialogComponent impleme
|
||||
|
||||
async ngOnInit() {
|
||||
super.ngOnInit();
|
||||
const data = await this._justificationsService.getForDossierTemplate(this._data.dossier.dossierTemplateId).toPromise();
|
||||
const data = await firstValueFrom(this._justificationsService.getForDossierTemplate(this._data.dossier.dossierTemplateId));
|
||||
|
||||
this.legalOptions = data
|
||||
.map<LegalBasisOption>(lbm => ({
|
||||
@ -56,6 +57,15 @@ export class ChangeLegalBasisDialogComponent extends BaseDialogComponent impleme
|
||||
this.initialFormValue = this.form.getRawValue();
|
||||
}
|
||||
|
||||
save() {
|
||||
this._dialogRef.close({
|
||||
legalBasis: this.form.get('reason').value.legalBasis,
|
||||
section: this.form.get('section').value,
|
||||
comment: this.form.get('comment').value,
|
||||
value: this.form.get('classification').value,
|
||||
});
|
||||
}
|
||||
|
||||
private _getForm(): FormGroup {
|
||||
this.isDocumentAdmin = this._permissionsService.isApprover(this._data.dossier);
|
||||
return this._formBuilder.group({
|
||||
@ -65,13 +75,4 @@ export class ChangeLegalBasisDialogComponent extends BaseDialogComponent impleme
|
||||
section: [this._data.annotations[0].section],
|
||||
});
|
||||
}
|
||||
|
||||
save() {
|
||||
this._dialogRef.close({
|
||||
legalBasis: this.form.get('reason').value.legalBasis,
|
||||
section: this.form.get('section').value,
|
||||
comment: this.form.get('comment').value,
|
||||
value: this.form.get('classification').value,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@ -6,6 +6,7 @@ import { FileAttributesService } from '@services/entity-services/file-attributes
|
||||
import { DossiersService } from '@services/entity-services/dossiers.service';
|
||||
import { FilesService } from '@services/entity-services/files.service';
|
||||
import { BaseDialogComponent } from '@iqser/common-ui';
|
||||
import { firstValueFrom } from 'rxjs';
|
||||
|
||||
@Component({
|
||||
templateUrl: './document-info-dialog.component.html',
|
||||
@ -33,7 +34,7 @@ export class DocumentInfoDialogComponent extends BaseDialogComponent implements
|
||||
async ngOnInit() {
|
||||
super.ngOnInit();
|
||||
this.attributes = (
|
||||
await this._fileAttributesService.getFileAttributesConfig(this._dossier.dossierTemplateId).toPromise()
|
||||
await firstValueFrom(this._fileAttributesService.getFileAttributesConfig(this._dossier.dossierTemplateId))
|
||||
).fileAttributeConfigs.filter(attr => attr.editable);
|
||||
this.form = this._getForm();
|
||||
this.initialFormValue = this.form.getRawValue();
|
||||
@ -44,7 +45,7 @@ export class DocumentInfoDialogComponent extends BaseDialogComponent implements
|
||||
...this.data.fileAttributes?.attributeIdToValue,
|
||||
...this.form.getRawValue(),
|
||||
};
|
||||
await this._fileAttributesService.setFileAttributes({ attributeIdToValue }, this.data.dossierId, this.data.fileId).toPromise();
|
||||
await firstValueFrom(this._fileAttributesService.setFileAttributes({ attributeIdToValue }, this.data.dossierId, this.data.fileId));
|
||||
this._filesService.reload(this.data.dossierId, this.data.fileId);
|
||||
this._dialogRef.close(true);
|
||||
}
|
||||
|
||||
@ -7,6 +7,7 @@ import { FormBuilder, FormGroup } from '@angular/forms';
|
||||
import * as moment from 'moment';
|
||||
import { DossierAttributesService } from '@shared/services/controller-wrappers/dossier-attributes.service';
|
||||
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
|
||||
import { firstValueFrom } from 'rxjs';
|
||||
|
||||
@Component({
|
||||
selector: 'redaction-edit-dossier-attributes',
|
||||
@ -72,7 +73,7 @@ export class EditDossierAttributesComponent implements EditDossierSectionInterfa
|
||||
: this.currentAttrValue(attr),
|
||||
}));
|
||||
try {
|
||||
await this._dossierAttributesService.setAttributes(this.dossier, dossierAttributeList).toPromise();
|
||||
await firstValueFrom(this._dossierAttributesService.setAttributes(this.dossier, dossierAttributeList));
|
||||
await this._loadAttributes();
|
||||
return { success: true };
|
||||
} catch (error) {
|
||||
|
||||
@ -16,7 +16,7 @@ import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
|
||||
import * as moment from 'moment';
|
||||
import { ConfigService } from '@services/config.service';
|
||||
import { getLeftDateTime } from '@utils/functions';
|
||||
import { Observable, of } from 'rxjs';
|
||||
import { firstValueFrom, Observable, of } from 'rxjs';
|
||||
import { distinctUntilChanged, map } from 'rxjs/operators';
|
||||
import { DossiersDialogService } from '../../../services/dossiers-dialog.service';
|
||||
import { FilesService } from '@services/entity-services/files.service';
|
||||
@ -107,7 +107,7 @@ export class EditDossierDeletedDocumentsComponent extends ListingComponent<FileL
|
||||
|
||||
async ngOnInit() {
|
||||
this._loadingService.start();
|
||||
const files = await this._filesService.getDeletedFilesFor(this.dossier.id).toPromise();
|
||||
const files = await firstValueFrom(this._filesService.getDeletedFilesFor(this.dossier.id));
|
||||
this.entitiesService.setEntities(this._toListItems(files));
|
||||
this.sortingService.setSortingOption({
|
||||
column: 'softDeleted',
|
||||
@ -119,7 +119,7 @@ export class EditDossierDeletedDocumentsComponent extends ListingComponent<FileL
|
||||
revert() {}
|
||||
|
||||
save(): EditDossierSaveResult {
|
||||
return of({ success: true }).toPromise();
|
||||
return firstValueFrom(of({ success: true }));
|
||||
}
|
||||
|
||||
restore(files = this.listingService.selected) {
|
||||
@ -130,14 +130,14 @@ export class EditDossierDeletedDocumentsComponent extends ListingComponent<FileL
|
||||
|
||||
private async _restore(files: FileListItem[]): Promise<void> {
|
||||
const fileIds = files.map(f => f.fileId);
|
||||
await this._fileManagementService.restore(fileIds, this.dossier.id).toPromise();
|
||||
await firstValueFrom(this._fileManagementService.restore(fileIds, this.dossier.id));
|
||||
this._removeFromList(fileIds);
|
||||
await this._filesService.loadAll(files[0].dossierId).toPromise();
|
||||
await firstValueFrom(this._filesService.loadAll(files[0].dossierId));
|
||||
}
|
||||
|
||||
private async _hardDelete(files: FileListItem[]) {
|
||||
const fileIds = files.map(f => f.fileId);
|
||||
await this._fileManagementService.hardDelete(this.dossier.id, fileIds).toPromise();
|
||||
await firstValueFrom(this._fileManagementService.hardDelete(this.dossier.id, fileIds));
|
||||
this._removeFromList(fileIds);
|
||||
}
|
||||
|
||||
|
||||
@ -7,7 +7,8 @@ import { DictionaryService } from '@shared/services/dictionary.service';
|
||||
import { CircleButtonTypes, LoadingService, Toaster } from '@iqser/common-ui';
|
||||
import { DossiersService } from '@services/entity-services/dossiers.service';
|
||||
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
|
||||
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
|
||||
import { FormBuilder, FormGroup } from '@angular/forms';
|
||||
import { firstValueFrom } from 'rxjs';
|
||||
|
||||
@Component({
|
||||
selector: 'redaction-edit-dossier-dictionary',
|
||||
@ -67,9 +68,9 @@ export class EditDossierDictionaryComponent implements EditDossierSectionInterfa
|
||||
this._loadingService.start();
|
||||
// TODO: Setting the type manually shouldn't be necessary, but for now it fails with status code 500...
|
||||
const dictionary: IDictionary = { ...this.dossierDictionary, type: 'dossier_redaction', label };
|
||||
await this._dictionaryService
|
||||
.updateDictionary(dictionary, this.dossier.dossierTemplateId, 'dossier_redaction', this.dossier.id)
|
||||
.toPromise();
|
||||
await firstValueFrom(
|
||||
this._dictionaryService.updateDictionary(dictionary, this.dossier.dossierTemplateId, 'dossier_redaction', this.dossier.id),
|
||||
);
|
||||
await this._updateDossierDictionary();
|
||||
this._toaster.success(_('edit-dossier-dialog.dictionary.display-name.success'));
|
||||
} catch (error) {
|
||||
@ -85,20 +86,20 @@ export class EditDossierDictionaryComponent implements EditDossierSectionInterfa
|
||||
type: 'dossier_redaction',
|
||||
addToDictionaryAction: this.form.get('addToDictionaryAction').value,
|
||||
};
|
||||
await this._dictionaryService
|
||||
.updateDictionary(dictionary, this.dossier.dossierTemplateId, 'dossier_redaction', this.dossier.id)
|
||||
.toPromise();
|
||||
await firstValueFrom(
|
||||
this._dictionaryService.updateDictionary(dictionary, this.dossier.dossierTemplateId, 'dossier_redaction', this.dossier.id),
|
||||
);
|
||||
|
||||
await this._dictionaryService
|
||||
.saveEntries(
|
||||
await firstValueFrom(
|
||||
this._dictionaryService.saveEntries(
|
||||
this._dictionaryManager.editor.currentEntries,
|
||||
this._dictionaryManager.initialEntries,
|
||||
this.dossier.dossierTemplateId,
|
||||
'dossier_redaction',
|
||||
this.dossier.id,
|
||||
false,
|
||||
)
|
||||
.toPromise();
|
||||
),
|
||||
);
|
||||
|
||||
await this._updateDossierDictionary();
|
||||
return { success: true };
|
||||
@ -127,6 +128,8 @@ export class EditDossierDictionaryComponent implements EditDossierSectionInterfa
|
||||
|
||||
private async _updateDossierDictionary() {
|
||||
const { dossierId, dossierTemplateId } = this.dossier;
|
||||
this.dossierDictionary = await this._dictionaryService.getForType(dossierTemplateId, 'dossier_redaction', dossierId).toPromise();
|
||||
this.dossierDictionary = await firstValueFrom(
|
||||
this._dictionaryService.getForType(dossierTemplateId, 'dossier_redaction', dossierId),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -6,6 +6,7 @@ import { downloadTypesTranslations } from '../../../../../translations/download-
|
||||
import { DossiersService } from '@services/entity-services/dossiers.service';
|
||||
import { ReportTemplateService } from '@services/report-template.service';
|
||||
import { PermissionsService } from '@services/permissions.service';
|
||||
import { firstValueFrom } from 'rxjs';
|
||||
|
||||
@Component({
|
||||
selector: 'redaction-edit-dossier-download-package',
|
||||
@ -70,7 +71,7 @@ export class EditDossierDownloadPackageComponent implements OnInit, EditDossierS
|
||||
|
||||
async ngOnInit() {
|
||||
this.availableReportTypes =
|
||||
(await this._reportTemplateController.getAvailableReportTemplates(this.dossier.dossierTemplateId).toPromise()) || [];
|
||||
(await firstValueFrom(this._reportTemplateController.getAvailableReportTemplates(this.dossier.dossierTemplateId))) || [];
|
||||
|
||||
this.form = this._getForm();
|
||||
if (!this._permissionsService.canEditDossier()) {
|
||||
@ -85,7 +86,7 @@ export class EditDossierDownloadPackageComponent implements OnInit, EditDossierS
|
||||
reportTemplateIds: this.form.get('reportTemplateIds').value,
|
||||
};
|
||||
try {
|
||||
await this._dossiersService.createOrUpdate(dossier).toPromise();
|
||||
await firstValueFrom(this._dossiersService.createOrUpdate(dossier));
|
||||
return { success: true };
|
||||
} catch (error) {
|
||||
return { success: false };
|
||||
|
||||
@ -5,7 +5,7 @@ import { DossiersService } from '@services/entity-services/dossiers.service';
|
||||
import { Dossier, IDossierRequest } from '@red/domain';
|
||||
import { AutoUnsubscribe } from '@iqser/common-ui';
|
||||
import { EditDossierSaveResult, EditDossierSectionInterface } from '../edit-dossier-section.interface';
|
||||
import { BehaviorSubject } from 'rxjs';
|
||||
import { BehaviorSubject, firstValueFrom } from 'rxjs';
|
||||
|
||||
@Component({
|
||||
selector: 'redaction-edit-dossier-team',
|
||||
@ -77,7 +77,7 @@ export class EditDossierTeamComponent extends AutoUnsubscribe implements EditDos
|
||||
} as IDossierRequest;
|
||||
|
||||
try {
|
||||
await this._dossiersService.createOrUpdate(dossier).toPromise();
|
||||
await firstValueFrom(this._dossiersService.createOrUpdate(dossier));
|
||||
return { success: true };
|
||||
} catch (error) {
|
||||
return { success: false };
|
||||
|
||||
@ -13,6 +13,7 @@ import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
|
||||
import { DossiersService } from '@services/entity-services/dossiers.service';
|
||||
import { DossierTemplatesService } from '@services/entity-services/dossier-templates.service';
|
||||
import { DossierStatsService } from '@services/entity-services/dossier-stats.service';
|
||||
import { firstValueFrom } from 'rxjs';
|
||||
|
||||
@Component({
|
||||
selector: 'redaction-edit-dossier-general-info',
|
||||
@ -96,7 +97,7 @@ export class EditDossierGeneralInfoComponent implements OnInit, EditDossierSecti
|
||||
dossierTemplateId: this.form.get('dossierTemplateId').value,
|
||||
} as IDossierRequest;
|
||||
try {
|
||||
await this._dossiersService.createOrUpdate(dossier).toPromise();
|
||||
await firstValueFrom(this._dossiersService.createOrUpdate(dossier));
|
||||
return { success: true };
|
||||
} catch (error) {
|
||||
return { success: false };
|
||||
|
||||
@ -9,6 +9,7 @@ import { PermissionsService } from '@services/permissions.service';
|
||||
import { DossiersService } from '@services/entity-services/dossiers.service';
|
||||
import { JustificationsService } from '@services/entity-services/justifications.service';
|
||||
import { Dossier, ILegalBasisChangeRequest } from '@red/domain';
|
||||
import { firstValueFrom } from 'rxjs';
|
||||
|
||||
export interface LegalBasisOption {
|
||||
label?: string;
|
||||
@ -47,18 +48,9 @@ export class ForceAnnotationDialogComponent extends BaseDialogComponent implemen
|
||||
return this._data.hint;
|
||||
}
|
||||
|
||||
private _getForm(): FormGroup {
|
||||
this.isDocumentAdmin = this._permissionsService.isApprover(this._data.dossier);
|
||||
|
||||
return this._formBuilder.group({
|
||||
reason: this._data.hint ? ['Forced Hint'] : [null, Validators.required],
|
||||
comment: this.isDocumentAdmin ? [null] : [null, Validators.required],
|
||||
});
|
||||
}
|
||||
|
||||
async ngOnInit() {
|
||||
super.ngOnInit();
|
||||
const data = await this._justificationsService.getForDossierTemplate(this._data.dossier.dossierTemplateId).toPromise();
|
||||
const data = await firstValueFrom(this._justificationsService.getForDossierTemplate(this._data.dossier.dossierTemplateId));
|
||||
|
||||
this.legalOptions = data.map(lbm => ({
|
||||
legalBasis: lbm.reason,
|
||||
@ -73,6 +65,15 @@ export class ForceAnnotationDialogComponent extends BaseDialogComponent implemen
|
||||
this._dialogRef.close(this._createForceRedactionRequest());
|
||||
}
|
||||
|
||||
private _getForm(): FormGroup {
|
||||
this.isDocumentAdmin = this._permissionsService.isApprover(this._data.dossier);
|
||||
|
||||
return this._formBuilder.group({
|
||||
reason: this._data.hint ? ['Forced Hint'] : [null, Validators.required],
|
||||
comment: this.isDocumentAdmin ? [null] : [null, Validators.required],
|
||||
});
|
||||
}
|
||||
|
||||
private _createForceRedactionRequest(): ILegalBasisChangeRequest {
|
||||
const request: ILegalBasisChangeRequest = {};
|
||||
|
||||
|
||||
@ -11,6 +11,7 @@ import { Dictionary, Dossier, File, IAddRedactionRequest } from '@red/domain';
|
||||
import { DossiersService } from '@services/entity-services/dossiers.service';
|
||||
import { BaseDialogComponent } from '@iqser/common-ui';
|
||||
import { DictionaryService } from '@shared/services/dictionary.service';
|
||||
import { firstValueFrom } from 'rxjs';
|
||||
|
||||
export interface LegalBasisOption {
|
||||
label?: string;
|
||||
@ -69,36 +70,15 @@ export class ManualAnnotationDialogComponent extends BaseDialogComponent impleme
|
||||
return null;
|
||||
}
|
||||
|
||||
private async _getPossibleDictionaries(): Promise<Dictionary[]> {
|
||||
const possibleDictionaries: Dictionary[] = [];
|
||||
const dossier = this._dossier;
|
||||
|
||||
const dossierDictionary = await this._dictionaryService
|
||||
.getForType(dossier.dossierTemplateId, 'dossier_redaction', dossier.dossierId)
|
||||
.toPromise();
|
||||
|
||||
for (const key of Object.keys(this._appStateService.dictionaryData[dossier.dossierTemplateId])) {
|
||||
const dictionaryData = this._appStateService.getDictionary(key, dossier.dossierTemplateId);
|
||||
if (!dictionaryData.virtual && dictionaryData.addToDictionaryAction) {
|
||||
possibleDictionaries.push(dictionaryData);
|
||||
}
|
||||
}
|
||||
|
||||
if (dossierDictionary.addToDictionaryAction) {
|
||||
// TODO fix this in the backend
|
||||
possibleDictionaries.push(new Dictionary({ ...dossierDictionary, type: 'dossier_redaction' }));
|
||||
}
|
||||
|
||||
possibleDictionaries.sort((a, b) => a.label.localeCompare(b.label));
|
||||
|
||||
return possibleDictionaries;
|
||||
get disabled() {
|
||||
return this.form.invalid;
|
||||
}
|
||||
|
||||
async ngOnInit() {
|
||||
super.ngOnInit();
|
||||
this.possibleDictionaries = await this._getPossibleDictionaries();
|
||||
|
||||
const data = await this._justificationsService.getForDossierTemplate(this._dossier.dossierTemplateId).toPromise();
|
||||
const data = await firstValueFrom(this._justificationsService.getForDossierTemplate(this._dossier.dossierTemplateId));
|
||||
this.legalOptions = data.map(lbm => ({
|
||||
legalBasis: lbm.reason,
|
||||
description: lbm.description,
|
||||
@ -124,6 +104,31 @@ export class ManualAnnotationDialogComponent extends BaseDialogComponent impleme
|
||||
);
|
||||
}
|
||||
|
||||
private async _getPossibleDictionaries(): Promise<Dictionary[]> {
|
||||
const possibleDictionaries: Dictionary[] = [];
|
||||
const dossier = this._dossier;
|
||||
|
||||
const dossierDictionary = await firstValueFrom(
|
||||
this._dictionaryService.getForType(dossier.dossierTemplateId, 'dossier_redaction', dossier.dossierId),
|
||||
);
|
||||
|
||||
for (const key of Object.keys(this._appStateService.dictionaryData[dossier.dossierTemplateId])) {
|
||||
const dictionaryData = this._appStateService.getDictionary(key, dossier.dossierTemplateId);
|
||||
if (!dictionaryData.virtual && dictionaryData.addToDictionaryAction) {
|
||||
possibleDictionaries.push(dictionaryData);
|
||||
}
|
||||
}
|
||||
|
||||
if (dossierDictionary.addToDictionaryAction) {
|
||||
// TODO fix this in the backend
|
||||
possibleDictionaries.push(new Dictionary({ ...dossierDictionary, type: 'dossier_redaction' }));
|
||||
}
|
||||
|
||||
possibleDictionaries.sort((a, b) => a.label.localeCompare(b.label));
|
||||
|
||||
return possibleDictionaries;
|
||||
}
|
||||
|
||||
private _getForm(): FormGroup {
|
||||
return this._formBuilder.group({
|
||||
section: [null],
|
||||
@ -155,8 +160,4 @@ export class ManualAnnotationDialogComponent extends BaseDialogComponent impleme
|
||||
addRedactionRequest.section = this.form.get('section').value;
|
||||
addRedactionRequest.value = addRedactionRequest.rectangle ? this.form.get('classification').value : addRedactionRequest.value;
|
||||
}
|
||||
|
||||
get disabled() {
|
||||
return this.form.invalid;
|
||||
}
|
||||
}
|
||||
|
||||
@ -3,7 +3,7 @@ import { Dossier, DossierAttributeWithValue, DossierStats } from '@red/domain';
|
||||
import { DossiersDialogService } from '../../../../services/dossiers-dialog.service';
|
||||
import { DossierTemplatesService } from '@services/entity-services/dossier-templates.service';
|
||||
import { FilesService } from '@services/entity-services/files.service';
|
||||
import { Observable } from 'rxjs';
|
||||
import { firstValueFrom, Observable } from 'rxjs';
|
||||
import { map, switchMap } from 'rxjs/operators';
|
||||
import { DossierStatsService } from '@services/entity-services/dossier-stats.service';
|
||||
import { FilesMapService } from '@services/entity-services/files-map.service';
|
||||
@ -43,7 +43,7 @@ export class DossierDetailsStatsComponent implements OnInit {
|
||||
openEditDossierDialog(section: string): void {
|
||||
const data = { dossierId: this.dossier.dossierId, section };
|
||||
this._dialogService.openDialog('editDossier', null, data, async () => {
|
||||
await this._filesService.loadAll(this.dossier.dossierId).toPromise();
|
||||
await firstValueFrom(this._filesService.loadAll(this.dossier.dossierId));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@ -9,7 +9,7 @@ import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
|
||||
import { Dossier, DossierAttributeWithValue, DossierStats, IDossierRequest, StatusSorter, User } from '@red/domain';
|
||||
import { DossiersService } from '@services/entity-services/dossiers.service';
|
||||
import { ActivatedRoute } from '@angular/router';
|
||||
import { Observable } from 'rxjs';
|
||||
import { firstValueFrom, Observable } from 'rxjs';
|
||||
import { DossierStatsService } from '@services/entity-services/dossier-stats.service';
|
||||
import { pluck, switchMap } from 'rxjs/operators';
|
||||
import { DossiersDialogService } from '../../../../services/dossiers-dialog.service';
|
||||
@ -73,7 +73,7 @@ export class DossierDetailsComponent {
|
||||
async assignOwner(user: User | string, dossier: Dossier) {
|
||||
const owner = typeof user === 'string' ? this._userService.find(user) : user;
|
||||
const dossierRequest: IDossierRequest = { ...dossier, ownerId: owner.id };
|
||||
await this.dossiersService.createOrUpdate(dossierRequest).toPromise();
|
||||
await firstValueFrom(this.dossiersService.createOrUpdate(dossierRequest));
|
||||
|
||||
const ownerName = this._userService.getNameForId(owner.id);
|
||||
const dossierName = dossier.dossierName;
|
||||
|
||||
@ -19,6 +19,7 @@ import { map, take } from 'rxjs/operators';
|
||||
import { saveAsCSV } from '@utils/csv-utils';
|
||||
import { UserService } from '@services/user.service';
|
||||
import { ConfigService } from '../../config.service';
|
||||
import { firstValueFrom } from 'rxjs';
|
||||
|
||||
@Component({
|
||||
selector: 'redaction-screen-header',
|
||||
@ -53,7 +54,7 @@ export class ScreenHeaderComponent implements OnInit {
|
||||
async reanalyseDossier() {
|
||||
this._loadingService.start();
|
||||
try {
|
||||
await this._reanalysisService.reanalyzeDossier(this.dossier.dossierId, true).toPromise();
|
||||
await firstValueFrom(this._reanalysisService.reanalyzeDossier(this.dossier.dossierId, true));
|
||||
this._toaster.success(_('dossier-overview.reanalyse-dossier.success'));
|
||||
} catch (e) {
|
||||
this._toaster.error(_('dossier-overview.reanalyse-dossier.error'));
|
||||
|
||||
@ -8,6 +8,7 @@ import { FileAssignService } from '../../../shared/services/file-assign.service'
|
||||
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
|
||||
import { ReanalysisService } from '../../../../../services/reanalysis.service';
|
||||
import { FileManagementService } from '@services/entity-services/file-management.service';
|
||||
import { firstValueFrom } from 'rxjs';
|
||||
|
||||
@Injectable()
|
||||
export class BulkActionsService {
|
||||
@ -28,13 +29,13 @@ export class BulkActionsService {
|
||||
this._assignFiles(files, 'approver', true);
|
||||
} else {
|
||||
this._loadingService.start();
|
||||
await this._filesService
|
||||
.setUnderApprovalFor(
|
||||
await firstValueFrom(
|
||||
this._filesService.setUnderApprovalFor(
|
||||
files.map(f => f.id),
|
||||
dossier.id,
|
||||
dossier.approverIds[0],
|
||||
)
|
||||
.toPromise();
|
||||
),
|
||||
);
|
||||
this._loadingService.stop();
|
||||
}
|
||||
}
|
||||
@ -45,12 +46,12 @@ export class BulkActionsService {
|
||||
|
||||
async ocr(files: File[]) {
|
||||
this._loadingService.start();
|
||||
await this._reanalysisService
|
||||
.ocrFiles(
|
||||
await firstValueFrom(
|
||||
this._reanalysisService.ocrFiles(
|
||||
files.map(f => f.fileId),
|
||||
files[0].dossierId,
|
||||
)
|
||||
.toPromise();
|
||||
),
|
||||
);
|
||||
this._loadingService.stop();
|
||||
}
|
||||
|
||||
@ -64,12 +65,12 @@ export class BulkActionsService {
|
||||
}),
|
||||
async () => {
|
||||
this._loadingService.start();
|
||||
await this._fileManagementService
|
||||
.delete(
|
||||
await firstValueFrom(
|
||||
this._fileManagementService.delete(
|
||||
files.map(item => item.fileId),
|
||||
files[0].dossierId,
|
||||
)
|
||||
.toPromise();
|
||||
),
|
||||
);
|
||||
this._loadingService.stop();
|
||||
},
|
||||
);
|
||||
@ -78,18 +79,18 @@ export class BulkActionsService {
|
||||
async reanalyse(files: File[]) {
|
||||
this._loadingService.start();
|
||||
const fileIds = files.filter(file => file.analysisRequired).map(file => file.fileId);
|
||||
await this._reanalysisService.reanalyzeFilesForDossier(fileIds, files[0].dossierId).toPromise();
|
||||
await firstValueFrom(this._reanalysisService.reanalyzeFilesForDossier(fileIds, files[0].dossierId));
|
||||
this._loadingService.stop();
|
||||
}
|
||||
|
||||
async backToUnderReview(files: File[]): Promise<void> {
|
||||
this._loadingService.start();
|
||||
await this._filesService
|
||||
.setUnderReviewFor(
|
||||
await firstValueFrom(
|
||||
this._filesService.setUnderReviewFor(
|
||||
files.map(f => f.id),
|
||||
files[0].dossierId,
|
||||
)
|
||||
.toPromise();
|
||||
),
|
||||
);
|
||||
this._loadingService.stop();
|
||||
}
|
||||
|
||||
@ -105,23 +106,23 @@ export class BulkActionsService {
|
||||
}),
|
||||
async () => {
|
||||
this._loadingService.start();
|
||||
await this._filesService
|
||||
.setApprovedFor(
|
||||
await firstValueFrom(
|
||||
this._filesService.setApprovedFor(
|
||||
files.map(f => f.id),
|
||||
files[0].dossierId,
|
||||
)
|
||||
.toPromise();
|
||||
),
|
||||
);
|
||||
this._loadingService.stop();
|
||||
},
|
||||
);
|
||||
} else {
|
||||
this._loadingService.start();
|
||||
await this._filesService
|
||||
.setApprovedFor(
|
||||
await firstValueFrom(
|
||||
this._filesService.setApprovedFor(
|
||||
files.map(f => f.id),
|
||||
files[0].dossierId,
|
||||
)
|
||||
.toPromise();
|
||||
),
|
||||
);
|
||||
this._loadingService.stop();
|
||||
}
|
||||
}
|
||||
|
||||
@ -9,6 +9,7 @@ import { UserPreferenceService } from '@services/user-preference.service';
|
||||
import { FilesMapService } from '@services/entity-services/files-map.service';
|
||||
import { ReanalysisService } from '@services/reanalysis.service';
|
||||
import { DossiersService } from '@services/entity-services/dossiers.service';
|
||||
import { firstValueFrom } from 'rxjs';
|
||||
|
||||
@Component({
|
||||
selector: 'redaction-dossiers-listing-actions',
|
||||
@ -60,6 +61,6 @@ export class DossiersListingActionsComponent implements OnChanges {
|
||||
|
||||
async reanalyseDossier($event: MouseEvent, id: string): Promise<void> {
|
||||
$event.stopPropagation();
|
||||
await this._reanalysisService.reanalyzeDossier(id).toPromise();
|
||||
await firstValueFrom(this._reanalysisService.reanalyzeDossier(id));
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,14 +2,12 @@ import {
|
||||
ChangeDetectionStrategy,
|
||||
ChangeDetectorRef,
|
||||
Component,
|
||||
EventEmitter,
|
||||
HostBinding,
|
||||
Input,
|
||||
OnChanges,
|
||||
OnDestroy,
|
||||
OnInit,
|
||||
Optional,
|
||||
Output,
|
||||
ViewChild,
|
||||
} from '@angular/core';
|
||||
import { PermissionsService } from '@services/permissions.service';
|
||||
@ -38,6 +36,7 @@ import { ExcludedPagesService } from '../../../screens/file-preview-screen/servi
|
||||
import { tap } from 'rxjs/operators';
|
||||
import { DocumentInfoService } from '../../../screens/file-preview-screen/services/document-info.service';
|
||||
import { ExpandableFileActionsComponent } from '@shared/components/expandable-file-actions/expandable-file-actions.component';
|
||||
import { firstValueFrom } from 'rxjs';
|
||||
|
||||
@Component({
|
||||
selector: 'redaction-file-actions [file] [type]',
|
||||
@ -273,7 +272,7 @@ export class FileActionsComponent extends AutoUnsubscribe implements OnDestroy,
|
||||
this._loadingService.start();
|
||||
try {
|
||||
const dossier = this._dossiersService.find(this.file.dossierId);
|
||||
await this._fileManagementService.delete([this.file.fileId], this.file.dossierId).toPromise();
|
||||
await firstValueFrom(this._fileManagementService.delete([this.file.fileId], this.file.dossierId));
|
||||
await this._router.navigate([dossier.routerLink]);
|
||||
} catch (error) {
|
||||
this._toaster.error(_('error.http.generic'), { params: error });
|
||||
@ -300,7 +299,7 @@ export class FileActionsComponent extends AutoUnsubscribe implements OnDestroy,
|
||||
if ($event) {
|
||||
$event.stopPropagation();
|
||||
}
|
||||
await this._reanalysisService.reanalyzeFilesForDossier([this.file.fileId], this.file.dossierId, true).toPromise();
|
||||
await firstValueFrom(this._reanalysisService.reanalyzeFilesForDossier([this.file.fileId], this.file.dossierId, true));
|
||||
}
|
||||
|
||||
private async _setFileUnderApproval($event: MouseEvent) {
|
||||
@ -311,7 +310,7 @@ export class FileActionsComponent extends AutoUnsubscribe implements OnDestroy,
|
||||
private async _ocrFile($event: MouseEvent) {
|
||||
$event.stopPropagation();
|
||||
this._loadingService.start();
|
||||
await this._reanalysisService.ocrFiles([this.file.fileId], this.file.dossierId).toPromise();
|
||||
await firstValueFrom(this._reanalysisService.ocrFiles([this.file.fileId], this.file.dossierId));
|
||||
this._loadingService.stop();
|
||||
}
|
||||
|
||||
@ -321,7 +320,7 @@ export class FileActionsComponent extends AutoUnsubscribe implements OnDestroy,
|
||||
|
||||
private async _toggleAnalysis() {
|
||||
this._loadingService.start();
|
||||
await this._reanalysisService.toggleAnalysis(this.file.dossierId, this.file.fileId, !this.file.excluded).toPromise();
|
||||
await firstValueFrom(this._reanalysisService.toggleAnalysis(this.file.dossierId, this.file.fileId, !this.file.excluded));
|
||||
this._loadingService.stop();
|
||||
}
|
||||
|
||||
@ -364,7 +363,7 @@ export class FileActionsComponent extends AutoUnsubscribe implements OnDestroy,
|
||||
|
||||
private async _setFileApproved() {
|
||||
this._loadingService.start();
|
||||
await this._filesService.setApprovedFor([this.file.id], this.file.dossierId).toPromise();
|
||||
await firstValueFrom(this._filesService.setApprovedFor([this.file.id], this.file.dossierId));
|
||||
this._loadingService.stop();
|
||||
}
|
||||
}
|
||||
|
||||
@ -6,7 +6,7 @@ import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
|
||||
import { FilesService } from '@services/entity-services/files.service';
|
||||
import { ConfirmationDialogInput, LoadingService, Toaster } from '@iqser/common-ui';
|
||||
import { DossiersService } from '@services/entity-services/dossiers.service';
|
||||
import { Observable } from 'rxjs';
|
||||
import { firstValueFrom, Observable } from 'rxjs';
|
||||
import { tap } from 'rxjs/operators';
|
||||
|
||||
@Injectable()
|
||||
@ -29,14 +29,12 @@ export class FileAssignService {
|
||||
question: _('confirmation-dialog.assign-file-to-me.question'),
|
||||
});
|
||||
this._dialogService.openDialog('confirm', null, data, () => {
|
||||
this._assignReviewerToCurrentUser(files)
|
||||
.toPromise()
|
||||
firstValueFrom(this._assignReviewerToCurrentUser(files))
|
||||
.then(() => resolve())
|
||||
.catch(() => reject());
|
||||
});
|
||||
} else {
|
||||
this._assignReviewerToCurrentUser(files)
|
||||
.toPromise()
|
||||
firstValueFrom(this._assignReviewerToCurrentUser(files))
|
||||
.then(() => resolve())
|
||||
.catch(() => reject());
|
||||
}
|
||||
@ -83,28 +81,28 @@ export class FileAssignService {
|
||||
this._loadingService.start();
|
||||
try {
|
||||
if (!userId) {
|
||||
await this._filesService
|
||||
.setUnassigned(
|
||||
await firstValueFrom(
|
||||
this._filesService.setUnassigned(
|
||||
files.map(f => f.fileId),
|
||||
files[0].dossierId,
|
||||
)
|
||||
.toPromise();
|
||||
),
|
||||
);
|
||||
} else if (mode === 'reviewer') {
|
||||
await this._filesService
|
||||
.setReviewerFor(
|
||||
await firstValueFrom(
|
||||
this._filesService.setReviewerFor(
|
||||
files.map(f => f.fileId),
|
||||
files[0].dossierId,
|
||||
userId,
|
||||
)
|
||||
.toPromise();
|
||||
),
|
||||
);
|
||||
} else {
|
||||
await this._filesService
|
||||
.setUnderApprovalFor(
|
||||
await firstValueFrom(
|
||||
this._filesService.setUnderApprovalFor(
|
||||
files.map(f => f.fileId),
|
||||
files[0].dossierId,
|
||||
userId,
|
||||
)
|
||||
.toPromise();
|
||||
),
|
||||
);
|
||||
}
|
||||
} catch (error) {
|
||||
this._toaster.error(_('error.http.generic'), { params: error });
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user