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) { 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 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))