Browse Source

fix: handle csv / excel import url extension

pull/2401/head
Wing-Kam Wong 2 years ago
parent
commit
78c757e949
  1. 20
      packages/nc-gui/components/import/QuickImport.vue

20
packages/nc-gui/components/import/QuickImport.vue

@ -60,11 +60,17 @@
v-model="url"
hide-details="auto"
type="url"
:label="quickImportType == 'excel' ? $t('msg.info.excelURL') : $t('msg.info.csvURL') "
:label="quickImportType === 'excel' ? $t('msg.info.excelURL') : $t('msg.info.csvURL') "
class="caption"
outlined
dense
:rules="[v => !!v || $t('general.required') ]"
:rules="
[
v => !!v || $t('general.required'),
v => quickImportType === 'excel' ?
(/.*\.(xls|xlsx|xlsm|ods|ots)/.test(v) || errorMessages.importExcel) :
(/.*\.(csv)/.test(v) || errorMessages.importCSV),
]"
/>
<v-btn v-t="['c:project:create:excel:load-url']" class="ml-3" color="primary" @click="loadUrl">
<!--Load-->
@ -213,7 +219,11 @@ export default {
parserConfig: {
maxRowsToParse: 500
},
filename: ''
filename: '',
errorMessages: {
importExcel: "Target file is not an accepted file type. The accepted file types are .xls, .xlsx, .xlsm, .ods, .ots!",
importCSV: "Target file is not an accepted file type. The accepted file type is .csv!"
}
}
},
computed: {
@ -322,11 +332,11 @@ export default {
if (this.quickImportType === 'excel') {
if (!/.*\.(xls|xlsx|xlsm|ods|ots)/.test(file.name)) {
return this.$toast.error('Dropped file is not an accepted file type. The accepted file types are .xls, .xlsx, .xlsm, .ods, .ots!').goAway(3000)
return this.$toast.error(this.errorMessages.importExcel).goAway(3000)
}
} else if (this.quickImportType === 'csv') {
if (!/.*\.(csv)/.test(file.name)) {
return this.$toast.error('Dropped file is not an accepted file type. The accepted file type is .csv!').goAway(3000)
return this.$toast.error(this.errorMessages.importCSV).goAway(3000)
}
}
this._file(file)

Loading…
Cancel
Save