Browse Source

chore(nc-gui): revise TODO tag for import for tracking easily later

pull/4135/head
Wing-Kam Wong 2 years ago
parent
commit
e4d8683fa6
  1. 8
      packages/nc-gui/components/dlg/QuickImport.vue
  2. 10
      packages/nc-gui/utils/parsers/CSVTemplateAdapter.ts
  3. 6
      packages/nc-gui/utils/parsers/ExcelTemplateAdapter.ts

8
packages/nc-gui/components/dlg/QuickImport.vue

@ -56,7 +56,7 @@ const isParsingData = ref(false)
const useForm = Form.useForm
const importState = reactive({
// TODO: remove
// TODO(import): remove
// fileList: [] as (UploadFile & { data: string | ArrayBuffer })[],
fileList: [] as UploadFile[],
url: '',
@ -139,7 +139,7 @@ async function handlePreImport() {
isParsingData.value = true
if (activeKey.value === 'uploadTab') {
// TODO: update
// TODO(import): update
await parseAndExtractData2(importState.fileList)
} else if (activeKey.value === 'urlTab') {
try {
@ -152,7 +152,7 @@ async function handlePreImport() {
await parseAndExtractData(JSON.stringify(importState.jsonEditor))
}
// TODO: fix
// TODO(import): fix
// loading.value = false
// isParsingData.value = false
}
@ -296,7 +296,7 @@ function getAdapter(val: any) {
case 'uploadTab':
return new CSVTemplateAdapter(val, importState.parserConfig)
case 'urlTab':
// TODO: implement one for CSV
// TODO(import): implement one for CSV
return new ExcelUrlTemplateAdapter(val, importState.parserConfig)
}
} else if (IsImportTypeExcel.value || isImportTypeCsv.value) {

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

@ -87,7 +87,7 @@ export default class CSVTemplateAdapter {
for (let columnIdx = 0; columnIdx < data.length; columnIdx++) {
const colData: any = [data[columnIdx]]
const colProps = { uidt: this.detectInitialUidt(data[columnIdx]) }
// TODO: centralise
// TODO(import): centralise
if (colProps.uidt === UITypes.SingleLineText) {
if (isMultiLineTextType(colData)) {
colProps.uidt = UITypes.LongText
@ -145,7 +145,7 @@ export default class CSVTemplateAdapter {
for (let columnIdx = 0; columnIdx < this.headers[tableIdx].length; columnIdx++) {
if (this.columnValues[columnIdx].length > 0) {
if (this.project.tables[tableIdx].columns[columnIdx].uidt === UITypes.DateTime) {
// TODO: handle DateTime
// TODO(import): handle DateTime
// set meta
}
Object.assign(
@ -172,7 +172,7 @@ export default class CSVTemplateAdapter {
} else {
that.detectColumnType(row.data as [])
}
// TODO: remove
// TODO(import): remove
if (steppers <= 10) {
console.log('Row:', row.data)
}
@ -183,8 +183,8 @@ export default class CSVTemplateAdapter {
console.log(`steppers: ${steppers}`)
that.updateTemplate(tableIdx)
console.log(that.project.tables)
// TODO: enable import button
// TODO: put info.file.originFileObj to list
// TODO(import): enable import button
// TODO(import): put info.file.originFileObj to list
callback()
},
})

6
packages/nc-gui/utils/parsers/ExcelTemplateAdapter.ts

@ -58,7 +58,7 @@ export default class ExcelTemplateAdapter extends TemplateGenerator {
cellDates: true,
}
// TODO: remove later
// TODO(import): remove later
// if (this.name.slice(-3) === 'csv') {
// this.wb = this.xlsx.read(new TextDecoder().decode(new Uint8Array(this.excelData)), {
// type: 'string',
@ -95,7 +95,7 @@ export default class ExcelTemplateAdapter extends TemplateGenerator {
const range = this.xlsx.utils.decode_range(ws['!ref'])
const rows: any = this.xlsx.utils.sheet_to_json(ws, { header: 1, blankrows: false, defval: null })
// TODO: remove later
// TODO(import): remove later
// if (this.name.slice(-3) !== 'csv') {
// // fix precision bug & timezone offset issues introduced by xlsx
// const basedate = new Date(1899, 11, 30, 0, 0, 0)
@ -192,7 +192,7 @@ export default class ExcelTemplateAdapter extends TemplateGenerator {
column.uidt = UITypes.Currency
}
} else if (column.uidt === UITypes.DateTime) {
// TODO: centralise
// TODO(import): centralise
// hold the possible date format found in the date
const dateFormat: Record<string, number> = {}
if (

Loading…
Cancel
Save