Browse Source

fix: correction i csv import modal

Signed-off-by: Pranav C <pranavxc@gmail.com>

#880
pull/948/head
Pranav C 3 years ago
parent
commit
546b901ab7
  1. 6
      packages/nc-gui/components/project/spreadsheet/components/exportImport.vue
  2. 9
      packages/nc-gui/components/project/spreadsheet/components/importExport/columnMappingModal.vue

6
packages/nc-gui/components/project/spreadsheet/components/exportImport.vue

@ -74,7 +74,7 @@
import FileSaver from 'file-saver'
import DropOrSelectFileModal from '~/components/import/dropOrSelectFileModal'
import ColumnMappingModal from '~/components/project/spreadsheet/components/columnMappingModal'
import ColumnMappingModal from '~/components/project/spreadsheet/components/importExport/columnMappingModal'
import CSVTemplateAdapter from '~/components/import/templateParsers/CSVTemplateAdapter'
export default {
@ -247,8 +247,8 @@ export default {
const batchData = data.slice(i, i + 500).map(row => columnMappings.reduce((res, col) => {
// todo: parse data
if (col.enabled && col.destCn && col.destCn._cn) {
res[col.destCn._cn] = row[col.sourceCn]
if (col.enabled && col.destCn) {
res[col.destCn] = row[col.sourceCn]
}
return res
}, {}))

9
packages/nc-gui/components/project/spreadsheet/components/columnMappingModal.vue → packages/nc-gui/components/project/spreadsheet/components/importExport/columnMappingModal.vue

@ -54,7 +54,7 @@
hide-details="auto"
:items="meta.columns"
item-text="_cn"
:item-value="v => v"
:item-value="v => v && v._cn"
:rules="[
v => validateField(v,r)
]"
@ -110,8 +110,7 @@ export default {
}
},
requiredColumnValidationError() {
const missingRequiredColumns = this.meta.columns.filter(c => (
(c.pk && (!c.ai || !c.cdf)) || c.rqd) &&
const missingRequiredColumns = this.meta.columns.filter(c => (c.pk ? !c.ai && !c.cdf : !c.cdf && c.rqd) &&
!this.mappings.some(r => r.destCn === c._cn))
if (missingRequiredColumns.length) {
@ -126,7 +125,9 @@ export default {
methods: {
validateField(v, row) {
if (!v) { return true }
if (!v) {
return true
}
switch (v.uidt) {
case UITypes.Number:
if (this.parsedCsv && this.parsedCsv.data && this.parsedCsv.data.slice(0, 500)
Loading…
Cancel
Save