-
Notifications
You must be signed in to change notification settings - Fork 14.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[exploreV2] mapStateToProps for fields (#1882)
* Controls support for mapStateToProps * Binding methods in the constructor * Adressing comments * Fixing tests
- Loading branch information
1 parent
9a62d94
commit 2226716
Showing
11 changed files
with
193 additions
and
217 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 13 additions & 42 deletions
55
superset/assets/javascripts/explorev2/components/FieldSetRow.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1,23 @@ | ||
import React, { PropTypes } from 'react'; | ||
import FieldSet from './FieldSet'; | ||
|
||
const NUM_COLUMNS = 12; | ||
|
||
const propTypes = { | ||
fields: PropTypes.object.isRequired, | ||
fieldSets: PropTypes.array.isRequired, | ||
fieldOverrides: PropTypes.object, | ||
onChange: PropTypes.func, | ||
form_data: PropTypes.object.isRequired, | ||
fields: PropTypes.arrayOf(PropTypes.object).isRequired, | ||
}; | ||
|
||
const defaultProps = { | ||
fieldOverrides: {}, | ||
onChange: () => {}, | ||
}; | ||
|
||
export default class FieldSetRow extends React.Component { | ||
getFieldData(fs) { | ||
const { fields, fieldOverrides } = this.props; | ||
let fieldData = fields[fs]; | ||
if (fieldOverrides.hasOwnProperty(fs)) { | ||
const overrideData = fieldOverrides[fs]; | ||
fieldData = Object.assign({}, fieldData, overrideData); | ||
} | ||
return fieldData; | ||
} | ||
render() { | ||
const colSize = NUM_COLUMNS / this.props.fieldSets.length; | ||
return ( | ||
<div className="row space-2"> | ||
{this.props.fieldSets.map((fs) => { | ||
const fieldData = this.getFieldData(fs); | ||
return ( | ||
<div className={`col-lg-${colSize} col-xs-12`} key={fs}> | ||
<FieldSet | ||
name={fs} | ||
onChange={this.props.onChange} | ||
value={this.props.form_data[fs]} | ||
{...fieldData} | ||
/> | ||
</div> | ||
); | ||
})} | ||
</div> | ||
); | ||
} | ||
function FieldSetRow(props) { | ||
const colSize = NUM_COLUMNS / props.fields.length; | ||
return ( | ||
<div className="row space-2"> | ||
{props.fields.map((field, i) => ( | ||
<div className={`col-lg-${colSize} col-xs-12`} key={i} > | ||
{field} | ||
</div> | ||
))} | ||
</div> | ||
); | ||
} | ||
|
||
FieldSetRow.propTypes = propTypes; | ||
FieldSetRow.defaultProps = defaultProps; | ||
export default FieldSetRow; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.