Files
dc/client/src/app/shared/dc-validator/utils/getHotDataSchema.ts
Mihajlo Medjedovic a1a90519c5
Some checks failed
Build / Build-and-ng-test (pull_request) Failing after 1m59s
fix: unnecessary zeros when adding new row (data schema default values)
2024-09-27 13:36:50 +02:00

30 lines
701 B
TypeScript

import { DcValidation } from '../models/dc-validation.model'
const schemaTypeMap: { [key: string]: any } = {
numeric: '',
default: ''
}
/**
* Schema defines the default values for given types. For example when new row is added.
*/
export const getHotDataSchema = (
type: string | undefined,
cellValidation?: DcValidation
): any => {
if (!type) return schemaTypeMap.default
switch (type) {
case 'autocomplete': {
return cellValidation && cellValidation.source
? (cellValidation.source as string[] | number[])[0]
: []
}
default: {
if (schemaTypeMap.hasOwnProperty(type)) return schemaTypeMap[type]
return schemaTypeMap.default
}
}
}