Browse Source

Merge pull request #1137 from nocodb/fix/csv-import

fix: some csv import issues
pull/1138/head
աɨռɢӄաօռɢ 3 years ago committed by GitHub
parent
commit
6feae235be
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 23
      packages/nc-gui/components/project/spreadsheet/components/importExport/columnMappingModal.vue
  2. 1
      packages/nc-gui/components/project/spreadsheet/components/moreActions.vue
  3. 1
      packages/nc-gui/components/project/spreadsheet/rowsXcDataTable.vue

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

@ -7,7 +7,11 @@
</v-card-title> </v-card-title>
<v-spacer /> <v-spacer />
<v-btn <v-btn
:disabled="!valid || requiredColumnValidationError" :disabled="
!valid ||
(typeof requiredColumnValidationError === 'string' || requiredColumnValidationError) ||
(typeof noSelectedColumnError === 'string' || noSelectedColumnError)
"
color="primary" color="primary"
large large
@click="$emit('import',mappings)" @click="$emit('import',mappings)"
@ -21,6 +25,9 @@
<div v-if="requiredColumnValidationError" class="error--text caption pa-2 text-center"> <div v-if="requiredColumnValidationError" class="error--text caption pa-2 text-center">
{{ requiredColumnValidationError }} {{ requiredColumnValidationError }}
</div> </div>
<div v-if="noSelectedColumnError" class="error--text caption pa-2 text-center">
{{ noSelectedColumnError }}
</div>
<v-divider /> <v-divider />
<v-container fluid> <v-container fluid>
<v-form ref="form" v-model="valid"> <v-form ref="form" v-model="valid">
@ -39,7 +46,7 @@
<tbody> <tbody>
<tr v-for="(r,i) in mappings" :key="i"> <tr v-for="(r,i) in mappings" :key="i">
<td> <td>
<v-checkbox v-model="r.enabled" class="mt-0" dense hide-details /> <v-checkbox v-model="r.enabled" class="mt-0" dense hide-details @change="$refs.form.validate()"/>
</td> </td>
<td class="caption" style="width:45%"> <td class="caption" style="width:45%">
<div :title="r.sourceCn" style=""> <div :title="r.sourceCn" style="">
@ -117,6 +124,12 @@ export default {
return `Following columns are required : ${missingRequiredColumns.map(c => c._cn).join(', ')}` return `Following columns are required : ${missingRequiredColumns.map(c => c._cn).join(', ')}`
} }
return false return false
},
noSelectedColumnError() {
if ((this.mappings || []).filter(v => v.enabled === true).length == 0) {
return 'At least one column has to be selected'
}
return false
} }
}, },
mounted() { mounted() {
@ -129,6 +142,11 @@ export default {
return true return true
} }
// if it is not selected, then pass validation
if (!row.enabled) {
return true
}
const v = this.meta && this.meta.columns.find(c => c._cn === _cn) const v = this.meta && this.meta.columns.find(c => c._cn === _cn)
if ((this.mappings || []).filter(v => v.destCn === _cn).length > 1) { return 'Duplicate mapping found, please remove one of the mapping' } if ((this.mappings || []).filter(v => v.destCn === _cn).length > 1) { return 'Duplicate mapping found, please remove one of the mapping' }
@ -154,6 +172,7 @@ export default {
} }
this.mappings.push(o) this.mappings.push(o)
} }
this.$nextTick(()=> this.$refs.form.validate())
}, },
getIcon(uidt) { getIcon(uidt) {
return getUIDTIcon(uidt) || 'mdi-alpha-v-circle-outline' return getUIDTIcon(uidt) || 'mdi-alpha-v-circle-outline'

1
packages/nc-gui/components/project/spreadsheet/components/moreActions.vue

@ -289,6 +289,7 @@ export default {
} }
this.columnMappingModal = false this.columnMappingModal = false
this.$store.commit('loader/MutClear') this.$store.commit('loader/MutClear')
this.$emit('reload')
this.$toast.success('Successfully imported table data').goAway(3000) this.$toast.success('Successfully imported table data').goAway(3000)
} catch (e) { } catch (e) {
this.$toast.error(e.message).goAway(3000) this.$toast.error(e.message).goAway(3000)

1
packages/nc-gui/components/project/spreadsheet/rowsXcDataTable.vue

@ -110,6 +110,7 @@
:selected-view="selectedView" :selected-view="selectedView"
@showAdditionalFeatOverlay="showAdditionalFeatOverlay($event)" @showAdditionalFeatOverlay="showAdditionalFeatOverlay($event)"
@webhook="showAdditionalFeatOverlay('webhooks')" @webhook="showAdditionalFeatOverlay('webhooks')"
@reload="reload"
/> />
</div> </div>
<v-spacer class="h-100" @dblclick="debug=true" /> <v-spacer class="h-100" @dblclick="debug=true" />

Loading…
Cancel
Save