Merge pull request #7699 from aignatov-bio/ai-sci-10872-fix-mapping-behavior

Fix mapping behavior [SCI-10872]
This commit is contained in:
aignatov-bio 2024-07-11 15:01:28 +02:00 committed by GitHub
commit bb62ea3261
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
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 item = this.selectedItems.find((i) => i.index === index);
const usedBeforeItem = this.selectedItems.find((i) => i.key === key && 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.key = null;
usedBeforeItem.value = null; usedBeforeItem.value = null;
} }
@ -188,24 +188,27 @@ export default {
this.$emit( this.$emit(
'generatePreview', 'generatePreview',
this.selectedItems this.selectedItems.filter((item) => item.key !== 'do_not_import')
); );
return true; return true;
} }
}, },
computed: { computed: {
computedDropdownOptions() { computedDropdownOptions() {
return this.availableFields let options = this.availableFields.map((el) => [String(el.key), `${String(el.value)} (${el.typeName})`]);
.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); // options = [['new', this.i18n.t('repositories.import_records.steps.step2.table.tableRow.importAsNewColumn')]].concat(options);
return options;
}, },
computedImportedIgnoredInfo() { 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; const ignoredSum = this.selectedItems.length - importedSum;
return { importedSum, ignoredSum }; return { importedSum, ignoredSum };
}, },
canSubmit() { 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() { created() {

View file

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