From 76403ad66756aeefc914deb2a6d3c66062629c0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D5=A1=C9=A8=D5=BC=C9=A2=D3=84=D5=A1=D6=85=D5=BC=C9=A2?= Date: Wed, 18 Oct 2023 16:22:20 +0800 Subject: [PATCH 1/3] fix(nc-gui): revise isCheckboxType logic --- packages/nc-gui/helpers/parsers/parserHelpers.ts | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/packages/nc-gui/helpers/parsers/parserHelpers.ts b/packages/nc-gui/helpers/parsers/parserHelpers.ts index e5679ea852..16321fe2bd 100644 --- a/packages/nc-gui/helpers/parsers/parserHelpers.ts +++ b/packages/nc-gui/helpers/parsers/parserHelpers.ts @@ -29,17 +29,15 @@ export const isCheckboxType: any = (values: [], col?: number) => { let options = booleanOptions for (let i = 0; i < values.length; i++) { const val = getColVal(values[i], col) - if (val === null || val === undefined || val.toString().trim() === '') { continue } - options = options.filter((v) => val in v) if (!options.length) { return false } } - return options + return true } export const getCheckboxValue = (value: any) => { @@ -161,8 +159,7 @@ export const getColumnUIDTAndMetas = (colData: [], defaultType: string) => { if (isUrlType(colData)) { colProps.uidt = UITypes.URL } else { - const checkboxType = isCheckboxType(colData) - if (checkboxType.length === 1) { + if (isCheckboxType(colData)) { colProps.uidt = UITypes.Checkbox } else { Object.assign(colProps, extractMultiOrSingleSelectProps(colData)) From ed5b3828fece1279fa911d2c265113879a2222f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D5=A1=C9=A8=D5=BC=C9=A2=D3=84=D5=A1=D6=85=D5=BC=C9=A2?= Date: Wed, 18 Oct 2023 16:22:40 +0800 Subject: [PATCH 2/3] fix(nc-gui): isCheckboxType return boolean now --- packages/nc-gui/helpers/parsers/ExcelTemplateAdapter.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/nc-gui/helpers/parsers/ExcelTemplateAdapter.ts b/packages/nc-gui/helpers/parsers/ExcelTemplateAdapter.ts index d5d87294b6..5d9cff094a 100644 --- a/packages/nc-gui/helpers/parsers/ExcelTemplateAdapter.ts +++ b/packages/nc-gui/helpers/parsers/ExcelTemplateAdapter.ts @@ -158,8 +158,7 @@ export default class ExcelTemplateAdapter extends TemplateGenerator { .map((r: any) => r[col]) .filter((v: any) => v !== null && v !== undefined && v.toString().trim() !== '') - const checkboxType = isCheckboxType(vals, col) - if (checkboxType.length === 1) { + if (isCheckboxType(vals, col)) { column.uidt = UITypes.Checkbox } else { // Single Select / Multi Select From 185f78e1c05e7ad197c950de4752d2d9072f1ba0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D5=A1=C9=A8=D5=BC=C9=A2=D3=84=D5=A1=D6=85=D5=BC=C9=A2?= Date: Wed, 18 Oct 2023 16:23:04 +0800 Subject: [PATCH 3/3] fix(nc-gui): use isCheckboxType for init detect --- packages/nc-gui/helpers/parsers/CSVTemplateAdapter.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/packages/nc-gui/helpers/parsers/CSVTemplateAdapter.ts b/packages/nc-gui/helpers/parsers/CSVTemplateAdapter.ts index 7f0bf65a7f..c35c6a0e90 100644 --- a/packages/nc-gui/helpers/parsers/CSVTemplateAdapter.ts +++ b/packages/nc-gui/helpers/parsers/CSVTemplateAdapter.ts @@ -85,7 +85,7 @@ export default class CSVTemplateAdapter { detectInitialUidt(v: string) { if (!isNaN(Number(v)) && !isNaN(parseFloat(v))) return UITypes.Number if (validateDateWithUnknownFormat(v)) return UITypes.DateTime - if (['true', 'True', 'false', 'False', '1', '0', 'T', 'F', 'Y', 'N'].includes(v)) return UITypes.Checkbox + if (isCheckboxType(v)) return UITypes.Checkbox return UITypes.SingleLineText } @@ -105,8 +105,7 @@ export default class CSVTemplateAdapter { if (isUrlType(colData)) { colProps.uidt = UITypes.URL } else { - const checkboxType = isCheckboxType(colData) - if (checkboxType.length === 1) { + if (isCheckboxType(colData)) { colProps.uidt = UITypes.Checkbox } else { if (data[columnIdx] && columnIdx < this.config.maxRowsToParse) {