Skip to content

Commit 684198e

Browse files
committed
Merge branch 'dev'
2 parents 1d992cc + d2fc278 commit 684198e

81 files changed

Lines changed: 523 additions & 810 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.eslintrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
"comma-dangle": ["error", "never"],
2727
"object-curly-spacing": [2, "always"],
2828
// "linebreak-style": ["error", "windows"],
29+
"react/prop-types": 0,
2930
"react/require-default-props": 0,
3031
"react/require-extension": 0,
3132
"react/jsx-uses-react": 2,

app/actuators/ReactiveMap.js

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,13 @@ import {
99
AppbaseSensorHelper as helper,
1010
PoweredBy
1111
} from "@appbaseio/reactivebase";
12-
import { SearchAsMove } from "../addons/SearchAsMove";
12+
import _ from "lodash";
13+
import SearchAsMove from "../addons/SearchAsMove";
1314
import { MapStyles, mapStylesCollection } from "../addons/MapStyles";
1415
import * as ReactiveMapHelper from "../helper/ReactiveMapHelper";
1516

16-
import _ from "lodash";
17-
1817
const MapComponent = (withGoogleMap((props) => {
19-
const { children: children, onMapMounted: onMapMounted, ...allProps } = props;
18+
const { children, onMapMounted, ...allProps } = props;
2019

2120
return (
2221
<GoogleMap ref={onMapMounted} {...allProps}>
@@ -92,7 +91,7 @@ export default class ReactiveMap extends Component {
9291
this.setReact(this.props);
9392
this.createChannel(updateExecute);
9493
const currentMapStyle = this.getMapStyle(this.props.defaultMapStyle);
95-
this.initialMapBoundQuery = this.props.defaultCenter ? true : false;
94+
this.initialMapBoundQuery = !!this.props.defaultCenter;
9695
this.applyGeoQuery = this.props.applyGeoQuery ? this.props.applyGeoQuery : this.props.setSearchAsMove;
9796
this.setState({
9897
currentMapStyle
@@ -180,7 +179,7 @@ export default class ReactiveMap extends Component {
180179
delete modifiedData.data;
181180
modifiedData = helper.prepareResultData(modifiedData, res.data);
182181
if (this.props.onAllData) {
183-
if(modifiedData.res) {
182+
if (modifiedData.res) {
184183
modifiedData.res.mapRef = this.mapRef;
185184
}
186185
const generatedData = this.props.onAllData(modifiedData.res, modifiedData.err);
@@ -252,7 +251,7 @@ export default class ReactiveMap extends Component {
252251
this.setState({
253252
rerender: true
254253
}, () => {
255-
if(this.props.popoverTTL) {
254+
if (this.props.popoverTTL) {
256255
this.watchPopoverTTL(marker);
257256
}
258257
});
@@ -268,18 +267,18 @@ export default class ReactiveMap extends Component {
268267
// watch and close popover on timeout
269268
watchPopoverTTL(marker) {
270269
this.popoverTTLStore = this.popoverTTLStore ? this.popoverTTLStore : {};
271-
if(this.popoverTTLStore[marker._type+marker._id]) {
272-
this.clearTTL(marker._type+marker._id);
270+
if (this.popoverTTLStore[marker._type + marker._id]) {
271+
this.clearTTL(marker._type + marker._id);
273272
} else {
274-
this.popoverTTLStore[marker._type+marker._id] = setTimeout(() => {
273+
this.popoverTTLStore[marker._type + marker._id] = setTimeout(() => {
275274
this.handleMarkerClose(marker);
276-
this.clearTTL(marker._type+marker._id);
277-
}, this.props.popoverTTL*1000);
275+
this.clearTTL(marker._type + marker._id);
276+
}, this.props.popoverTTL * 1000);
278277
}
279278
}
280279

281280
clearTTL(id) {
282-
clearTimeout(this.popoverTTLStore[id])
281+
clearTimeout(this.popoverTTLStore[id]);
283282
delete this.popoverTTLStore[id];
284283
}
285284

@@ -325,7 +324,7 @@ export default class ReactiveMap extends Component {
325324
const flag = this.initialMapBoundQuery ? true : (this.applyGeoQuery ? this.applyGeoQuery : this.searchAsMove);
326325
this.setValue(boundingBoxCoordinates, flag);
327326
}
328-
if (!_.isEqual({mapBounds: this.state.mapBounds}, stateObj)) {
327+
if (!_.isEqual({ mapBounds: this.state.mapBounds }, stateObj)) {
329328
this.setState(stateObj);
330329
}
331330
}
@@ -454,9 +453,7 @@ export default class ReactiveMap extends Component {
454453
convertedGeo: []
455454
};
456455
if (markersData && markersData.length) {
457-
markersData = markersData.filter((hit) => {
458-
return ReactiveMapHelper.identifyGeoData(hit._source[self.props.dataField]);
459-
});
456+
markersData = markersData.filter(hit => ReactiveMapHelper.identifyGeoData(hit._source[self.props.dataField]));
460457
response.markerComponent = markersData.map((hit, index) => {
461458
const field = ReactiveMapHelper.identifyGeoData(hit._source[self.props.dataField]);
462459
response.convertedGeo.push(field);
@@ -475,7 +472,7 @@ export default class ReactiveMap extends Component {
475472
popoverEvent = {};
476473
popoverEvent.onClick = this.handleMarkerClick.bind(this, hit);
477474
}
478-
const defaultFn = function() {};
475+
const defaultFn = function () {};
479476
const events = {
480477
onClick: this.props.markerOnClick ? this.props.markerOnClick : defaultFn,
481478
onDblClick: this.props.markerOnDblClick ? this.props.markerOnDblClick : defaultFn,
@@ -598,7 +595,7 @@ export default class ReactiveMap extends Component {
598595
{showMapStyles}
599596
<MapComponent
600597
onMapMounted={(ref) => {
601-
this.mapRef = ref
598+
this.mapRef = ref;
602599
}}
603600
containerElement={<div
604601
className="rbc-container"
@@ -607,7 +604,7 @@ export default class ReactiveMap extends Component {
607604
mapElement={<div style={{ height: "100%" }} />}
608605
{...centerComponent}
609606
{...ReactiveMapHelper.normalizeProps(this.props)}
610-
options = {{
607+
options={{
611608
styles: this.state.currentMapStyle
612609
}}
613610
defaultCenter={ReactiveMapHelper.normalizeCenter(this.state.defaultCenter)}

app/addons/ItemCheckboxList.js

Lines changed: 18 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,22 @@
1-
import { default as React, Component } from "react";
1+
import React, { Component } from "react";
22

3-
export class ItemCheckboxList extends Component {
3+
export default class ItemCheckboxList extends Component {
44
constructor(props) {
55
super(props);
6+
67
this.state = {
78
selectedItems: []
89
};
10+
911
this.handleListClick = this.handleListClick.bind(this);
10-
this.handleTagClick = this.handleTagClick.bind(this);
1112
this.handleListClickAll = this.handleListClickAll.bind(this);
12-
}
1313

14-
componentDidMount() {
15-
if (this.props.defaultSelected) {
16-
this.setState({
17-
selectedItems: this.props.defaultSelected
18-
}, () => {
19-
this.updateAction.bind(this);
20-
this.props.onSelect(this.state.selectedItems);
21-
});
14+
if (props.defaultSelected) {
15+
this.state = {
16+
selectedItems: props.defaultSelected
17+
};
18+
this.updateAction();
19+
this.props.onSelect(this.state.selectedItems);
2220
}
2321
}
2422

@@ -80,39 +78,11 @@ export class ItemCheckboxList extends Component {
8078
this.props.onSelect(this.state.selectedItems);
8179
}
8280
}
83-
// If the checkbox selectedStatus is false
84-
// Call handleTagClick to remove it from the selected Items
85-
else {
86-
this.handleTagClick(value);
87-
}
88-
}
89-
90-
// Handler function when a cancel button on tag is clicked to remove it
91-
handleTagClick(value) {
92-
// Pass the older value props to parent components to remove older list in terms query
93-
const isExecutable = this.state.selectedItems.length === 1;
94-
this.props.onRemove(this.state.selectedItems, isExecutable);
95-
const keyRef = value.toString().replace(/ /g, "_");
96-
const ref = `ref${keyRef}`;
97-
const checkboxElement = this.refs[ref];
98-
checkboxElement.state.status = false;
99-
const updated = this.state.selectedItems;
100-
const index = updated.indexOf(value);
101-
updated.splice(index, 1);
102-
this.setState({
103-
selectedItems: updated
104-
}, this.updateAction.bind(this));
105-
// Pass the removed value props to parent components to add updated list in terms query
106-
if (this.state.selectedItems.length) {
107-
this.props.onSelect(this.state.selectedItems);
108-
}
10981
}
11082

11183
render() {
11284
const items = this.props.items;
113-
const selectedItems = this.state.selectedItems;
11485
const ListItemsArray = [];
115-
const TagItemsArray = [];
11686
// Build the array for the checkboxList items
11787
items.forEach((item, index) => {
11888
try {
@@ -140,29 +110,12 @@ export class ItemCheckboxList extends Component {
140110
countField={false}
141111
handleClick={this.handleListClickAll}
142112
status={this.props.defaultSelectall || false}
143-
ref={"refselectall"}
144113
/>
145114
);
146115
}
147-
// Build the array of Tags for selected items
148-
if (this.props.showTags && selectedItems) {
149-
selectedItems.forEach((item) => {
150-
TagItemsArray.push(<Tag
151-
key={item}
152-
value={item}
153-
onClick={this.handleTagClick}
154-
/>);
155-
});
156-
}
116+
157117
return (
158118
<div className="rbc-list-container col s12 col-xs-12">
159-
{
160-
TagItemsArray.length ?
161-
<div className="row">
162-
{TagItemsArray}
163-
</div> :
164-
null
165-
}
166119
<div className="row">
167120
{ListItemsArray}
168121
</div>
@@ -171,26 +124,17 @@ export class ItemCheckboxList extends Component {
171124
}
172125
}
173126

174-
ItemCheckboxList.defaultProps = {
175-
showTags: true
176-
};
177-
178127
class ListItem extends Component {
179128
constructor(props) {
180129
super(props);
130+
181131
this.state = {
182-
initialStatus: this.props.status,
183-
status: this.props.status || false
132+
initialStatus: props.status,
133+
status: props.status || false
184134
};
185-
}
186135

187-
componentDidUpdate() {
188-
if (this.props.status !== this.state.initialStatus) {
189-
this.setState({
190-
status: this.props.status,
191-
initialStatus: this.props.status
192-
});
193-
}
136+
this.handleClick = this.handleClick.bind(this);
137+
this.handleCheckboxChange = this.handleCheckboxChange.bind(this);
194138
}
195139

196140
handleClick() {
@@ -213,29 +157,14 @@ class ListItem extends Component {
213157
count = <span> ({this.props.doc_count}) </span>;
214158
}
215159
return (
216-
<div onClick={this.handleClick.bind(this)} className="rbc-list-item rbc-checkbox-item col s12 col-xs-12">
160+
<div onClick={this.handleClick} className="rbc-list-item rbc-checkbox-item col s12 col-xs-12">
217161
<input
218162
type="checkbox"
219163
checked={this.state.status}
220-
onChange={this.handleCheckboxChange.bind(this)}
164+
onChange={this.handleCheckboxChange}
221165
/>
222166
<label> {this.props.value} {count}</label>
223167
</div>
224168
);
225169
}
226170
}
227-
228-
class Tag extends Component {
229-
constructor(props) {
230-
super(props);
231-
}
232-
233-
render() {
234-
return (
235-
<span onClick={this.props.onClick.bind(null, this.props.value)} className="tag-item col">
236-
<a href="javascript:void(0)" className="close"> x </a>
237-
<span>{this.props.value}</span>
238-
</span>
239-
);
240-
}
241-
}

app/addons/MapStyles.js

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
1-
import { default as React, Component } from "react";
2-
import { render } from "react-dom";
3-
import {
4-
AppbaseSensorHelper
5-
} from "@appbaseio/reactivebase";
1+
import React, { Component } from "react";
62

73
export const mapStylesCollection = [{
84
key: "Standard",
@@ -28,7 +24,7 @@ export const mapStylesCollection = [{
2824
}];
2925

3026
export class MapStyles extends Component {
31-
constructor(props, context) {
27+
constructor(props) {
3228
super(props);
3329
this.state = {
3430
items: []
@@ -60,13 +56,13 @@ export class MapStyles extends Component {
6056
});
6157
}
6258

63-
themeChanged(isExecute = false) {
59+
themeChanged() {
6460
const style = mapStylesCollection[this.state.selectedValue].value;
6561
this.props.mapStyleChange(style);
6662
}
6763

6864
render() {
69-
const options = this.state.items.map((item, index) => <option value={index} key={index}>{item.key}</option>);
65+
const options = this.state.items.map((item, index) => <option value={index} key={item.key}>{item.key}</option>);
7066
return (
7167
<div className="input-field col rbc-mapstyles pull-right right">
7268
<select className="browser-default form-control" onChange={this.handleSelect} value={this.state.selectedValue} name="mapStyles" id="mapStyles">
@@ -77,9 +73,6 @@ export class MapStyles extends Component {
7773
}
7874
}
7975

80-
MapStyles.propTypes = {
81-
};
82-
8376
// Default props value
8477
MapStyles.defaultProps = {
8578
fieldName: "MapStyles"

app/addons/SearchAsMove.js

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,23 @@
1-
import { default as React, Component } from "react";
2-
import { ItemCheckboxList } from "./ItemCheckboxList.js";
1+
import React, { Component } from "react";
32
import { AppbaseSensorHelper } from "@appbaseio/reactivebase";
3+
import ItemCheckboxList from "./ItemCheckboxList";
44

5-
export class SearchAsMove extends Component {
6-
constructor(props, context) {
5+
export default class SearchAsMove extends Component {
6+
constructor(props) {
77
super(props);
8+
89
this.state = {
9-
items: []
10+
items: [{
11+
key: "Search as I move the map",
12+
value: true,
13+
status: props.searchAsMoveDefault
14+
}]
1015
};
16+
1117
this.handleSelect = this.handleSelect.bind(this);
12-
this.handleRemove = this.handleRemove.bind(this);
1318
}
1419

1520
componentDidMount() {
16-
this.setState({
17-
items: [{
18-
key: "Search as I move the map",
19-
value: true,
20-
status: this.props.searchAsMoveDefault
21-
}]
22-
});
2321
if (this.props.searchAsMoveDefault && this.props.searchAsMoveDefault === true) {
2422
this.handleSelect(this.props.searchAsMoveDefault);
2523
}
@@ -31,17 +29,11 @@ export class SearchAsMove extends Component {
3129
this.props.searchAsMoveChange(flag);
3230
}
3331

34-
// Handler function when a value is deselected or removed
35-
handleRemove(value) {
36-
}
37-
3832
render() {
39-
let listComponent;
40-
listComponent = (<ItemCheckboxList
33+
const listComponent = (<ItemCheckboxList
4134
showTags={false}
4235
items={this.state.items}
4336
onSelect={this.handleSelect}
44-
onRemove={this.handleRemove}
4537
showCount={this.props.showCount}
4638
/>);
4739

0 commit comments

Comments
 (0)