Files
superset2/caravel/assets/javascripts/explorev2/components/FieldSet.jsx
Alanna Scott 38d3075554 [explore V2] render all control panels and fields dynamically for each vis type (#1493)
* export functions directly rather than object at the bottom

* move viztypes to controlPanelMappings, add fieldset rows and section data

* for each viz type, render a controlPanelsContainer, controlPanelSections, FieldSetRows, and FieldsSets

* add comments, move mappings to store

* organize store and add default sections

* render all the needed sections

* add tooltip to sections

* remove console log

* use only panel panel-default, not panel-body, no need the padding

* render fields for all fields in field set

* add the rest of the control panel sections and field overrides

* fix naming

* add fieldTypes array

* don't use default section

* pass only needed state via mapStateToProps

* fix code climate errors

* linting

* move field components to their own files

* render field sets as lists

* fix field components

* use SFC

* update modal trigger test to be more accurate

* add FieldSetRow test

* add test for controlpanelsContainer

* fix test

* make code climate happy

* add freeform select field
2016-11-02 12:57:44 -07:00

64 lines
1.8 KiB
JavaScript

import React, { PropTypes } from 'react';
import TextField from './TextField';
import CheckboxField from './CheckboxField';
import TextAreaField from './TextAreaField';
import SelectField from './SelectField';
import { fieldTypes } from '../stores/store';
const propTypes = {
type: PropTypes.oneOf(fieldTypes).isRequired,
label: PropTypes.string.isRequired,
choices: PropTypes.arrayOf(PropTypes.array),
description: PropTypes.string,
places: PropTypes.number,
validators: PropTypes.any,
};
const defaultProps = {
choices: null,
description: null,
places: null,
validators: null,
};
export default class FieldSet extends React.Component {
renderCheckBoxField() {
return <CheckboxField label={this.props.label} description={this.props.description} />;
}
renderTextAreaField() {
return <TextAreaField label={this.props.label} description={this.props.description} />;
}
renderSelectField() {
return <SelectField label={this.props.label} description={this.props.description} />;
}
renderTextField() {
return <TextField label={this.props.label} description={this.props.description} />;
}
render() {
const type = this.props.type;
let html;
if (type === 'CheckboxField') {
html = this.renderCheckBoxField();
} else if (type === 'SelectField' ||
type === 'SelectCustomMultiField' ||
type === 'SelectMultipleSortableField' ||
type === 'FreeFormSelectField') {
html = this.renderSelectField();
} else if (type === 'TextField' || type === 'IntegerField') {
html = this.renderTextField();
} else if (type === 'TextAreaField') {
this.renderTextAreaField();
}
return html;
}
}
FieldSet.propTypes = propTypes;
FieldSet.defaultProps = defaultProps;