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" type="text"
/> />
</div> </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"> <div class="iqser-input-group required w-150">
<label translate="add-edit-component-mapping.form.encoding-type"></label> <label translate="add-edit-component-mapping.form.encoding-type"></label>

View File

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

View File

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

View File

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

View File

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