mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-12-11 06:35:58 +08:00
Merge pull request #7575 from lasniscinote/gl_SCI_10610
(dev) Inventory import - Automatic mapping [SCI-10610]
This commit is contained in:
commit
4471ad40dc
3 changed files with 46 additions and 3 deletions
|
|
@ -86,6 +86,7 @@
|
||||||
:stepProps="stepProps"
|
:stepProps="stepProps"
|
||||||
@selection:changed="handleChange"
|
@selection:changed="handleChange"
|
||||||
:availableFields="this.availableFields"
|
:availableFields="this.availableFields"
|
||||||
|
:autoMapping="this.autoMapping"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -153,7 +154,7 @@ export default {
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
autoMapping: false,
|
autoMapping: true,
|
||||||
updateWithEmptyCells: false,
|
updateWithEmptyCells: false,
|
||||||
onlyAddNewItems: false,
|
onlyAddNewItems: false,
|
||||||
columnLabels: {
|
columnLabels: {
|
||||||
|
|
|
||||||
|
|
@ -23,8 +23,11 @@
|
||||||
@isOpen="handleIsOpen"
|
@isOpen="handleIsOpen"
|
||||||
:clearable="true"
|
:clearable="true"
|
||||||
:size="'sm'"
|
:size="'sm'"
|
||||||
placeholder="Do not import"
|
:placeholder="computeMatchNotFound ?
|
||||||
|
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"
|
||||||
></SelectDropdown>
|
></SelectDropdown>
|
||||||
<template v-if="selectedColumnType?.key == 'new'">
|
<template v-if="selectedColumnType?.key == 'new'">
|
||||||
<SelectDropdown
|
<SelectDropdown
|
||||||
|
|
@ -60,7 +63,9 @@
|
||||||
<!-- <i v-else-if=""></i> -->
|
<!-- <i v-else-if=""></i> -->
|
||||||
|
|
||||||
<!-- match not found -->
|
<!-- match not found -->
|
||||||
<!-- <i v-else-if=""></i> -->
|
<i v-else-if="computeMatchNotFound"
|
||||||
|
class="sn-icon sn-icon-close text-sn-alert-brittlebush" :title="i18n.t('repositories.import_records.steps.step2.table.tableRow.matchNotFoundColumnTitle')">
|
||||||
|
</i>
|
||||||
|
|
||||||
<!-- do not import -->
|
<!-- do not import -->
|
||||||
<i v-else class="sn-icon sn-icon-close text-sn-sleepy-grey" :title="i18n.t('repositories.import_records.steps.step2.table.tableRow.doNotImportColumnTitle')"></i>
|
<i v-else class="sn-icon sn-icon-close text-sn-sleepy-grey" :title="i18n.t('repositories.import_records.steps.step2.table.tableRow.doNotImportColumnTitle')"></i>
|
||||||
|
|
@ -95,6 +100,10 @@ export default {
|
||||||
stepProps: {
|
stepProps: {
|
||||||
type: Object,
|
type: Object,
|
||||||
required: true
|
required: true
|
||||||
|
},
|
||||||
|
autoMapping: {
|
||||||
|
type: Boolean,
|
||||||
|
required: true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
|
|
@ -125,7 +134,31 @@ export default {
|
||||||
this.i18n.t('repositories.import_records.steps.step2.table.tableRow.systemGeneratedData.updatedOn')]
|
this.i18n.t('repositories.import_records.steps.step2.table.tableRow.systemGeneratedData.updatedOn')]
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
watch: {
|
||||||
|
autoMapping(newVal, oldVal) {
|
||||||
|
if (newVal === true) {
|
||||||
|
this.autoMap();
|
||||||
|
} else {
|
||||||
|
this.clearAutoMap();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
computeMatchNotFound() {
|
||||||
|
return this.autoMapping && ((this.selectedColumnType && !this.selectedColumnType.key) || !this.selectedColumnType);
|
||||||
|
}
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
autoMap() {
|
||||||
|
Object.entries(this.stepProps.availableFields).forEach(([key, value]) => {
|
||||||
|
if (this.item === value) {
|
||||||
|
this.changeSelected(key);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
clearAutoMap() {
|
||||||
|
this.changeSelected(null);
|
||||||
|
},
|
||||||
changeSelected(e) {
|
changeSelected(e) {
|
||||||
let value;
|
let value;
|
||||||
if (e === 'new') {
|
if (e === 'new') {
|
||||||
|
|
@ -143,6 +176,11 @@ export default {
|
||||||
tableRows.style.overflow = 'hidden';
|
tableRows.style.overflow = 'hidden';
|
||||||
} else tableRows.style.overflow = 'auto';
|
} else tableRows.style.overflow = 'auto';
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
mounted() {
|
||||||
|
if (this.autoMapping) {
|
||||||
|
this.autoMap();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
|
|
@ -2240,7 +2240,11 @@ en:
|
||||||
RepositoryStockValue: 'Stock'
|
RepositoryStockValue: 'Stock'
|
||||||
table:
|
table:
|
||||||
tableRow:
|
tableRow:
|
||||||
|
placeholders:
|
||||||
|
matchNotFound: 'Match not found'
|
||||||
|
doNotImport: 'Do not import'
|
||||||
defaultColumnTitle: 'Default column. Mapped as identifier.'
|
defaultColumnTitle: 'Default column. Mapped as identifier.'
|
||||||
|
matchNotFoundColumnTitle: 'Match not found.'
|
||||||
userDefinedColumnTitle: 'Column name does not match. Column will be imported as '
|
userDefinedColumnTitle: 'Column name does not match. Column will be imported as '
|
||||||
importedColumnTitle: 'Column will be imported.'
|
importedColumnTitle: 'Column will be imported.'
|
||||||
doNotImportColumnTitle: 'Column will not import.'
|
doNotImportColumnTitle: 'Column will not import.'
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue