Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
metagrover committed Aug 3, 2017
2 parents 04da6d7 + f56d2c4 commit f492f5b
Show file tree
Hide file tree
Showing 29 changed files with 458 additions and 202 deletions.
79 changes: 64 additions & 15 deletions app/sensors/GeoDistanceDropdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,16 @@ export default class GeoDistanceDropdown extends Component {
unit: this.unit
}
};

const execQuery = () => {
if(this.props.onValueChange) {
this.props.onValueChange(obj.value);
}
helper.selectedSensor.setSortInfo(sortObj);
helper.URLParams.update(this.props.componentId, this.setURLValue(), this.props.URLParams);
helper.selectedSensor.set(obj, true);
};

const sortObj = {
key: this.props.componentId,
value: {
Expand All @@ -235,19 +245,42 @@ export default class GeoDistanceDropdown extends Component {
}
}
};
if(this.props.onValueChange) {
this.props.onValueChange(obj.value);

if (this.props.beforeValueChange) {
this.props.beforeValueChange(obj.value)
.then(() => {
execQuery();
})
.catch((e) => {
console.warn(`${this.props.componentId} - beforeValueChange rejected the promise with`, e);
});
} else {
execQuery();
}
helper.selectedSensor.setSortInfo(sortObj);
helper.URLParams.update(this.props.componentId, this.setURLValue(), this.props.URLParams);
helper.selectedSensor.set(obj, true);
} else if(this.state.selected === null && this.state.currentValue === "") {
const obj = {
key: this.props.componentId,
value: null
};
helper.URLParams.update(this.props.componentId, null, this.props.URLParams);
helper.selectedSensor.set(obj, true);
const execNullQuery = () => {
const obj = {
key: this.props.componentId,
value: null
};
if(this.props.onValueChange) {
this.props.onValueChange(null);
}
helper.URLParams.update(this.props.componentId, null, this.props.URLParams);
helper.selectedSensor.set(obj, true);
}

if (this.props.beforeValueChange) {
this.props.beforeValueChange(obj.value)
.then(() => {
execNullQuery();
})
.catch((e) => {
console.warn(`${this.props.componentId} - beforeValueChange rejected the promise with`, e);
});
} else {
execNullQuery();
}
}
}

Expand All @@ -274,11 +307,26 @@ export default class GeoDistanceDropdown extends Component {
key: this.props.componentId,
value: null
};
if(this.props.onValueChange) {
this.props.onValueChange(obj.value);

const execQuery = () => {
if(this.props.onValueChange) {
this.props.onValueChange(obj.value);
}
helper.URLParams.update(this.props.componentId, null, this.props.URLParams);
helper.selectedSensor.set(obj, true);
};

if (this.props.beforeValueChange) {
this.props.beforeValueChange(obj.value)
.then(() => {
execQuery();
})
.catch((e) => {
console.warn(`${this.props.componentId} - beforeValueChange rejected the promise with`, e);
});
} else {
execQuery();
}
helper.URLParams.update(this.props.componentId, null, this.props.URLParams);
helper.selectedSensor.set(obj, true);
}
}

Expand Down Expand Up @@ -401,6 +449,7 @@ GeoDistanceDropdown.propTypes = {
label: React.PropTypes.string.isRequired
})
),
beforeValueChange: React.PropTypes.func,
onValueChange: React.PropTypes.func,
componentStyle: React.PropTypes.object,
URLParams: React.PropTypes.bool,
Expand Down
82 changes: 66 additions & 16 deletions app/sensors/GeoDistanceSlider.js
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ export default class GeoDistanceSlider extends Component {
location: this.locString
}
};

const sortObj = {
key: this.props.componentId,
value: {
Expand All @@ -215,19 +216,51 @@ export default class GeoDistanceSlider extends Component {
}
}
};
if(this.props.onValueChange) {
this.props.onValueChange(obj.value);

const execQuery = () => {
if(this.props.onValueChange) {
this.props.onValueChange(obj.value);
}
helper.selectedSensor.setSortInfo(sortObj);
helper.URLParams.update(this.props.componentId, this.setURLValue(), this.props.URLParams);
helper.selectedSensor.set(obj, true);
};

if (this.props.beforeValueChange) {
this.props.beforeValueChange(obj.value)
.then(() => {
execQuery();
})
.catch((e) => {
console.warn(`${this.props.componentId} - beforeValueChange rejected the promise with`, e);
});
} else {
execQuery();
}
helper.selectedSensor.setSortInfo(sortObj);
helper.URLParams.update(this.props.componentId, this.setURLValue(), this.props.URLParams);
helper.selectedSensor.set(obj, true);
} else if(this.state.currentDistance === null && this.state.currentValue === "") {
const obj = {
key: this.props.componentId,
value: null
};
helper.URLParams.update(this.props.componentId, null, this.props.URLParams);
helper.selectedSensor.set(obj, true);
const execNullQuery = () => {
if(this.props.onValueChange) {
this.props.onValueChange(null);
}
const obj = {
key: this.props.componentId,
value: null
};
helper.URLParams.update(this.props.componentId, null, this.props.URLParams);
helper.selectedSensor.set(obj, true);
}

if (this.props.beforeValueChange) {
this.props.beforeValueChange(obj.value)
.then(() => {
execNullQuery();
})
.catch((e) => {
console.warn(`${this.props.componentId} - beforeValueChange rejected the promise with`, e);
});
} else {
execNullQuery();
}
}
}

Expand All @@ -252,14 +285,30 @@ export default class GeoDistanceSlider extends Component {
this.setState({
currentValue: ""
});

const obj = {
key: this.props.componentId,
value: null
};
if(this.props.onValueChange) {
this.props.onValueChange(obj.value);

const execQuery = () => {
if(this.props.onValueChange) {
this.props.onValueChange(obj.value);
}
helper.selectedSensor.set(obj, true);
};

if (this.props.beforeValueChange) {
this.props.beforeValueChange(obj.value)
.then(() => {
execQuery();
})
.catch((e) => {
console.warn(`${this.props.componentId} - beforeValueChange rejected the promise with`, e);
});
} else {
execQuery();
}
helper.selectedSensor.set(obj, true);
}
}

Expand Down Expand Up @@ -361,10 +410,10 @@ export default class GeoDistanceSlider extends Component {
<div className="rbc-rangeslider-container col s12 col-xs-12">
<Slider
tipFormatter={this.unitFormatter}
value={this.state.value}
defaultValue={this.state.value}
min={this.props.range.start}
max={this.props.range.end}
onChange={this.handleResults}
onAfterChange={this.handleResults}
marks={marks}
step={this.props.stepValue}
/>
Expand Down Expand Up @@ -399,6 +448,7 @@ GeoDistanceSlider.propTypes = {
end: React.PropTypes.string
}),
autoLocation: React.PropTypes.bool,
beforeValueChange: React.PropTypes.func,
onValueChange: React.PropTypes.func,
componentStyle: React.PropTypes.object,
URLParams: React.PropTypes.bool,
Expand Down
46 changes: 38 additions & 8 deletions app/sensors/PlacesSearch.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,11 +184,26 @@ export default class PlacesSearch extends Component {
location: this.locString
}
};
if(this.props.onValueChange) {
this.props.onValueChange(obj.value);

const execQuery = () => {
if(this.props.onValueChange) {
this.props.onValueChange(obj.value);
}
helper.URLParams.update(this.props.componentId, this.state.currentValue, this.props.URLParams);
helper.selectedSensor.set(obj, true);
};

if (this.props.beforeValueChange) {
this.props.beforeValueChange(obj.value)
.then(() => {
execQuery();
})
.catch((e) => {
console.warn(`${this.props.componentId} - beforeValueChange rejected the promise with`, e);
});
} else {
execQuery();
}
helper.URLParams.update(this.props.componentId, this.state.currentValue, this.props.URLParams);
helper.selectedSensor.set(obj, true);
}
}

Expand All @@ -208,11 +223,25 @@ export default class PlacesSearch extends Component {
key: this.props.componentId,
value: null
};
if(this.props.onValueChange) {
this.props.onValueChange(obj.value);
const execQuery = () => {
if(this.props.onValueChange) {
this.props.onValueChange(obj.value);
}
helper.URLParams.update(this.props.componentId, null, this.props.URLParams);
helper.selectedSensor.set(obj, true);
};

if (this.props.beforeValueChange) {
this.props.beforeValueChange(obj.value)
.then(() => {
execQuery();
})
.catch((e) => {
console.warn(`${this.props.componentId} - beforeValueChange rejected the promise with`, e);
});
} else {
execQuery();
}
helper.URLParams.update(this.props.componentId, null, this.props.URLParams);
helper.selectedSensor.set(obj, true);
}
}

Expand Down Expand Up @@ -309,6 +338,7 @@ PlacesSearch.propTypes = {
customQuery: React.PropTypes.func,
placeholder: React.PropTypes.string,
autoLocation: React.PropTypes.bool,
beforeValueChange: React.PropTypes.func,
onValueChange: React.PropTypes.func,
componentStyle: React.PropTypes.object,
URLParams: React.PropTypes.bool,
Expand Down
14 changes: 7 additions & 7 deletions dist/CustomQuery.bundle.js

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions dist/GeoDistanceDropdown.bundle.js

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions dist/GeoDistanceSlider.bundle.js

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions dist/PlacesSearch.bundle.js

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions dist/direction.bundle.js

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions dist/earthquake.bundle.js

Large diffs are not rendered by default.

16 changes: 8 additions & 8 deletions dist/events.bundle.js

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions dist/heatmap.bundle.js

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions dist/list.bundle.js

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions dist/meetupblast.bundle.js

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions dist/nearby.bundle.js

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions dist/now.bundle.js

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions dist/transport.bundle.js

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions dist/weather.bundle.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions examples/GeoDistanceDropdown/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ class Main extends Component {
{ start: 501, end: 1000, label: "Above 500 miles" }]
}
placeholder="Search Location"
beforeValueChange={() => new Promise((resolve, reject) => resolve())}
/>
</div>
<div className="col s6 col-xs-6">
Expand Down
1 change: 1 addition & 0 deletions examples/GeoDistanceSlider/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ class Main extends Component {
unit="mi"
placeholder="Search Location"
URLParams={true}
beforeValueChange={() => new Promise((resolve, reject) => resolve())}
/>
</div>
<div className="col s6 col-xs-6">
Expand Down
Loading

0 comments on commit f492f5b

Please sign in to comment.