next csv params

This commit is contained in:
Jan Prochazka
2020-11-19 11:36:34 +01:00
parent 0cd3e393e8
commit 7ccb1d9c90
5 changed files with 21 additions and 6 deletions

View File

@@ -21,6 +21,20 @@ const csvFormat: FileFormatDefinition = {
],
apiName: 'delimiter',
},
{
type: 'checkbox',
name: 'quoted',
label: 'Quoted',
apiName: 'quoted',
direction: 'target',
},
{
type: 'checkbox',
name: 'header',
label: 'Has header row',
apiName: 'header',
default: true,
},
],
};

View File

@@ -22,7 +22,7 @@ function extractApiParameters(values, direction, format) {
const pairs = (format.args || [])
.filter((arg) => arg.apiName)
.map((arg) => [arg.apiName, values[`${direction}_${format.storageType}_${arg.name}`]])
.filter((x) => x[1]);
.filter((x) => x[1] != null);
return _.fromPairs(pairs);
}

View File

@@ -20,7 +20,7 @@ function FormArgument({ arg, namePrefix }) {
return <FormTextField label={arg.label} name={name} />;
}
if (arg.type == 'checkbox') {
return <FormCheckboxField label={arg.label} name={name} />;
return <FormCheckboxField label={arg.label} name={name} defaultValue={arg.default} />;
}
if (arg.type == 'select') {
return (

View File

@@ -50,12 +50,14 @@ export function FormTextField({ label, ...other }) {
);
}
export function FormCheckboxFieldRaw({ name = undefined, ...other }) {
export function FormCheckboxFieldRaw({ name = undefined, defaultValue = undefined, ...other }) {
const { values, setFieldValue } = useFormikContext();
const handleChange = (event) => {
setFieldValue(name, event.target.checked);
};
return <CheckboxField name={name} checked={!!values[name]} onChange={handleChange} {...other} />;
let isChecked = values[name];
if (isChecked == null) isChecked = defaultValue;
return <CheckboxField name={name} checked={!!isChecked} onChange={handleChange} {...other} />;
// return <Field {...other} as={CheckboxField} />;
}