mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-03-04 19:53:19 +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"
|
||||
@selection:changed="handleChange"
|
||||
:availableFields="this.availableFields"
|
||||
:autoMapping="this.autoMapping"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -153,7 +154,7 @@ export default {
|
|||
},
|
||||
data() {
|
||||
return {
|
||||
autoMapping: false,
|
||||
autoMapping: true,
|
||||
updateWithEmptyCells: false,
|
||||
onlyAddNewItems: false,
|
||||
columnLabels: {
|
||||
|
|
|
@ -23,8 +23,11 @@
|
|||
@isOpen="handleIsOpen"
|
||||
:clearable="true"
|
||||
: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"
|
||||
:value="this.selectedColumnType?.key"
|
||||
></SelectDropdown>
|
||||
<template v-if="selectedColumnType?.key == 'new'">
|
||||
<SelectDropdown
|
||||
|
@ -60,7 +63,9 @@
|
|||
<!-- <i v-else-if=""></i> -->
|
||||
|
||||
<!-- 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 -->
|
||||
<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: {
|
||||
type: Object,
|
||||
required: true
|
||||
},
|
||||
autoMapping: {
|
||||
type: Boolean,
|
||||
required: true
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
|
@ -125,7 +134,31 @@ export default {
|
|||
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: {
|
||||
autoMap() {
|
||||
Object.entries(this.stepProps.availableFields).forEach(([key, value]) => {
|
||||
if (this.item === value) {
|
||||
this.changeSelected(key);
|
||||
}
|
||||
});
|
||||
},
|
||||
clearAutoMap() {
|
||||
this.changeSelected(null);
|
||||
},
|
||||
changeSelected(e) {
|
||||
let value;
|
||||
if (e === 'new') {
|
||||
|
@ -143,6 +176,11 @@ export default {
|
|||
tableRows.style.overflow = 'hidden';
|
||||
} else tableRows.style.overflow = 'auto';
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
if (this.autoMapping) {
|
||||
this.autoMap();
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
|
|
@ -2240,7 +2240,11 @@ en:
|
|||
RepositoryStockValue: 'Stock'
|
||||
table:
|
||||
tableRow:
|
||||
placeholders:
|
||||
matchNotFound: 'Match not found'
|
||||
doNotImport: 'Do not import'
|
||||
defaultColumnTitle: 'Default column. Mapped as identifier.'
|
||||
matchNotFoundColumnTitle: 'Match not found.'
|
||||
userDefinedColumnTitle: 'Column name does not match. Column will be imported as '
|
||||
importedColumnTitle: 'Column will be imported.'
|
||||
doNotImportColumnTitle: 'Column will not import.'
|
||||
|
|
Loading…
Reference in a new issue