Web console: fix missing value input in timestampSpec step (#7698)

This commit is contained in:
Vadim Ogievetsky 2019-05-21 03:59:48 -07:00 committed by Clint Wylie
parent cb6ec2cab8
commit 169d2493bc
2 changed files with 24 additions and 5 deletions

View File

@ -255,11 +255,12 @@ const TIMESTAMP_SPEC_FORM_FIELDS: Field<TimestampSpec>[] = [
{
name: 'column',
type: 'string',
isDefined: (timestampSpec: TimestampSpec) => isColumnTimestampSpec(timestampSpec)
defaultValue: 'timestamp'
},
{
name: 'format',
type: 'string',
defaultValue: 'auto',
suggestions: ['auto'].concat(TIMESTAMP_FORMAT_VALUES),
isDefined: (timestampSpec: TimestampSpec) => isColumnTimestampSpec(timestampSpec),
info: <p>
@ -269,12 +270,30 @@ const TIMESTAMP_SPEC_FORM_FIELDS: Field<TimestampSpec>[] = [
{
name: 'missingValue',
type: 'string',
isDefined: (timestampSpec: TimestampSpec) => !isColumnTimestampSpec(timestampSpec)
placeholder: '(optional)',
info: <p>
This value will be used if the specified column can not be found.
</p>
}
];
export function getTimestampSpecFormFields() {
return TIMESTAMP_SPEC_FORM_FIELDS;
const CONSTANT_TIMESTAMP_SPEC_FORM_FIELDS: Field<TimestampSpec>[] = [
{
name: 'missingValue',
label: 'Constant value',
type: 'string',
info: <p>
The dummy value that will be used as the timestamp.
</p>
}
];
export function getTimestampSpecFormFields(timestampSpec: TimestampSpec) {
if (isColumnTimestampSpec(timestampSpec)) {
return TIMESTAMP_SPEC_FORM_FIELDS;
} else {
return CONSTANT_TIMESTAMP_SPEC_FORM_FIELDS;
}
}
export function issueWithTimestampSpec(timestampSpec: TimestampSpec | undefined): string | null {

View File

@ -1112,7 +1112,7 @@ export class LoadDataView extends React.Component<LoadDataViewProps, LoadDataVie
</ButtonGroup>
</FormGroup>
<AutoForm
fields={getTimestampSpecFormFields()}
fields={getTimestampSpecFormFields(timestampSpec)}
model={timestampSpec}
onChange={(timestampSpec) => {
this.updateSpec(deepSet(spec, 'dataSchema.parser.parseSpec.timestampSpec', timestampSpec));