Skip to content

Commit

Permalink
pushed sorting back to fields from index
Browse files Browse the repository at this point in the history
  • Loading branch information
KeyboardTsundoku committed Dec 15, 2016
1 parent 4f01606 commit 02355d3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
11 changes: 10 additions & 1 deletion src/internal-packages/schema/lib/component/field.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,17 @@ const Field = React.createClass({
},

componentWillMount() {
// sort the types in descending order and push undefined to the end
const types = _.sortBy(this.props.types, (type) => {
if (type.name === 'Undefined') {
return -Infinity;
}
return type.probability;
}).reverse();

// sets the active type to the first type in the props.types array
this.setState({
types: types,
activeType: this.props.types.length > 0 ? this.props.types[0] : null
});
},
Expand Down Expand Up @@ -139,7 +148,7 @@ const Field = React.createClass({
const cls = FIELD_CLASS + ' ' + (this.state.collapsed ? 'collapsed' : 'expanded');

// types represented as horizontal bars with labels
const typeList = this.props.types.map((type) => {
const typeList = this.state.types.map((type) => {
// allow for semantic types and convert the type, e.g. geo coordinates
type = this.getSemanticType(type);
return (
Expand Down
10 changes: 0 additions & 10 deletions src/internal-packages/schema/lib/component/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,16 +90,6 @@ const Schema = React.createClass({
render() {
this._updateProgressBar();
const fieldList = _.get(this.state.schema, 'fields', []).map((field) => {
// sort the types in descending order and push undefined to the end
const types = _.sortBy(field.types, (type) => {
if (type.name === 'Undefined') {
return -Infinity;
}
return type.probability;
}).reverse();

field.types = types;
console.log('field props', field);
return <Field key={field.name} {...field} />;
});
return (
Expand Down

0 comments on commit 02355d3

Please sign in to comment.