From a9e272e0744624aad82f2ddd855af64a3bcaa6ac Mon Sep 17 00:00:00 2001 From: Wing-Kam Wong Date: Wed, 19 Oct 2022 13:40:40 +0800 Subject: [PATCH] feat(nc-gui): import numeric detection logic --- .../nc-gui/utils/parsers/CSVTemplateAdapter.ts | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/packages/nc-gui/utils/parsers/CSVTemplateAdapter.ts b/packages/nc-gui/utils/parsers/CSVTemplateAdapter.ts index e36a2dbe43..4e2b035da7 100644 --- a/packages/nc-gui/utils/parsers/CSVTemplateAdapter.ts +++ b/packages/nc-gui/utils/parsers/CSVTemplateAdapter.ts @@ -143,6 +143,17 @@ export default class CSVTemplateAdapter { if (len == 0) { return UITypes.SingleLineText } + // handle numeric case + if ( + Object.keys(this.detectedColumnTypes[columnIdx]).length == 2 && + UITypes.Number in this.detectedColumnTypes[columnIdx] && + UITypes.Decimal in this.detectedColumnTypes[columnIdx] + ) { + if (this.detectedColumnTypes[columnIdx][UITypes.Number] > this.detectedColumnTypes[columnIdx][UITypes.Decimal]) { + return UITypes.Number + } + return UITypes.Decimal + } // if there are multiple detected column types // then return either LongText or SingleLineText if (Object.keys(this.detectedColumnTypes[columnIdx]).length > 1) { @@ -215,8 +226,6 @@ export default class CSVTemplateAdapter { console.log('complete') console.log(`steppers: ${steppers}`) that.updateTemplate(tableIdx) - // TODO(import): enable import button - // TODO(import): put info.file.originFileObj to list callback() }, }) @@ -263,7 +272,6 @@ export default class CSVTemplateAdapter { complete() { console.log('getData(): complete') console.log(`getData(): steppers: ${steppers}`) - console.log(that.data[tn]) }, }) }