feature/RED-10260: add quoteChar to componentMapping

This commit is contained in:
Kilian Schüttler 2024-10-24 09:59:21 +02:00 committed by Dan Percic
parent 7557025b01
commit 61e9df1844
7 changed files with 34 additions and 12 deletions

View File

@ -42,6 +42,15 @@
type="text"
/>
</div>
<div class="iqser-input-group required w-150">
<label translate="add-edit-component-mapping.form.quote-char"></label>
<input
[placeholder]="'add-edit-component-mapping.form.quote-char-placeholder' | translate"
formControlName="quoteChar"
name="quoteChar"
type="text"
/>
</div>
<div class="iqser-input-group required w-150">
<label translate="add-edit-component-mapping.form.encoding-type"></label>

View File

@ -17,12 +17,14 @@ interface DialogData {
dossierTemplateId: string;
mapping: IComponentMapping;
}
interface DialogResult {
id: string;
name: string;
file: Blob;
encoding: string;
delimiter: string;
quoteChar: string;
fileName?: string;
}
@ -72,14 +74,14 @@ export class AddEditComponentMappingDialogComponent
const file = new Blob([fileContent.body as Blob], { type: 'text/csv' });
this.form.get('file').setValue(file);
this.initialFormValue = this.form.getRawValue();
this.#disableEncodingAndDelimiter();
this.#disableEncodingAndQuoteCharAndDelimiter();
}
}
changeFile(file: File) {
this.form.get('file').setValue(file);
this.form.get('fileName').setValue(file?.name);
this.#enableEncodingAndDelimiter();
this.#enableEncodingAndQuoteCharAndDelimiter();
}
save() {
@ -93,16 +95,19 @@ export class AddEditComponentMappingDialogComponent
fileName: [this.data?.mapping?.fileName, Validators.required],
encoding: this.encodingTypeOptions.find(e => e === this.data?.mapping?.encoding) ?? this.encodingTypeOptions[0],
delimiter: [this.data?.mapping?.delimiter ?? ',', Validators.required],
quoteChar: [this.data?.mapping?.quoteChar ?? '"', Validators.required],
});
}
#disableEncodingAndDelimiter() {
#disableEncodingAndQuoteCharAndDelimiter() {
this.form.get('encoding').disable();
this.form.get('delimiter').disable();
this.form.get('quoteChar').disable();
}
#enableEncodingAndDelimiter() {
#enableEncodingAndQuoteCharAndDelimiter() {
this.form.get('encoding').enable();
this.form.get('delimiter').enable();
this.form.get('quoteChar').enable();
}
}

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, fileName } = result;
const newMapping = { id, name, encoding, delimiter, fileName };
const { id, name, encoding, delimiter, fileName, quoteChar } = result;
const newMapping = { id, name, encoding, delimiter, fileName, quoteChar };
await firstValueFrom(
this._componentMappingService.createUpdateComponentMapping(this.#dossierTemplateId, newMapping, result.file),
);

View File

@ -28,6 +28,7 @@ export class ComponentMappingsService extends EntitiesService<IComponentMapping,
{ key: 'name', value: componentMapping.name },
{ key: 'encoding', value: componentMapping.encoding },
{ key: 'delimiter', value: componentMapping.delimiter },
{ key: 'quoteChar', value: componentMapping.quoteChar },
];
if (componentMapping.id) {

View File

@ -102,9 +102,11 @@
},
"disabled-file-options": "",
"form": {
"delimiter": "",
"delimiter-placeholder": "",
"encoding-type": "",
"quote-char": "Zitatzeichen",
"quote-char-placeholder": "\"",
"delimiter": "Trennzeichen",
"delimiter-placeholder": ",",
"encoding-type": "Codierung",
"file": "Mapping-Datei",
"name": "Mapping-Name",
"name-placeholder": "Mapping-Name",

View File

@ -102,9 +102,11 @@
},
"disabled-file-options": "",
"form": {
"delimiter": "",
"delimiter-placeholder": "",
"encoding-type": "",
"quote-char": "Quotation marker",
"quote-char-placeholder": "\"",
"delimiter": "Delimiter",
"delimiter-placeholder": ",",
"encoding-type": "Encoding",
"file": "Mapping file",
"name": "Mapping name",
"name-placeholder": "Mapping name",

View File

@ -10,6 +10,7 @@ export interface IComponentMapping extends IListable {
numberOfLines: number;
encoding: string;
delimiter: string;
quoteChar: string;
}
export class ComponentMapping implements IComponentMapping, IListable {
@ -22,6 +23,7 @@ export class ComponentMapping implements IComponentMapping, IListable {
readonly numberOfLines: number;
readonly encoding: string;
readonly delimiter: string;
readonly quoteChar: string;
constructor(componentMapping: IComponentMapping) {
this.id = componentMapping.id;
@ -33,6 +35,7 @@ export class ComponentMapping implements IComponentMapping, IListable {
this.numberOfLines = componentMapping.numberOfLines;
this.encoding = componentMapping.encoding;
this.delimiter = componentMapping.delimiter;
this.quoteChar = componentMapping.quoteChar;
}
get searchKey(): string {