Browse Source

fix: handle csv / excel import url extension

feat/0523-export-schema
Wing-Kam Wong 2 years ago committed by Raju Udava
parent
commit
ab7832a5b0
  1. 20
      packages/nc-gui/components/import/QuickImport.vue

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

@ -60,11 +60,17 @@
v-model="url" v-model="url"
hide-details="auto" hide-details="auto"
type="url" 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" class="caption"
outlined outlined
dense 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"> <v-btn v-t="['c:project:create:excel:load-url']" class="ml-3" color="primary" @click="loadUrl">
<!--Load--> <!--Load-->
@ -213,7 +219,11 @@ export default {
parserConfig: { parserConfig: {
maxRowsToParse: 500 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: { computed: {
@ -322,11 +332,11 @@ export default {
if (this.quickImportType === 'excel') { if (this.quickImportType === 'excel') {
if (!/.*\.(xls|xlsx|xlsm|ods|ots)/.test(file.name)) { 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') { } else if (this.quickImportType === 'csv') {
if (!/.*\.(csv)/.test(file.name)) { 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) this._file(file)

Loading…
Cancel
Save