Browse Source

Merge pull request #6725 from nocodb/fix/quick-import

fix(nc-gui): single select in quick import
pull/6726/head
Raju Udava 1 year ago committed by GitHub
parent
commit
f4099f1ed2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      packages/nc-gui/helpers/parsers/CSVTemplateAdapter.ts
  2. 3
      packages/nc-gui/helpers/parsers/ExcelTemplateAdapter.ts
  3. 7
      packages/nc-gui/helpers/parsers/parserHelpers.ts

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

3
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

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

Loading…
Cancel
Save