@corpsmap/corpsmap 3.0.19 → 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/dev.js +27 -13
- package/lib/prod.js +27 -13
- package/package.json +87 -87
- package/src/application-bundles/search-bundle.js +77 -45
package/lib/dev.js
CHANGED
|
@@ -105538,11 +105538,11 @@ var primaryPanelBundle = createContainerBundle({
|
|
|
105538
105538
|
});
|
|
105539
105539
|
|
|
105540
105540
|
var searchBundle = {
|
|
105541
|
-
name:
|
|
105541
|
+
name: "search",
|
|
105542
105542
|
getReducer: function getReducer() {
|
|
105543
105543
|
var initialData = {
|
|
105544
105544
|
shouldFireSearch: false,
|
|
105545
|
-
q:
|
|
105545
|
+
q: "",
|
|
105546
105546
|
selected: null,
|
|
105547
105547
|
onFireSearchListeners: [],
|
|
105548
105548
|
results: []
|
|
@@ -105554,7 +105554,7 @@ var searchBundle = {
|
|
|
105554
105554
|
type = _ref.type,
|
|
105555
105555
|
payload = _ref.payload;
|
|
105556
105556
|
|
|
105557
|
-
if (type.indexOf(
|
|
105557
|
+
if (type.indexOf("SEARCH_") !== -1) {
|
|
105558
105558
|
return Object.assign({}, state, payload);
|
|
105559
105559
|
}
|
|
105560
105560
|
|
|
@@ -105568,7 +105568,7 @@ var searchBundle = {
|
|
|
105568
105568
|
var listeners = store.selectSearchOnFireSearchListeners();
|
|
105569
105569
|
if (options.onFireSearch) listeners.push(options.onFireSearch);
|
|
105570
105570
|
dispatch({
|
|
105571
|
-
type:
|
|
105571
|
+
type: "SEARCH_COLLECTION_ADDED",
|
|
105572
105572
|
payload: {
|
|
105573
105573
|
onFireSearchListeners: listeners
|
|
105574
105574
|
}
|
|
@@ -105579,7 +105579,7 @@ var searchBundle = {
|
|
|
105579
105579
|
return function (_ref3) {
|
|
105580
105580
|
var dispatch = _ref3.dispatch;
|
|
105581
105581
|
dispatch({
|
|
105582
|
-
type:
|
|
105582
|
+
type: "SEARCH_SHOULD_FIRE",
|
|
105583
105583
|
payload: {
|
|
105584
105584
|
shouldFire: true
|
|
105585
105585
|
}
|
|
@@ -105591,7 +105591,7 @@ var searchBundle = {
|
|
|
105591
105591
|
var dispatch = _ref4.dispatch,
|
|
105592
105592
|
store = _ref4.store;
|
|
105593
105593
|
dispatch({
|
|
105594
|
-
type:
|
|
105594
|
+
type: "SEARCH_SET_QUERY",
|
|
105595
105595
|
payload: {
|
|
105596
105596
|
q: q,
|
|
105597
105597
|
results: []
|
|
@@ -105603,7 +105603,7 @@ var searchBundle = {
|
|
|
105603
105603
|
return function (_ref5) {
|
|
105604
105604
|
var dispatch = _ref5.dispatch;
|
|
105605
105605
|
dispatch({
|
|
105606
|
-
type:
|
|
105606
|
+
type: "SEARCH_ITEM_SELECTED",
|
|
105607
105607
|
payload: {
|
|
105608
105608
|
selected: item
|
|
105609
105609
|
}
|
|
@@ -105615,7 +105615,7 @@ var searchBundle = {
|
|
|
105615
105615
|
var dispatch = _ref6.dispatch,
|
|
105616
105616
|
store = _ref6.store;
|
|
105617
105617
|
dispatch({
|
|
105618
|
-
type:
|
|
105618
|
+
type: "SEARCH_START",
|
|
105619
105619
|
payload: {
|
|
105620
105620
|
shouldFire: false
|
|
105621
105621
|
}
|
|
@@ -105623,7 +105623,7 @@ var searchBundle = {
|
|
|
105623
105623
|
var listeners = store.selectSearchOnFireSearchListeners();
|
|
105624
105624
|
async$1.parallel(listeners, function (err, r) {
|
|
105625
105625
|
if (err) return dispatch({
|
|
105626
|
-
type:
|
|
105626
|
+
type: "SEARCH_ERROR",
|
|
105627
105627
|
payload: {
|
|
105628
105628
|
err: err,
|
|
105629
105629
|
results: []
|
|
@@ -105632,10 +105632,24 @@ var searchBundle = {
|
|
|
105632
105632
|
|
|
105633
105633
|
var results = lodash.flatten(r);
|
|
105634
105634
|
|
|
105635
|
+
var sortedResultsGeo = [];
|
|
105636
|
+
var sortedResultsWMS = [];
|
|
105637
|
+
results.forEach(function (result) {
|
|
105638
|
+
if (result.provider !== "geocoder") {
|
|
105639
|
+
sortedResultsWMS.push(result);
|
|
105640
|
+
}
|
|
105641
|
+
|
|
105642
|
+
if (result.provider === "geocoder") {
|
|
105643
|
+
sortedResultsGeo.push(result);
|
|
105644
|
+
}
|
|
105645
|
+
});
|
|
105646
|
+
var sortedResults = [].concat(sortedResultsWMS, sortedResultsGeo); // Delete below after Testing
|
|
105647
|
+
|
|
105648
|
+
console.log(sortedResults);
|
|
105635
105649
|
dispatch({
|
|
105636
|
-
type:
|
|
105650
|
+
type: "SEARCH_SUCCESS",
|
|
105637
105651
|
payload: {
|
|
105638
|
-
results:
|
|
105652
|
+
results: sortedResults
|
|
105639
105653
|
}
|
|
105640
105654
|
});
|
|
105641
105655
|
});
|
|
@@ -105652,7 +105666,7 @@ var searchBundle = {
|
|
|
105652
105666
|
},
|
|
105653
105667
|
reactSearchShouldFire: function reactSearchShouldFire(state) {
|
|
105654
105668
|
if (state.search.shouldFire) return {
|
|
105655
|
-
actionCreator:
|
|
105669
|
+
actionCreator: "doSearchFire"
|
|
105656
105670
|
};
|
|
105657
105671
|
}
|
|
105658
105672
|
}; // => add collection, should have a name and implement the following api:
|
|
@@ -106470,7 +106484,7 @@ var config = {
|
|
|
106470
106484
|
};
|
|
106471
106485
|
|
|
106472
106486
|
var name = "@corpsmap/corpsmap";
|
|
106473
|
-
var version$1 = "3.0
|
|
106487
|
+
var version$1 = "3.1.0";
|
|
106474
106488
|
var description = "CorpsMap as React Components";
|
|
106475
106489
|
var main = "index.js";
|
|
106476
106490
|
var scripts = {
|
package/lib/prod.js
CHANGED
|
@@ -105452,11 +105452,11 @@ var primaryPanelBundle = createContainerBundle({
|
|
|
105452
105452
|
});
|
|
105453
105453
|
|
|
105454
105454
|
var searchBundle = {
|
|
105455
|
-
name:
|
|
105455
|
+
name: "search",
|
|
105456
105456
|
getReducer: function getReducer() {
|
|
105457
105457
|
var initialData = {
|
|
105458
105458
|
shouldFireSearch: false,
|
|
105459
|
-
q:
|
|
105459
|
+
q: "",
|
|
105460
105460
|
selected: null,
|
|
105461
105461
|
onFireSearchListeners: [],
|
|
105462
105462
|
results: []
|
|
@@ -105468,7 +105468,7 @@ var searchBundle = {
|
|
|
105468
105468
|
type = _ref.type,
|
|
105469
105469
|
payload = _ref.payload;
|
|
105470
105470
|
|
|
105471
|
-
if (type.indexOf(
|
|
105471
|
+
if (type.indexOf("SEARCH_") !== -1) {
|
|
105472
105472
|
return Object.assign({}, state, payload);
|
|
105473
105473
|
}
|
|
105474
105474
|
|
|
@@ -105482,7 +105482,7 @@ var searchBundle = {
|
|
|
105482
105482
|
var listeners = store.selectSearchOnFireSearchListeners();
|
|
105483
105483
|
if (options.onFireSearch) listeners.push(options.onFireSearch);
|
|
105484
105484
|
dispatch({
|
|
105485
|
-
type:
|
|
105485
|
+
type: "SEARCH_COLLECTION_ADDED",
|
|
105486
105486
|
payload: {
|
|
105487
105487
|
onFireSearchListeners: listeners
|
|
105488
105488
|
}
|
|
@@ -105493,7 +105493,7 @@ var searchBundle = {
|
|
|
105493
105493
|
return function (_ref3) {
|
|
105494
105494
|
var dispatch = _ref3.dispatch;
|
|
105495
105495
|
dispatch({
|
|
105496
|
-
type:
|
|
105496
|
+
type: "SEARCH_SHOULD_FIRE",
|
|
105497
105497
|
payload: {
|
|
105498
105498
|
shouldFire: true
|
|
105499
105499
|
}
|
|
@@ -105505,7 +105505,7 @@ var searchBundle = {
|
|
|
105505
105505
|
var dispatch = _ref4.dispatch,
|
|
105506
105506
|
store = _ref4.store;
|
|
105507
105507
|
dispatch({
|
|
105508
|
-
type:
|
|
105508
|
+
type: "SEARCH_SET_QUERY",
|
|
105509
105509
|
payload: {
|
|
105510
105510
|
q: q,
|
|
105511
105511
|
results: []
|
|
@@ -105517,7 +105517,7 @@ var searchBundle = {
|
|
|
105517
105517
|
return function (_ref5) {
|
|
105518
105518
|
var dispatch = _ref5.dispatch;
|
|
105519
105519
|
dispatch({
|
|
105520
|
-
type:
|
|
105520
|
+
type: "SEARCH_ITEM_SELECTED",
|
|
105521
105521
|
payload: {
|
|
105522
105522
|
selected: item
|
|
105523
105523
|
}
|
|
@@ -105529,7 +105529,7 @@ var searchBundle = {
|
|
|
105529
105529
|
var dispatch = _ref6.dispatch,
|
|
105530
105530
|
store = _ref6.store;
|
|
105531
105531
|
dispatch({
|
|
105532
|
-
type:
|
|
105532
|
+
type: "SEARCH_START",
|
|
105533
105533
|
payload: {
|
|
105534
105534
|
shouldFire: false
|
|
105535
105535
|
}
|
|
@@ -105537,7 +105537,7 @@ var searchBundle = {
|
|
|
105537
105537
|
var listeners = store.selectSearchOnFireSearchListeners();
|
|
105538
105538
|
async$1.parallel(listeners, function (err, r) {
|
|
105539
105539
|
if (err) return dispatch({
|
|
105540
|
-
type:
|
|
105540
|
+
type: "SEARCH_ERROR",
|
|
105541
105541
|
payload: {
|
|
105542
105542
|
err: err,
|
|
105543
105543
|
results: []
|
|
@@ -105546,10 +105546,24 @@ var searchBundle = {
|
|
|
105546
105546
|
|
|
105547
105547
|
var results = lodash.flatten(r);
|
|
105548
105548
|
|
|
105549
|
+
var sortedResultsGeo = [];
|
|
105550
|
+
var sortedResultsWMS = [];
|
|
105551
|
+
results.forEach(function (result) {
|
|
105552
|
+
if (result.provider !== "geocoder") {
|
|
105553
|
+
sortedResultsWMS.push(result);
|
|
105554
|
+
}
|
|
105555
|
+
|
|
105556
|
+
if (result.provider === "geocoder") {
|
|
105557
|
+
sortedResultsGeo.push(result);
|
|
105558
|
+
}
|
|
105559
|
+
});
|
|
105560
|
+
var sortedResults = [].concat(sortedResultsWMS, sortedResultsGeo); // Delete below after Testing
|
|
105561
|
+
|
|
105562
|
+
console.log(sortedResults);
|
|
105549
105563
|
dispatch({
|
|
105550
|
-
type:
|
|
105564
|
+
type: "SEARCH_SUCCESS",
|
|
105551
105565
|
payload: {
|
|
105552
|
-
results:
|
|
105566
|
+
results: sortedResults
|
|
105553
105567
|
}
|
|
105554
105568
|
});
|
|
105555
105569
|
});
|
|
@@ -105566,7 +105580,7 @@ var searchBundle = {
|
|
|
105566
105580
|
},
|
|
105567
105581
|
reactSearchShouldFire: function reactSearchShouldFire(state) {
|
|
105568
105582
|
if (state.search.shouldFire) return {
|
|
105569
|
-
actionCreator:
|
|
105583
|
+
actionCreator: "doSearchFire"
|
|
105570
105584
|
};
|
|
105571
105585
|
}
|
|
105572
105586
|
}; // => add collection, should have a name and implement the following api:
|
|
@@ -106384,7 +106398,7 @@ var config = {
|
|
|
106384
106398
|
};
|
|
106385
106399
|
|
|
106386
106400
|
var name = "@corpsmap/corpsmap";
|
|
106387
|
-
var version$1 = "3.0
|
|
106401
|
+
var version$1 = "3.1.0";
|
|
106388
106402
|
var description = "CorpsMap as React Components";
|
|
106389
106403
|
var main = "index.js";
|
|
106390
106404
|
var scripts = {
|
package/package.json
CHANGED
|
@@ -1,87 +1,87 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@corpsmap/corpsmap",
|
|
3
|
-
"version": "3.0
|
|
4
|
-
"description": "CorpsMap as React Components",
|
|
5
|
-
"main": "index.js",
|
|
6
|
-
"scripts": {
|
|
7
|
-
"prepublishOnly": "npm run release",
|
|
8
|
-
"release": "npm run build:dev && npm run build:prod",
|
|
9
|
-
"build:dev": "cross-env NODE_ENV=development rollup -c",
|
|
10
|
-
"build:prod": "cross-env NODE_ENV=production rollup -c",
|
|
11
|
-
"dev": "cross-env NODE_ENV=development rollup -c --watch",
|
|
12
|
-
"test": "echo \"Error: no test specified\" && exit 1",
|
|
13
|
-
"sample-app": "wait-on file:lib/dev.js && (cd ../corpsmap-test-app && npm run start)",
|
|
14
|
-
"dev-n-sample": "concurrently \"npm run dev\" \"npm run sample-app\""
|
|
15
|
-
},
|
|
16
|
-
"author": "willbreitkreutz",
|
|
17
|
-
"license": "MIT",
|
|
18
|
-
"devDependencies": {
|
|
19
|
-
"@babel/core": "^7.5.5",
|
|
20
|
-
"@babel/plugin-proposal-class-properties": "^7.5.5",
|
|
21
|
-
"@babel/preset-env": "^7.5.5",
|
|
22
|
-
"@babel/preset-react": "^7.0.0",
|
|
23
|
-
"babel-plugin-import": "^1.12.2",
|
|
24
|
-
"concurrently": "^5.3.0",
|
|
25
|
-
"cross-env": "^5.2.0",
|
|
26
|
-
"react": "^16.9.0",
|
|
27
|
-
"react-dom": "^16.9.0",
|
|
28
|
-
"rollup": "^1.20.2",
|
|
29
|
-
"rollup-plugin-babel": "^4.3.3",
|
|
30
|
-
"rollup-plugin-commonjs": "^10.1.0",
|
|
31
|
-
"rollup-plugin-css-only": "^1.0.0",
|
|
32
|
-
"rollup-plugin-json": "^4.0.0",
|
|
33
|
-
"rollup-plugin-node-resolve": "^5.2.0",
|
|
34
|
-
"rollup-plugin-postcss": "^2.0.3",
|
|
35
|
-
"rollup-plugin-replace": "^2.2.0",
|
|
36
|
-
"styled-jsx": "^3.2.1",
|
|
37
|
-
"wait-on": "^5.2.1"
|
|
38
|
-
},
|
|
39
|
-
"peerDependencies": {
|
|
40
|
-
"react": ">= 16.x.x",
|
|
41
|
-
"react-dom": ">=16.x.x"
|
|
42
|
-
},
|
|
43
|
-
"dependencies": {
|
|
44
|
-
"@mapbox/togeojson": "^0.16.0",
|
|
45
|
-
"@turf/bbox": "^6.0.1",
|
|
46
|
-
"@turf/bbox-polygon": "^6.0.1",
|
|
47
|
-
"@turf/boolean-crosses": "^6.0.1",
|
|
48
|
-
"@turf/boolean-disjoint": "^6.0.2",
|
|
49
|
-
"@turf/boolean-point-in-polygon": "^6.0.1",
|
|
50
|
-
"@turf/buffer": "^5.1.5",
|
|
51
|
-
"@turf/center-of-mass": "^6.0.1",
|
|
52
|
-
"@turf/centroid": "^6.0.2",
|
|
53
|
-
"@turf/distance": "^6.0.1",
|
|
54
|
-
"@turf/flatten": "^5.1.5",
|
|
55
|
-
"@turf/helpers": "^6.1.4",
|
|
56
|
-
"@turf/length": "^6.0.2",
|
|
57
|
-
"@turf/line-slice": "^5.1.5",
|
|
58
|
-
"async": "^2.6.1",
|
|
59
|
-
"classnames": "^2.2.5",
|
|
60
|
-
"css": "^2.2.4",
|
|
61
|
-
"decompress": "^4.2.1",
|
|
62
|
-
"extract-files": "^12.0.0",
|
|
63
|
-
"file-saver": "^2.0.2",
|
|
64
|
-
"is-html": "^2.0.0",
|
|
65
|
-
"jspdf": "^1.5.3",
|
|
66
|
-
"kmljs": "0.0.1",
|
|
67
|
-
"lodash": "^4.17.15",
|
|
68
|
-
"markdown-it": "^12.0.3",
|
|
69
|
-
"moment": "^2.24.0",
|
|
70
|
-
"money-clip": "^3.0.1",
|
|
71
|
-
"ol": "^6.4.3",
|
|
72
|
-
"ol-esri-style": "^2.0.7",
|
|
73
|
-
"parse2-kmz": "^1.0.5",
|
|
74
|
-
"proj4": "^2.4.4",
|
|
75
|
-
"react-data-grid": "^6.1.0",
|
|
76
|
-
"react-datepicker": "^2.9.6",
|
|
77
|
-
"react-dnd": "^9.4.0",
|
|
78
|
-
"react-dnd-html5-backend": "^9.4.0",
|
|
79
|
-
"react-notification-system": "^0.2.17",
|
|
80
|
-
"react-split": "^2.0.7",
|
|
81
|
-
"redux-bundler": "^26.0.0",
|
|
82
|
-
"redux-bundler-react": "^1.2.0",
|
|
83
|
-
"shpjs": "^3.4.3",
|
|
84
|
-
"uuid": "^3.3.3",
|
|
85
|
-
"xhr": "^2.5.0"
|
|
86
|
-
}
|
|
87
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@corpsmap/corpsmap",
|
|
3
|
+
"version": "3.1.0",
|
|
4
|
+
"description": "CorpsMap as React Components",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"prepublishOnly": "npm run release",
|
|
8
|
+
"release": "npm run build:dev && npm run build:prod",
|
|
9
|
+
"build:dev": "cross-env NODE_ENV=development rollup -c",
|
|
10
|
+
"build:prod": "cross-env NODE_ENV=production rollup -c",
|
|
11
|
+
"dev": "cross-env NODE_ENV=development rollup -c --watch",
|
|
12
|
+
"test": "echo \"Error: no test specified\" && exit 1",
|
|
13
|
+
"sample-app": "wait-on file:lib/dev.js && (cd ../corpsmap-test-app && npm run start)",
|
|
14
|
+
"dev-n-sample": "concurrently \"npm run dev\" \"npm run sample-app\""
|
|
15
|
+
},
|
|
16
|
+
"author": "willbreitkreutz",
|
|
17
|
+
"license": "MIT",
|
|
18
|
+
"devDependencies": {
|
|
19
|
+
"@babel/core": "^7.5.5",
|
|
20
|
+
"@babel/plugin-proposal-class-properties": "^7.5.5",
|
|
21
|
+
"@babel/preset-env": "^7.5.5",
|
|
22
|
+
"@babel/preset-react": "^7.0.0",
|
|
23
|
+
"babel-plugin-import": "^1.12.2",
|
|
24
|
+
"concurrently": "^5.3.0",
|
|
25
|
+
"cross-env": "^5.2.0",
|
|
26
|
+
"react": "^16.9.0",
|
|
27
|
+
"react-dom": "^16.9.0",
|
|
28
|
+
"rollup": "^1.20.2",
|
|
29
|
+
"rollup-plugin-babel": "^4.3.3",
|
|
30
|
+
"rollup-plugin-commonjs": "^10.1.0",
|
|
31
|
+
"rollup-plugin-css-only": "^1.0.0",
|
|
32
|
+
"rollup-plugin-json": "^4.0.0",
|
|
33
|
+
"rollup-plugin-node-resolve": "^5.2.0",
|
|
34
|
+
"rollup-plugin-postcss": "^2.0.3",
|
|
35
|
+
"rollup-plugin-replace": "^2.2.0",
|
|
36
|
+
"styled-jsx": "^3.2.1",
|
|
37
|
+
"wait-on": "^5.2.1"
|
|
38
|
+
},
|
|
39
|
+
"peerDependencies": {
|
|
40
|
+
"react": ">= 16.x.x",
|
|
41
|
+
"react-dom": ">=16.x.x"
|
|
42
|
+
},
|
|
43
|
+
"dependencies": {
|
|
44
|
+
"@mapbox/togeojson": "^0.16.0",
|
|
45
|
+
"@turf/bbox": "^6.0.1",
|
|
46
|
+
"@turf/bbox-polygon": "^6.0.1",
|
|
47
|
+
"@turf/boolean-crosses": "^6.0.1",
|
|
48
|
+
"@turf/boolean-disjoint": "^6.0.2",
|
|
49
|
+
"@turf/boolean-point-in-polygon": "^6.0.1",
|
|
50
|
+
"@turf/buffer": "^5.1.5",
|
|
51
|
+
"@turf/center-of-mass": "^6.0.1",
|
|
52
|
+
"@turf/centroid": "^6.0.2",
|
|
53
|
+
"@turf/distance": "^6.0.1",
|
|
54
|
+
"@turf/flatten": "^5.1.5",
|
|
55
|
+
"@turf/helpers": "^6.1.4",
|
|
56
|
+
"@turf/length": "^6.0.2",
|
|
57
|
+
"@turf/line-slice": "^5.1.5",
|
|
58
|
+
"async": "^2.6.1",
|
|
59
|
+
"classnames": "^2.2.5",
|
|
60
|
+
"css": "^2.2.4",
|
|
61
|
+
"decompress": "^4.2.1",
|
|
62
|
+
"extract-files": "^12.0.0",
|
|
63
|
+
"file-saver": "^2.0.2",
|
|
64
|
+
"is-html": "^2.0.0",
|
|
65
|
+
"jspdf": "^1.5.3",
|
|
66
|
+
"kmljs": "0.0.1",
|
|
67
|
+
"lodash": "^4.17.15",
|
|
68
|
+
"markdown-it": "^12.0.3",
|
|
69
|
+
"moment": "^2.24.0",
|
|
70
|
+
"money-clip": "^3.0.1",
|
|
71
|
+
"ol": "^6.4.3",
|
|
72
|
+
"ol-esri-style": "^2.0.7",
|
|
73
|
+
"parse2-kmz": "^1.0.5",
|
|
74
|
+
"proj4": "^2.4.4",
|
|
75
|
+
"react-data-grid": "^6.1.0",
|
|
76
|
+
"react-datepicker": "^2.9.6",
|
|
77
|
+
"react-dnd": "^9.4.0",
|
|
78
|
+
"react-dnd-html5-backend": "^9.4.0",
|
|
79
|
+
"react-notification-system": "^0.2.17",
|
|
80
|
+
"react-split": "^2.0.7",
|
|
81
|
+
"redux-bundler": "^26.0.0",
|
|
82
|
+
"redux-bundler-react": "^1.2.0",
|
|
83
|
+
"shpjs": "^3.4.3",
|
|
84
|
+
"uuid": "^3.3.3",
|
|
85
|
+
"xhr": "^2.5.0"
|
|
86
|
+
}
|
|
87
|
+
}
|
|
@@ -1,58 +1,91 @@
|
|
|
1
|
-
import async from
|
|
2
|
-
import _ from
|
|
1
|
+
import async from "async";
|
|
2
|
+
import _ from "lodash";
|
|
3
3
|
|
|
4
4
|
export default {
|
|
5
|
-
name:
|
|
5
|
+
name: "search",
|
|
6
6
|
|
|
7
|
-
getReducer(){
|
|
7
|
+
getReducer() {
|
|
8
8
|
const initialData = {
|
|
9
9
|
shouldFireSearch: false,
|
|
10
|
-
q:
|
|
10
|
+
q: "",
|
|
11
11
|
selected: null,
|
|
12
12
|
onFireSearchListeners: [],
|
|
13
|
-
results: []
|
|
14
|
-
}
|
|
13
|
+
results: [],
|
|
14
|
+
};
|
|
15
15
|
|
|
16
|
-
return (state = initialData, {type, payload}) => {
|
|
17
|
-
if(type.indexOf(
|
|
16
|
+
return (state = initialData, { type, payload }) => {
|
|
17
|
+
if (type.indexOf("SEARCH_") !== -1) {
|
|
18
18
|
return Object.assign({}, state, payload);
|
|
19
19
|
}
|
|
20
20
|
return state;
|
|
21
|
-
}
|
|
21
|
+
};
|
|
22
22
|
},
|
|
23
23
|
|
|
24
|
-
doSearchAddCollection:
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
24
|
+
doSearchAddCollection:
|
|
25
|
+
(options) =>
|
|
26
|
+
({ dispatch, store }) => {
|
|
27
|
+
const listeners = store.selectSearchOnFireSearchListeners();
|
|
28
|
+
if (options.onFireSearch) listeners.push(options.onFireSearch);
|
|
29
|
+
dispatch({
|
|
30
|
+
type: "SEARCH_COLLECTION_ADDED",
|
|
31
|
+
payload: {
|
|
32
|
+
onFireSearchListeners: listeners,
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
},
|
|
36
|
+
|
|
37
|
+
doSearchShouldFire:
|
|
38
|
+
() =>
|
|
39
|
+
({ dispatch }) => {
|
|
40
|
+
dispatch({ type: "SEARCH_SHOULD_FIRE", payload: { shouldFire: true } });
|
|
41
|
+
},
|
|
42
|
+
|
|
43
|
+
doSearchSetQuery:
|
|
44
|
+
(q) =>
|
|
45
|
+
({ dispatch, store }) => {
|
|
46
|
+
dispatch({ type: "SEARCH_SET_QUERY", payload: { q: q, results: [] } });
|
|
47
|
+
},
|
|
48
|
+
|
|
49
|
+
doSearchSelectItem:
|
|
50
|
+
(item) =>
|
|
51
|
+
({ dispatch }) => {
|
|
52
|
+
dispatch({ type: "SEARCH_ITEM_SELECTED", payload: { selected: item } });
|
|
53
|
+
},
|
|
54
|
+
|
|
55
|
+
doSearchFire:
|
|
56
|
+
() =>
|
|
57
|
+
({ dispatch, store }) => {
|
|
58
|
+
dispatch({ type: "SEARCH_START", payload: { shouldFire: false } });
|
|
59
|
+
const listeners = store.selectSearchOnFireSearchListeners();
|
|
60
|
+
async.parallel(listeners, (err, r) => {
|
|
61
|
+
if (err)
|
|
62
|
+
return dispatch({
|
|
63
|
+
type: "SEARCH_ERROR",
|
|
64
|
+
payload: { err: err, results: [] },
|
|
65
|
+
});
|
|
51
66
|
const results = _.flatten(r);
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
67
|
+
|
|
68
|
+
const sortedResultsGeo = [];
|
|
69
|
+
const sortedResultsWMS = [];
|
|
70
|
+
results.forEach((result) => {
|
|
71
|
+
if (result.provider !== "geocoder") {
|
|
72
|
+
sortedResultsWMS.push(result);
|
|
73
|
+
}
|
|
74
|
+
if (result.provider === "geocoder") {
|
|
75
|
+
sortedResultsGeo.push(result);
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
const sortedResults = [...sortedResultsWMS, ...sortedResultsGeo];
|
|
80
|
+
// Delete below after Testing
|
|
81
|
+
console.log(sortedResults);
|
|
82
|
+
|
|
83
|
+
dispatch({
|
|
84
|
+
type: "SEARCH_SUCCESS",
|
|
85
|
+
payload: { results: sortedResults },
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
},
|
|
56
89
|
|
|
57
90
|
selectSearchOnFireSearchListeners: (state) => {
|
|
58
91
|
return state.search.onFireSearchListeners;
|
|
@@ -67,9 +100,9 @@ export default {
|
|
|
67
100
|
},
|
|
68
101
|
|
|
69
102
|
reactSearchShouldFire: (state) => {
|
|
70
|
-
if(state.search.shouldFire) return { actionCreator:
|
|
71
|
-
}
|
|
72
|
-
}
|
|
103
|
+
if (state.search.shouldFire) return { actionCreator: "doSearchFire" };
|
|
104
|
+
},
|
|
105
|
+
};
|
|
73
106
|
|
|
74
107
|
// => add collection, should have a name and implement the following api:
|
|
75
108
|
|
|
@@ -88,4 +121,3 @@ export default {
|
|
|
88
121
|
// geometry: <object>, // geojson geometry
|
|
89
122
|
// properties: <object> // geojson properties
|
|
90
123
|
// }
|
|
91
|
-
|