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 FileSaver from 'file-saver'
import DropOrSelectFileModal from '~/components/import/dropOrSelectFileModal' 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' import CSVTemplateAdapter from '~/components/import/templateParsers/CSVTemplateAdapter'
export default { export default {
@ -247,8 +247,8 @@ export default {
const batchData = data.slice(i, i + 500).map(row => columnMappings.reduce((res, col) => { const batchData = data.slice(i, i + 500).map(row => columnMappings.reduce((res, col) => {
// todo: parse data // todo: parse data
if (col.enabled && col.destCn && col.destCn._cn) { if (col.enabled && col.destCn) {
res[col.destCn._cn] = row[col.sourceCn] res[col.destCn] = row[col.sourceCn]
} }
return res 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" hide-details="auto"
:items="meta.columns" :items="meta.columns"
item-text="_cn" item-text="_cn"
:item-value="v => v" :item-value="v => v && v._cn"
:rules="[ :rules="[
v => validateField(v,r) v => validateField(v,r)
]" ]"
@ -110,8 +110,7 @@ export default {
} }
}, },
requiredColumnValidationError() { requiredColumnValidationError() {
const missingRequiredColumns = this.meta.columns.filter(c => ( const missingRequiredColumns = this.meta.columns.filter(c => (c.pk ? !c.ai && !c.cdf : !c.cdf && c.rqd) &&
(c.pk && (!c.ai || !c.cdf)) || c.rqd) &&
!this.mappings.some(r => r.destCn === c._cn)) !this.mappings.some(r => r.destCn === c._cn))
if (missingRequiredColumns.length) { if (missingRequiredColumns.length) {
@ -126,7 +125,9 @@ export default {
methods: { methods: {
validateField(v, row) { validateField(v, row) {
if (!v) { return true } if (!v) {
return true
}
switch (v.uidt) { switch (v.uidt) {
case UITypes.Number: case UITypes.Number:
if (this.parsedCsv && this.parsedCsv.data && this.parsedCsv.data.slice(0, 500) if (this.parsedCsv && this.parsedCsv.data && this.parsedCsv.data.slice(0, 500)
Loading…
Cancel
Save