Fix mapping behavior [SCI-10872]

This commit is contained in:
Anton 2024-07-11 14:49:33 +02:00
parent 99915cb43f
commit 87a1a5a3e6
2 changed files with 16 additions and 15 deletions

View file

@ -145,7 +145,7 @@ export default {
const item = this.selectedItems.find((i) => i.index === index);
const usedBeforeItem = this.selectedItems.find((i) => i.key === key && i.index !== index);
if (usedBeforeItem) {
if (usedBeforeItem && usedBeforeItem.key !== 'do_not_import') {
usedBeforeItem.key = null;
usedBeforeItem.value = null;
}
@ -188,24 +188,27 @@ export default {
this.$emit(
'generatePreview',
this.selectedItems
this.selectedItems.filter((item) => item.key !== 'do_not_import')
);
return true;
}
},
computed: {
computedDropdownOptions() {
return this.availableFields
.map((el) => [String(el.key), `${String(el.value)} (${el.typeName})`]);
let options = this.availableFields.map((el) => [String(el.key), `${String(el.value)} (${el.typeName})`]);
options = [
['do_not_import', this.i18n.t('repositories.import_records.steps.step2.table.tableRow.placeholders.doNotImport')]
].concat(options);
// options = [['new', this.i18n.t('repositories.import_records.steps.step2.table.tableRow.importAsNewColumn')]].concat(options);
return options;
},
computedImportedIgnoredInfo() {
const importedSum = this.selectedItems.filter((i) => i.key).length;
const importedSum = this.selectedItems.filter((i) => i.key && i.key !== 'do_not_import').length;
const ignoredSum = this.selectedItems.length - importedSum;
return { importedSum, ignoredSum };
},
canSubmit() {
return this.selectedItems.filter((i) => i.key).length > 0;
return this.selectedItems.filter((i) => i.key && i.key !== 'do_not_import').length > 0;
}
},
created() {

View file

@ -20,16 +20,13 @@
<SelectDropdown
:options="dropdownOptions"
@change="changeSelected"
:clearable="true"
:size="'sm'"
class="max-w-96"
:searchable="true"
:class="{
'outline-sn-alert-brittlebush outline-1 outline rounded': computeMatchNotFound
}"
:placeholder="computeMatchNotFound ?
i18n.t('repositories.import_records.steps.step2.table.tableRow.placeholders.matchNotFound') :
i18n.t('repositories.import_records.steps.step2.table.tableRow.placeholders.doNotImport')"
:placeholder="i18n.t('repositories.import_records.steps.step2.table.tableRow.placeholders.matchNotFound')"
:title="this.selectedColumnType?.value"
:value="this.selectedColumnType?.key"
></SelectDropdown>
@ -137,16 +134,16 @@ export default {
return this.autoMapping && !this.isSystemColumn(this.item) && ((this.selectedColumnType && !this.selectedColumnType.key) || !this.selectedColumnType);
},
selected() {
return !!this.value?.key;
return this.columnMapped;
},
differentMapingName() {
return this.columnMapped && this.selectedColumnType?.value !== this.item;
return this.columnMapped && this.selectedColumnType?.value !== this.item && this.value?.key !== 'do_not_import';
},
matchNotFound() {
return this.autoMapping && !this.selectedColumnType?.key;
return this.autoMapping && this.columnMapped;
},
columnMapped() {
return this.selectedColumnType?.key;
return this.selectedColumnType?.key && this.selectedColumnType?.key !== 'do_not_import';
}
},
methods: {
@ -154,6 +151,7 @@ export default {
return this.systemColumns.includes(column);
},
autoMap() {
this.changeSelected(null);
Object.entries(this.params.import_data.available_fields).forEach(([key, value]) => {
if (this.item === value) {
this.changeSelected(key);
@ -161,7 +159,7 @@ export default {
});
},
clearAutoMap() {
this.changeSelected(null);
this.changeSelected('do_not_import');
},
changeSelected(e) {
const value = this.params.import_data.available_fields[e];