diff --git a/apps/red-ui/src/app/modules/shared-dossiers/dialogs/edit-dossier-dialog/attributes/edit-dossier-attributes.component.ts b/apps/red-ui/src/app/modules/shared-dossiers/dialogs/edit-dossier-dialog/attributes/edit-dossier-attributes.component.ts index f561a07e0..b03686c6b 100644 --- a/apps/red-ui/src/app/modules/shared-dossiers/dialogs/edit-dossier-dialog/attributes/edit-dossier-attributes.component.ts +++ b/apps/red-ui/src/app/modules/shared-dossiers/dialogs/edit-dossier-dialog/attributes/edit-dossier-attributes.component.ts @@ -39,7 +39,7 @@ export class EditDossierAttributesComponent implements EditDossierSectionInterfa if (!dayjs(attr.value).isSame(dayjs(this.currentAttrValue(attr)), 'day')) { return true; } - } else if (this._parseAttrValue(attr.value) !== this._parseAttrValue(this.currentAttrValue(attr))) { + } else if (this.#parseAttrValue(attr.value) !== this.#parseAttrValue(this.currentAttrValue(attr))) { return true; } } @@ -57,8 +57,8 @@ export class EditDossierAttributesComponent implements EditDossierSectionInterfa async ngOnInit() { this._loadingService.start(); - await this._loadAttributes(); - this.form = this._getForm(); + await this.#loadAttributes(); + this.form = this.#getForm(); this.initialFormValue = this.form.getRawValue(); this._loadingService.stop(); } @@ -74,7 +74,7 @@ export class EditDossierAttributesComponent implements EditDossierSectionInterfa try { await firstValueFrom(this._dossierAttributesService.setAttributes(this.dossier, dossierAttributeList)); await firstValueFrom(this._dossierAttributesService.loadAll(this.dossier.dossierTemplateId)); - await this._loadAttributes(); + await this.#loadAttributes(); this.initialFormValue = this.form.getRawValue(); return { success: true }; } catch (error) { @@ -84,7 +84,7 @@ export class EditDossierAttributesComponent implements EditDossierSectionInterfa } fileInputClick(attr: DossierAttributeWithValue) { - this._getFileInputById(attr.id).nativeElement.click(); + this.#getFileInputById(attr.id).nativeElement.click(); } isSpecificType(attr: DossierAttributeWithValue, type: DossierAttributeConfigType): boolean { @@ -105,11 +105,11 @@ export class EditDossierAttributesComponent implements EditDossierSectionInterfa this.form.patchValue({ [attr.id]: result, }); - this._getFileInputById(attr.id).nativeElement.value = null; + this.#getFileInputById(attr.id).nativeElement.value = null; } revert() { - this._loadAttributes().then(() => this.form.reset(this.initialFormValue)); + this.#loadAttributes().then(() => this.form.reset(this.initialFormValue)); } currentAttrValue(attr: DossierAttributeWithValue): string { @@ -122,21 +122,21 @@ export class EditDossierAttributesComponent implements EditDossierSectionInterfa }); } - private _getFileInputById(id: string): ElementRef { - return this._fileInputs.find(el => el.nativeElement.id === id); + #getFileInputById(id: string): ElementRef { + return this._fileInputs.find(el => el.nativeElement.name === id); } - private _parseAttrValue(value: any) { + #parseAttrValue(value: any) { return [null, undefined, ''].includes(value) ? undefined : value; } - private async _loadAttributes() { + async #loadAttributes() { this.attributes = await this._dossierAttributesService.getWithValues(this.dossier); this.customAttributes = this.attributes.filter(attr => !this.isSpecificType(attr, this.dossierAttributeConfigTypes.IMAGE)); this.imageAttributes = this.attributes.filter(attr => this.isSpecificType(attr, this.dossierAttributeConfigTypes.IMAGE)); } - private _getForm(): UntypedFormGroup { + #getForm(): UntypedFormGroup { const controlsConfig = {}; for (const attribute of this.attributes) { controlsConfig[attribute.id] = [{ value: attribute.value, disabled: this.disabled }];