Browse Source

feat(nc-gui): add detectColumnType logic

pull/4135/head
Wing-Kam Wong 2 years ago
parent
commit
5c14090e4d
  1. 10
      packages/nc-gui/utils/parsers/CSVTemplateAdapter.ts

10
packages/nc-gui/utils/parsers/CSVTemplateAdapter.ts

@ -29,6 +29,7 @@ export default class CSVTemplateAdapter {
constructor(files: UploadFile[], parserConfig = {}) { constructor(files: UploadFile[], parserConfig = {}) {
this.config = { this.config = {
maxRowsToParse: 500, maxRowsToParse: 500,
autoSelectFieldTypes: true,
firstRowAsHeaders: true, firstRowAsHeaders: true,
...parserConfig, ...parserConfig,
} }
@ -224,11 +225,16 @@ export default class CSVTemplateAdapter {
tn, tn,
[...Array((row.data as []).length)].map((_, i) => `column${i + 1}`), [...Array((row.data as []).length)].map((_, i) => `column${i + 1}`),
) )
if (that.config.autoSelectFieldTypes) {
// row.data is data
that.detectColumnType(tableIdx, row.data as [])
}
}
} else {
if (that.config.autoSelectFieldTypes) {
// row.data is data // row.data is data
that.detectColumnType(tableIdx, row.data as []) that.detectColumnType(tableIdx, row.data as [])
} }
} else {
that.detectColumnType(tableIdx, row.data as [])
} }
} }
}, },

Loading…
Cancel
Save