Merge remote-tracking branch 'origin/master' into RED-9747

This commit is contained in:
Dan Percic 2024-07-26 16:02:19 +03:00
commit 10fa81e77c
4 changed files with 10 additions and 7 deletions

View File

@ -1,5 +1,5 @@
import { Component, OnInit } from '@angular/core';
import { CircleButtonComponent, IconButtonComponent, IconButtonTypes, IqserDialogComponent, UploadFileComponent } from '@iqser/common-ui';
import { CircleButtonComponent, IconButtonComponent, IqserDialogComponent, UploadFileComponent } from '@iqser/common-ui';
import { FileAttributeEncodingTypes, IComponentMapping } from '@red/domain';
import { FormBuilder, ReactiveFormsModule, UntypedFormGroup, Validators } from '@angular/forms';
import { TranslateModule } from '@ngx-translate/core';
@ -22,6 +22,7 @@ interface DialogResult {
file: Blob;
encoding: string;
delimiter: string;
fileName?: string;
}
@Component({
@ -63,9 +64,10 @@ export class AddEditComponentMappingDialogComponent
async ngOnInit() {
if (this.data.mapping?.fileName) {
this.activeFile = { name: this.data.mapping.fileName } as File;
const file = await firstValueFrom(
const fileContent = await firstValueFrom(
this._componentMappingService.getComponentMappingFile(this.data.dossierTemplateId, this.data.mapping.id),
);
const file = new Blob([fileContent.body as Blob], { type: 'text/csv' });
this.form.get('file').setValue(file);
this.initialFormValue = this.form.getRawValue();
}
@ -76,7 +78,8 @@ export class AddEditComponentMappingDialogComponent
}
save() {
this.dialogRef.close({ ...this.data.mapping, ...this.form.getRawValue() });
const fileName = document.getElementById('file-name-label')?.textContent;
this.dialogRef.close({ ...this.data.mapping, ...this.form.getRawValue(), fileName });
}
#getForm(): UntypedFormGroup {

View File

@ -99,8 +99,8 @@ export default class ComponentMappingsScreenComponent extends ListingComponent<C
const result = await dialog.result();
if (result) {
this._loadingService.start();
const { id, name, encoding, delimiter } = result;
const newMapping = { id, name, encoding, delimiter };
const { id, name, encoding, delimiter, fileName } = result;
const newMapping = { id, name, encoding, delimiter, fileName };
await firstValueFrom(
this._componentMappingService.createUpdateComponentMapping(this.#dossierTemplateId, newMapping, result.file),
);

View File

@ -22,7 +22,7 @@ export class ComponentMappingsService extends EntitiesService<IComponentMapping,
file: Blob,
): Observable<IComponentMapping> {
const formParams = new FormData();
formParams.append('file', file);
formParams.append('file', file, componentMapping.fileName);
const queryParams: List<QueryParam> = [
{ key: 'name', value: componentMapping.name },

@ -1 +1 @@
Subproject commit 98ac49fbc81bb9989c14a8ca06c11d98ed042c86
Subproject commit 9df87dc218ea8090159059a7bad184aaaeba8854