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', name: 'column',
type: 'string', type: 'string',
isDefined: (timestampSpec: TimestampSpec) => isColumnTimestampSpec(timestampSpec) defaultValue: 'timestamp'
}, },
{ {
name: 'format', name: 'format',
type: 'string', type: 'string',
defaultValue: 'auto',
suggestions: ['auto'].concat(TIMESTAMP_FORMAT_VALUES), suggestions: ['auto'].concat(TIMESTAMP_FORMAT_VALUES),
isDefined: (timestampSpec: TimestampSpec) => isColumnTimestampSpec(timestampSpec), isDefined: (timestampSpec: TimestampSpec) => isColumnTimestampSpec(timestampSpec),
info: <p> info: <p>
@ -269,12 +270,30 @@ const TIMESTAMP_SPEC_FORM_FIELDS: Field<TimestampSpec>[] = [
{ {
name: 'missingValue', name: 'missingValue',
type: 'string', 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() { const CONSTANT_TIMESTAMP_SPEC_FORM_FIELDS: Field<TimestampSpec>[] = [
return TIMESTAMP_SPEC_FORM_FIELDS; {
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 { export function issueWithTimestampSpec(timestampSpec: TimestampSpec | undefined): string | null {

View File

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