@appbaseio/reactivesearch-vue 1.16.0-alpha.36 → 1.16.0-alpha.39
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/dist/@appbaseio/reactivesearch-vue.umd.js +471 -904
- package/dist/@appbaseio/reactivesearch-vue.umd.js.map +1 -1
- package/dist/@appbaseio/reactivesearch-vue.umd.min.js +5 -5
- package/dist/@appbaseio/reactivesearch-vue.umd.min.js.map +1 -1
- package/dist/cjs/DataSearch.js +13 -7
- package/dist/cjs/DynamicRangeSlider.js +23 -14
- package/dist/cjs/MultiDropdownList.js +22 -17
- package/dist/cjs/MultiList.js +22 -16
- package/dist/cjs/ReactiveComponent.js +31 -61
- package/dist/cjs/ReactiveList.js +47 -47
- package/dist/cjs/SingleDropdownList.js +17 -12
- package/dist/cjs/SingleList.js +16 -11
- package/dist/cjs/initReactivesearch.js +119 -78
- package/dist/cjs/version.js +1 -1
- package/dist/es/DataSearch.js +13 -7
- package/dist/es/DynamicRangeSlider.js +23 -14
- package/dist/es/MultiDropdownList.js +22 -17
- package/dist/es/MultiList.js +22 -16
- package/dist/es/ReactiveComponent.js +31 -61
- package/dist/es/ReactiveList.js +47 -47
- package/dist/es/SingleDropdownList.js +17 -12
- package/dist/es/SingleList.js +16 -11
- package/dist/es/initReactivesearch.js +121 -80
- package/dist/es/version.js +1 -1
- package/package.json +3 -3
package/dist/cjs/ReactiveList.js
CHANGED
|
@@ -272,9 +272,10 @@ var isEqual$1 = configureStore.helper.isEqual,
|
|
|
272
272
|
getQueryOptions = configureStore.helper.getQueryOptions,
|
|
273
273
|
getClassName = configureStore.helper.getClassName,
|
|
274
274
|
parseHits = configureStore.helper.parseHits,
|
|
275
|
-
getOptionsFromQuery = configureStore.helper.getOptionsFromQuery,
|
|
276
275
|
getCompositeAggsQuery = configureStore.helper.getCompositeAggsQuery,
|
|
277
|
-
getResultStats = configureStore.helper.getResultStats
|
|
276
|
+
getResultStats = configureStore.helper.getResultStats,
|
|
277
|
+
extractQueryFromCustomQuery = configureStore.helper.extractQueryFromCustomQuery,
|
|
278
|
+
getOptionsForCustomQuery = configureStore.helper.getOptionsForCustomQuery;
|
|
278
279
|
var ReactiveList = {
|
|
279
280
|
name: 'ReactiveList',
|
|
280
281
|
components: {
|
|
@@ -337,6 +338,12 @@ var ReactiveList = {
|
|
|
337
338
|
});
|
|
338
339
|
}
|
|
339
340
|
|
|
341
|
+
if (this.urlSortOption) {
|
|
342
|
+
this.sortOptionIndex = this.$props.sortOptions.findIndex(function (s) {
|
|
343
|
+
return s.label === _this.urlSortOption;
|
|
344
|
+
}) || 0;
|
|
345
|
+
}
|
|
346
|
+
|
|
340
347
|
this.updateComponentProps(this.componentId, {
|
|
341
348
|
from: this.from
|
|
342
349
|
}, constants.componentTypes.reactiveList);
|
|
@@ -466,19 +473,11 @@ var ReactiveList = {
|
|
|
466
473
|
var options = getQueryOptions(this.$props);
|
|
467
474
|
options.from = 0;
|
|
468
475
|
this.$defaultQuery = newVal(null, this.$props);
|
|
469
|
-
|
|
470
|
-
var
|
|
471
|
-
sort = _ref.sort,
|
|
472
|
-
query = _ref.query;
|
|
473
|
-
|
|
474
|
-
if (sort) {
|
|
475
|
-
options.sort = this.$defaultQuery.sort;
|
|
476
|
-
}
|
|
477
|
-
|
|
478
|
-
var queryOptions = getOptionsFromQuery(this.$defaultQuery);
|
|
476
|
+
var query = extractQueryFromCustomQuery(this.$defaultQuery);
|
|
477
|
+
var queryOptions = getOptionsForCustomQuery(this.$defaultQuery);
|
|
479
478
|
|
|
480
479
|
if (queryOptions) {
|
|
481
|
-
options = _rollupPluginBabelHelpers._extends({}, options,
|
|
480
|
+
options = _rollupPluginBabelHelpers._extends({}, options, queryOptions);
|
|
482
481
|
} // Update calculated default query in store
|
|
483
482
|
|
|
484
483
|
|
|
@@ -569,24 +568,24 @@ var ReactiveList = {
|
|
|
569
568
|
options.from = this.$data.from;
|
|
570
569
|
|
|
571
570
|
if (this.sortOptions && this.sortOptions[this.sortOptionIndex]) {
|
|
572
|
-
var
|
|
571
|
+
var _ref;
|
|
573
572
|
|
|
574
573
|
var sortField = this.sortOptions[this.sortOptionIndex].dataField;
|
|
575
574
|
var sortBy = this.sortOptions[this.sortOptionIndex].sortBy;
|
|
576
|
-
options.sort = [(
|
|
575
|
+
options.sort = [(_ref = {}, _ref[sortField] = {
|
|
577
576
|
order: sortBy
|
|
578
|
-
},
|
|
577
|
+
}, _ref)]; // To handle sort options for RS API
|
|
579
578
|
|
|
580
579
|
this.updateComponentProps(this.componentId, {
|
|
581
580
|
dataField: sortField,
|
|
582
581
|
sortBy: sortBy
|
|
583
582
|
}, constants.componentTypes.reactiveList);
|
|
584
583
|
} else if (this.$props.sortBy) {
|
|
585
|
-
var
|
|
584
|
+
var _ref2;
|
|
586
585
|
|
|
587
|
-
options.sort = [(
|
|
586
|
+
options.sort = [(_ref2 = {}, _ref2[this.$props.dataField] = {
|
|
588
587
|
order: this.$props.sortBy
|
|
589
|
-
},
|
|
588
|
+
}, _ref2)];
|
|
590
589
|
} // Override sort query with defaultQuery's sort if defined
|
|
591
590
|
|
|
592
591
|
|
|
@@ -594,20 +593,13 @@ var ReactiveList = {
|
|
|
594
593
|
|
|
595
594
|
if (this.$props.defaultQuery) {
|
|
596
595
|
this.$defaultQuery = this.$props.defaultQuery();
|
|
597
|
-
options = _rollupPluginBabelHelpers._extends({}, options,
|
|
598
|
-
|
|
599
|
-
if (this.$defaultQuery.sort) {
|
|
600
|
-
options.sort = this.$defaultQuery.sort;
|
|
601
|
-
} // Update calculated default query in store
|
|
602
|
-
|
|
596
|
+
options = _rollupPluginBabelHelpers._extends({}, options, getOptionsForCustomQuery(this.$defaultQuery)); // Update calculated default query in store
|
|
603
597
|
|
|
604
598
|
index.updateDefaultQuery(this.componentId, this.setDefaultQuery, this.$props);
|
|
605
599
|
} // execute is set to false at the time of mount
|
|
606
600
|
|
|
607
601
|
|
|
608
|
-
var
|
|
609
|
-
query = _ref4.query;
|
|
610
|
-
|
|
602
|
+
var query = extractQueryFromCustomQuery(this.$defaultQuery);
|
|
611
603
|
var execute = false;
|
|
612
604
|
this.setQueryOptions(this.$props.componentId, _rollupPluginBabelHelpers._extends({}, options, this.getAggsQuery()), execute);
|
|
613
605
|
|
|
@@ -722,18 +714,18 @@ var ReactiveList = {
|
|
|
722
714
|
}) : 0;
|
|
723
715
|
|
|
724
716
|
if (props.sortOptions[sortOptionIndex]) {
|
|
725
|
-
var
|
|
717
|
+
var _ref3;
|
|
726
718
|
|
|
727
|
-
options.sort = [(
|
|
719
|
+
options.sort = [(_ref3 = {}, _ref3[props.sortOptions[sortOptionIndex].dataField] = {
|
|
728
720
|
order: props.sortOptions[sortOptionIndex].sortBy
|
|
729
|
-
},
|
|
721
|
+
}, _ref3)];
|
|
730
722
|
}
|
|
731
723
|
} else if (props.sortBy) {
|
|
732
|
-
var
|
|
724
|
+
var _ref4;
|
|
733
725
|
|
|
734
|
-
options.sort = [(
|
|
726
|
+
options.sort = [(_ref4 = {}, _ref4[props.dataField] = {
|
|
735
727
|
order: props.sortBy
|
|
736
|
-
},
|
|
728
|
+
}, _ref4)];
|
|
737
729
|
}
|
|
738
730
|
|
|
739
731
|
this.setQueryOptions(this.$props.componentId, _rollupPluginBabelHelpers._extends({}, options, this.getAggsQuery()), true);
|
|
@@ -836,16 +828,16 @@ var ReactiveList = {
|
|
|
836
828
|
var index = e.target.value;
|
|
837
829
|
|
|
838
830
|
if (this.sortOptions && this.sortOptions[index]) {
|
|
839
|
-
var
|
|
831
|
+
var _ref5;
|
|
840
832
|
|
|
841
833
|
// This fixes issue #371 (where sorting a multi-result page with infinite loader breaks)
|
|
842
834
|
var options = getQueryOptions(this.$props);
|
|
843
835
|
options.from = 0;
|
|
844
836
|
var sortField = this.sortOptions[index].dataField;
|
|
845
837
|
var sortBy = this.sortOptions[index].sortBy;
|
|
846
|
-
options.sort = [(
|
|
838
|
+
options.sort = [(_ref5 = {}, _ref5[sortField] = {
|
|
847
839
|
order: sortBy
|
|
848
|
-
},
|
|
840
|
+
}, _ref5)];
|
|
849
841
|
this.sortOptionIndex = index; // To handle sort options for RS API
|
|
850
842
|
|
|
851
843
|
this.updateComponentProps(this.componentId, {
|
|
@@ -853,8 +845,11 @@ var ReactiveList = {
|
|
|
853
845
|
sortBy: sortBy
|
|
854
846
|
}, constants.componentTypes.reactiveList);
|
|
855
847
|
this.setQueryOptions(this.$props.componentId, options, true);
|
|
848
|
+
this.setPage(0);
|
|
856
849
|
this.currentPageState = 0;
|
|
857
850
|
this.from = 0;
|
|
851
|
+
var sortOption = this.$props.sortOptions[this.sortOptionIndex] ? this.$props.sortOptions[this.sortOptionIndex].label : null;
|
|
852
|
+
this.setPageURL(this.$props.componentId + "sortOption", sortOption, this.$props.componentId + "sortOption", false, this.$props.URLParams);
|
|
858
853
|
}
|
|
859
854
|
},
|
|
860
855
|
triggerClickAnalytics: function triggerClickAnalytics(searchPosition, documentId) {
|
|
@@ -966,6 +961,7 @@ var ReactiveList = {
|
|
|
966
961
|
var mapStateToProps = function mapStateToProps(state, props) {
|
|
967
962
|
return {
|
|
968
963
|
defaultPage: state.selectedValues[props.componentId] && state.selectedValues[props.componentId].value - 1,
|
|
964
|
+
urlSortOption: state.selectedValues[props.componentId + "sortOption"] && state.selectedValues[props.componentId + "sortOption"].value,
|
|
969
965
|
hits: state.hits[props.componentId] && state.hits[props.componentId].hits,
|
|
970
966
|
rawData: state.rawData[props.componentId],
|
|
971
967
|
aggregationData: state.compositeAggregations[props.componentId],
|
|
@@ -1006,7 +1002,7 @@ ReactiveList.generateQueryOptions = function (props) {
|
|
|
1006
1002
|
options.size = size || 10;
|
|
1007
1003
|
|
|
1008
1004
|
var getSortOption = function getSortOption() {
|
|
1009
|
-
var
|
|
1005
|
+
var _ref7;
|
|
1010
1006
|
|
|
1011
1007
|
if (defaultSortOption) {
|
|
1012
1008
|
var sortOption = sortOptionsNew.find(function (option) {
|
|
@@ -1014,35 +1010,39 @@ ReactiveList.generateQueryOptions = function (props) {
|
|
|
1014
1010
|
});
|
|
1015
1011
|
|
|
1016
1012
|
if (sortOption) {
|
|
1017
|
-
var
|
|
1013
|
+
var _ref6;
|
|
1018
1014
|
|
|
1019
|
-
return
|
|
1015
|
+
return _ref6 = {}, _ref6[sortOption.dataField] = {
|
|
1020
1016
|
order: sortOption.sortBy
|
|
1021
|
-
},
|
|
1017
|
+
}, _ref6;
|
|
1022
1018
|
}
|
|
1023
1019
|
}
|
|
1024
1020
|
|
|
1025
|
-
return
|
|
1021
|
+
return _ref7 = {}, _ref7[sortOptionsNew[0].dataField] = {
|
|
1026
1022
|
order: sortOptionsNew[0].sortBy
|
|
1027
|
-
},
|
|
1023
|
+
}, _ref7;
|
|
1028
1024
|
};
|
|
1029
1025
|
|
|
1030
1026
|
if (sortOptionsNew) {
|
|
1031
1027
|
options.sort = [getSortOption()];
|
|
1032
1028
|
} else if (sortBy) {
|
|
1033
|
-
var
|
|
1029
|
+
var _ref8;
|
|
1034
1030
|
|
|
1035
|
-
options.sort = [(
|
|
1031
|
+
options.sort = [(_ref8 = {}, _ref8[dataField] = {
|
|
1036
1032
|
order: sortBy
|
|
1037
|
-
},
|
|
1033
|
+
}, _ref8)];
|
|
1038
1034
|
}
|
|
1039
1035
|
|
|
1040
1036
|
return options;
|
|
1041
1037
|
};
|
|
1042
1038
|
|
|
1039
|
+
ReactiveList.hasInternalComponent = function () {
|
|
1040
|
+
return true;
|
|
1041
|
+
};
|
|
1042
|
+
|
|
1043
1043
|
var RLConnected = ComponentWrapper.ComponentWrapper(index.connect(mapStateToProps, mapDispatchtoProps)(ReactiveList), {
|
|
1044
1044
|
componentType: constants.componentTypes.reactiveList,
|
|
1045
|
-
internalComponent:
|
|
1045
|
+
internalComponent: ReactiveList.hasInternalComponent()
|
|
1046
1046
|
});
|
|
1047
1047
|
|
|
1048
1048
|
ReactiveList.install = function (Vue) {
|
|
@@ -36,9 +36,10 @@ var getQueryOptions = configureStore.helper.getQueryOptions,
|
|
|
36
36
|
checkValueChange = configureStore.helper.checkValueChange,
|
|
37
37
|
checkPropChange = configureStore.helper.checkPropChange,
|
|
38
38
|
getClassName = configureStore.helper.getClassName,
|
|
39
|
-
getOptionsFromQuery = configureStore.helper.getOptionsFromQuery,
|
|
40
39
|
isEqual = configureStore.helper.isEqual,
|
|
41
|
-
getCompositeAggsQuery = configureStore.helper.getCompositeAggsQuery
|
|
40
|
+
getCompositeAggsQuery = configureStore.helper.getCompositeAggsQuery,
|
|
41
|
+
extractQueryFromCustomQuery = configureStore.helper.extractQueryFromCustomQuery,
|
|
42
|
+
getOptionsForCustomQuery = configureStore.helper.getOptionsForCustomQuery;
|
|
42
43
|
var SingleDropdownList = {
|
|
43
44
|
name: 'SingleDropdownList',
|
|
44
45
|
data: function data() {
|
|
@@ -75,7 +76,7 @@ var SingleDropdownList = {
|
|
|
75
76
|
selectAllLabel: vueTypes.types.string,
|
|
76
77
|
showCount: VueTypes.bool.def(true),
|
|
77
78
|
showFilter: VueTypes.bool.def(true),
|
|
78
|
-
size: VueTypes.number
|
|
79
|
+
size: VueTypes.number,
|
|
79
80
|
sortBy: VueTypes.oneOf(['asc', 'desc', 'count']).def('count'),
|
|
80
81
|
title: vueTypes.types.title,
|
|
81
82
|
URLParams: VueTypes.bool.def(false),
|
|
@@ -292,12 +293,13 @@ var SingleDropdownList = {
|
|
|
292
293
|
|
|
293
294
|
if (this.defaultQuery) {
|
|
294
295
|
var defaultQueryToBeSet = this.defaultQuery(value, props) || {};
|
|
296
|
+
var defaultQueryObj = extractQueryFromCustomQuery(defaultQueryToBeSet);
|
|
295
297
|
|
|
296
|
-
if (
|
|
297
|
-
query =
|
|
298
|
+
if (defaultQueryObj) {
|
|
299
|
+
query = defaultQueryObj;
|
|
298
300
|
}
|
|
299
301
|
|
|
300
|
-
defaultQueryOptions =
|
|
302
|
+
defaultQueryOptions = getOptionsForCustomQuery(defaultQueryToBeSet); // Update calculated default query in store
|
|
301
303
|
|
|
302
304
|
index.updateDefaultQuery(props.componentId, this.setDefaultQuery, props, value);
|
|
303
305
|
}
|
|
@@ -316,10 +318,9 @@ var SingleDropdownList = {
|
|
|
316
318
|
var customQueryOptions;
|
|
317
319
|
|
|
318
320
|
if (customQuery) {
|
|
319
|
-
var
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
customQueryOptions = getOptionsFromQuery(customQuery(value, props));
|
|
321
|
+
var customQueryCalc = customQuery(value, props);
|
|
322
|
+
query = extractQueryFromCustomQuery(customQueryCalc);
|
|
323
|
+
customQueryOptions = getOptionsForCustomQuery(customQueryCalc);
|
|
323
324
|
index.updateCustomQuery(props.componentId, this.setCustomQuery, props, value);
|
|
324
325
|
}
|
|
325
326
|
|
|
@@ -357,7 +358,7 @@ var SingleDropdownList = {
|
|
|
357
358
|
|
|
358
359
|
if (props.defaultQuery) {
|
|
359
360
|
var value = this.$data.currentValue;
|
|
360
|
-
var defaultQueryOptions =
|
|
361
|
+
var defaultQueryOptions = getOptionsForCustomQuery(props.defaultQuery(value, props));
|
|
361
362
|
this.setQueryOptions(this.internalComponent, _rollupPluginBabelHelpers._extends({}, queryOptions, defaultQueryOptions));
|
|
362
363
|
} else {
|
|
363
364
|
this.setQueryOptions(this.internalComponent, queryOptions);
|
|
@@ -449,6 +450,10 @@ SingleDropdownList.generateQueryOptions = function (props, after) {
|
|
|
449
450
|
}) : utils.getAggsQuery(queryOptions, props);
|
|
450
451
|
};
|
|
451
452
|
|
|
453
|
+
SingleDropdownList.hasInternalComponent = function () {
|
|
454
|
+
return true;
|
|
455
|
+
};
|
|
456
|
+
|
|
452
457
|
var mapStateToProps = function mapStateToProps(state, props) {
|
|
453
458
|
return {
|
|
454
459
|
options: props.nestedField && state.aggregations[props.componentId] ? state.aggregations[props.componentId].reactivesearch_nested : state.aggregations[props.componentId],
|
|
@@ -470,7 +475,7 @@ var mapDispatchtoProps = {
|
|
|
470
475
|
};
|
|
471
476
|
var ListConnected = ComponentWrapper.ComponentWrapper(index.connect(mapStateToProps, mapDispatchtoProps)(SingleDropdownList), {
|
|
472
477
|
componentType: constants.componentTypes.singleDropdownList,
|
|
473
|
-
internalComponent:
|
|
478
|
+
internalComponent: SingleDropdownList.hasInternalComponent()
|
|
474
479
|
});
|
|
475
480
|
|
|
476
481
|
SingleDropdownList.install = function (Vue) {
|
package/dist/cjs/SingleList.js
CHANGED
|
@@ -31,8 +31,9 @@ var updateQuery = configureStore.Actions.updateQuery,
|
|
|
31
31
|
var getQueryOptions = configureStore.helper.getQueryOptions,
|
|
32
32
|
checkValueChange = configureStore.helper.checkValueChange,
|
|
33
33
|
getClassName = configureStore.helper.getClassName,
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
isEqual = configureStore.helper.isEqual,
|
|
35
|
+
extractQueryFromCustomQuery = configureStore.helper.extractQueryFromCustomQuery,
|
|
36
|
+
getOptionsForCustomQuery = configureStore.helper.getOptionsForCustomQuery;
|
|
36
37
|
var SingleList = {
|
|
37
38
|
name: 'SingleList',
|
|
38
39
|
props: {
|
|
@@ -274,12 +275,13 @@ var SingleList = {
|
|
|
274
275
|
|
|
275
276
|
if (this.defaultQuery) {
|
|
276
277
|
var defaultQueryToBeSet = this.defaultQuery(value, props) || {};
|
|
278
|
+
var defaultQueryObj = extractQueryFromCustomQuery(defaultQueryToBeSet);
|
|
277
279
|
|
|
278
|
-
if (
|
|
279
|
-
query =
|
|
280
|
+
if (defaultQueryObj) {
|
|
281
|
+
query = defaultQueryObj;
|
|
280
282
|
}
|
|
281
283
|
|
|
282
|
-
defaultQueryOptions =
|
|
284
|
+
defaultQueryOptions = getOptionsForCustomQuery(defaultQueryToBeSet); // Update calculated default query in store
|
|
283
285
|
|
|
284
286
|
index.updateDefaultQuery(props.componentId, this.setDefaultQuery, props, value);
|
|
285
287
|
}
|
|
@@ -298,10 +300,9 @@ var SingleList = {
|
|
|
298
300
|
var customQueryOptions;
|
|
299
301
|
|
|
300
302
|
if (customQuery) {
|
|
301
|
-
var
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
customQueryOptions = getOptionsFromQuery(customQuery(value, props));
|
|
303
|
+
var customQueryCalc = customQuery(value, props);
|
|
304
|
+
query = extractQueryFromCustomQuery(customQueryCalc);
|
|
305
|
+
customQueryOptions = getOptionsForCustomQuery(customQueryCalc);
|
|
305
306
|
index.updateCustomQuery(props.componentId, this.setCustomQuery, props, value);
|
|
306
307
|
}
|
|
307
308
|
|
|
@@ -325,7 +326,7 @@ var SingleList = {
|
|
|
325
326
|
|
|
326
327
|
if (props.defaultQuery) {
|
|
327
328
|
var value = this.$data.currentValue;
|
|
328
|
-
var defaultQueryOptions =
|
|
329
|
+
var defaultQueryOptions = getOptionsForCustomQuery(props.defaultQuery(value, props));
|
|
329
330
|
this.setQueryOptions(this.internalComponent, _rollupPluginBabelHelpers._extends({}, queryOptions, defaultQueryOptions));
|
|
330
331
|
} else {
|
|
331
332
|
this.setQueryOptions(this.internalComponent, queryOptions);
|
|
@@ -470,6 +471,10 @@ SingleList.defaultQuery = function (value, props) {
|
|
|
470
471
|
return query;
|
|
471
472
|
};
|
|
472
473
|
|
|
474
|
+
SingleList.hasInternalComponent = function () {
|
|
475
|
+
return true;
|
|
476
|
+
};
|
|
477
|
+
|
|
473
478
|
var mapStateToProps = function mapStateToProps(state, props) {
|
|
474
479
|
return {
|
|
475
480
|
options: props.nestedField && state.aggregations[props.componentId] ? state.aggregations[props.componentId].reactivesearch_nested : state.aggregations[props.componentId],
|
|
@@ -491,7 +496,7 @@ var mapDispatchtoProps = {
|
|
|
491
496
|
};
|
|
492
497
|
var ListConnected = ComponentWrapper.ComponentWrapper(index.connect(mapStateToProps, mapDispatchtoProps)(SingleList), {
|
|
493
498
|
componentType: constants.componentTypes.singleList,
|
|
494
|
-
internalComponent:
|
|
499
|
+
internalComponent: SingleList.hasInternalComponent()
|
|
495
500
|
});
|
|
496
501
|
|
|
497
502
|
SingleList.install = function (Vue) {
|
|
@@ -18,10 +18,10 @@ var dependencyTreeReducer = _interopDefault(require('@appbaseio/reactivecore/lib
|
|
|
18
18
|
var fetchGraphQL = _interopDefault(require('@appbaseio/reactivecore/lib/utils/graphQL'));
|
|
19
19
|
var utils = require('@appbaseio/reactivecore/lib/actions/utils');
|
|
20
20
|
|
|
21
|
-
var _excluded = ["aggs", "size"]
|
|
21
|
+
var _excluded = ["aggs", "size"],
|
|
22
|
+
_excluded2 = ["query"],
|
|
23
|
+
_excluded3 = ["aggs", "size"];
|
|
22
24
|
var X_SEARCH_CLIENT = 'ReactiveSearch Vue';
|
|
23
|
-
var componentsWithHighlightQuery = [constants.componentTypes.dataSearch, constants.componentTypes.categorySearch];
|
|
24
|
-
var componentsWithOptions = [constants.componentTypes.reactiveList, constants.componentTypes.reactiveMap, constants.componentTypes.singleList, constants.componentTypes.multiList, constants.componentTypes.tagCloud].concat(componentsWithHighlightQuery);
|
|
25
25
|
var componentsWithoutFilters = [constants.componentTypes.numberBox, constants.componentTypes.ratingsFilter];
|
|
26
26
|
var resultComponents = [constants.componentTypes.reactiveList, constants.componentTypes.reactiveMap];
|
|
27
27
|
|
|
@@ -55,23 +55,35 @@ function parseValue(value, component) {
|
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
return value;
|
|
58
|
-
}
|
|
58
|
+
} // Returns query DSL with query property and other options
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
function getDefaultQuery(component, value) {
|
|
62
|
+
// get custom or default query of sensor components
|
|
63
|
+
var currentValue = parseValue(value, component); // get default query of result components
|
|
64
|
+
|
|
65
|
+
if (component.defaultQuery) {
|
|
66
|
+
var defaultQuery = component.defaultQuery(currentValue, component);
|
|
67
|
+
return _rollupPluginBabelHelpers._extends({
|
|
68
|
+
query: helper.extractQueryFromCustomQuery(defaultQuery)
|
|
69
|
+
}, helper.getOptionsForCustomQuery(defaultQuery));
|
|
70
|
+
}
|
|
59
71
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
} // get custom or default query of sensor components
|
|
72
|
+
return component.source.defaultQuery ? {
|
|
73
|
+
query: component.source.defaultQuery(currentValue, component)
|
|
74
|
+
} : {};
|
|
75
|
+
} // Only results the query part
|
|
65
76
|
|
|
66
77
|
|
|
78
|
+
function getCustomQuery(component, value) {
|
|
79
|
+
// get custom or default query of sensor components
|
|
67
80
|
var currentValue = parseValue(value, component);
|
|
68
81
|
|
|
69
82
|
if (component.customQuery) {
|
|
70
|
-
|
|
71
|
-
return customQuery && customQuery.query;
|
|
83
|
+
return helper.extractQueryFromCustomQuery(component.customQuery(currentValue, component));
|
|
72
84
|
}
|
|
73
85
|
|
|
74
|
-
return component.source.defaultQuery ? component.source.defaultQuery(currentValue, component) :
|
|
86
|
+
return component.source.defaultQuery ? component.source.defaultQuery(currentValue, component) : null;
|
|
75
87
|
}
|
|
76
88
|
|
|
77
89
|
function initReactivesearch(componentCollection, searchState, settings) {
|
|
@@ -126,6 +138,11 @@ function initReactivesearch(componentCollection, searchState, settings) {
|
|
|
126
138
|
}
|
|
127
139
|
});
|
|
128
140
|
var isInternalComponentPresent = false;
|
|
141
|
+
|
|
142
|
+
if (component.source.hasInternalComponent) {
|
|
143
|
+
isInternalComponentPresent = component.source.hasInternalComponent(component);
|
|
144
|
+
}
|
|
145
|
+
|
|
129
146
|
var isResultComponent = resultComponents.includes(componentType);
|
|
130
147
|
var internalComponent = component.componentId + "__internal";
|
|
131
148
|
var label = component.filterLabel || component.componentId;
|
|
@@ -157,74 +174,67 @@ function initReactivesearch(componentCollection, searchState, settings) {
|
|
|
157
174
|
|
|
158
175
|
if (component.defaultQuery && typeof component.defaultQuery === 'function') {
|
|
159
176
|
defaultQueries[component.componentId] = component.defaultQuery(value, compProps);
|
|
160
|
-
}
|
|
161
|
-
|
|
177
|
+
}
|
|
162
178
|
|
|
163
|
-
|
|
164
|
-
var options = component.source.generateQueryOptions ? component.source.generateQueryOptions(component) : null;
|
|
165
|
-
var highlightQuery = {};
|
|
179
|
+
var componentQueryOptions = {}; // [2] set query options - main component query (valid for result components)
|
|
166
180
|
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
181
|
+
if (component && component.source.generateQueryOptions) {
|
|
182
|
+
componentQueryOptions = _rollupPluginBabelHelpers._extends({}, componentQueryOptions, component.source.generateQueryOptions(component));
|
|
183
|
+
}
|
|
170
184
|
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
var _ref = options || {},
|
|
174
|
-
aggs = _ref.aggs,
|
|
175
|
-
size = _ref.size,
|
|
176
|
-
otherQueryOptions = _rollupPluginBabelHelpers._objectWithoutPropertiesLoose(_ref, _excluded);
|
|
177
|
-
|
|
178
|
-
if (aggs && Object.keys(aggs).length) {
|
|
179
|
-
isInternalComponentPresent = true; // query should be applied on the internal component
|
|
180
|
-
// to enable feeding the data to parent component
|
|
181
|
-
|
|
182
|
-
queryOptions = queryOptionsReducer(queryOptions, {
|
|
183
|
-
type: 'SET_QUERY_OPTIONS',
|
|
184
|
-
component: internalComponent,
|
|
185
|
-
options: {
|
|
186
|
-
aggs: aggs,
|
|
187
|
-
size: typeof size === 'undefined' ? 100 : size
|
|
188
|
-
}
|
|
189
|
-
});
|
|
190
|
-
} // sort, highlight, size, from - query should be applied on the main component
|
|
185
|
+
console.log('QUERY LOG componentQueryOptions', component.componentId, componentQueryOptions);
|
|
186
|
+
var highlightQuery = {};
|
|
191
187
|
|
|
188
|
+
if (component.source.highlightQuery) {
|
|
189
|
+
highlightQuery = component.source.highlightQuery(component);
|
|
190
|
+
}
|
|
192
191
|
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
192
|
+
if (componentQueryOptions && Object.keys(componentQueryOptions).length || highlightQuery && Object.keys(highlightQuery).length) {
|
|
193
|
+
// eslint-disable-next-line
|
|
194
|
+
var _ref = componentQueryOptions || {},
|
|
195
|
+
aggs = _ref.aggs,
|
|
196
|
+
size = _ref.size,
|
|
197
|
+
otherQueryOptions = _rollupPluginBabelHelpers._objectWithoutPropertiesLoose(_ref, _excluded);
|
|
198
|
+
|
|
199
|
+
if (aggs && Object.keys(aggs).length) {
|
|
200
|
+
isInternalComponentPresent = true;
|
|
201
|
+
componentQueryOptions = _rollupPluginBabelHelpers._extends({}, componentQueryOptions, {
|
|
202
|
+
aggs: aggs,
|
|
203
|
+
size: typeof size === 'undefined' ? 100 : size
|
|
204
|
+
});
|
|
205
|
+
} // sort, highlight, size, from - query should be applied on the main component
|
|
196
206
|
|
|
197
|
-
var mainQueryOptions = _rollupPluginBabelHelpers._extends({}, otherQueryOptions, highlightQuery, {
|
|
198
|
-
size: size
|
|
199
|
-
});
|
|
200
207
|
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
208
|
+
if (otherQueryOptions && Object.keys(otherQueryOptions).length || highlightQuery && Object.keys(highlightQuery).length) {
|
|
209
|
+
if (!otherQueryOptions) otherQueryOptions = {};
|
|
210
|
+
if (!highlightQuery) highlightQuery = {};
|
|
204
211
|
|
|
205
|
-
|
|
206
|
-
|
|
212
|
+
var mainQueryOptions = _rollupPluginBabelHelpers._extends({}, otherQueryOptions, highlightQuery, {
|
|
213
|
+
size: size
|
|
214
|
+
});
|
|
207
215
|
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
216
|
+
if (isInternalComponentPresent) {
|
|
217
|
+
mainQueryOptions = _rollupPluginBabelHelpers._extends({}, otherQueryOptions, highlightQuery);
|
|
218
|
+
}
|
|
211
219
|
|
|
212
|
-
|
|
213
|
-
|
|
220
|
+
if (isResultComponent) {
|
|
221
|
+
var currentPage = component.currentPage ? component.currentPage - 1 : 0;
|
|
214
222
|
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
size: resultSize,
|
|
218
|
-
from: from
|
|
219
|
-
});
|
|
223
|
+
if (selectedValues[component.componentId] && selectedValues[component.componentId].value) {
|
|
224
|
+
currentPage = selectedValues[component.componentId].value - 1 || 0;
|
|
220
225
|
}
|
|
221
226
|
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
227
|
+
var resultSize = component.size || 10;
|
|
228
|
+
var from = currentPage * resultSize; // Update props for RS API
|
|
229
|
+
|
|
230
|
+
compProps.from = from;
|
|
231
|
+
mainQueryOptions = _rollupPluginBabelHelpers._extends({}, mainQueryOptions, highlightQuery, {
|
|
232
|
+
size: resultSize,
|
|
233
|
+
from: from
|
|
226
234
|
});
|
|
227
235
|
}
|
|
236
|
+
|
|
237
|
+
componentQueryOptions = _rollupPluginBabelHelpers._extends({}, componentQueryOptions, mainQueryOptions);
|
|
228
238
|
}
|
|
229
239
|
} // [3] set dependency tree
|
|
230
240
|
|
|
@@ -242,25 +252,38 @@ function initReactivesearch(componentCollection, searchState, settings) {
|
|
|
242
252
|
react: react
|
|
243
253
|
});
|
|
244
254
|
} // [4] set query list
|
|
255
|
+
// Do not set default query for suggestions
|
|
245
256
|
|
|
246
257
|
|
|
247
|
-
if (
|
|
248
|
-
var
|
|
249
|
-
|
|
258
|
+
if (isInternalComponentPresent && !transform.isSearchComponent(component.componentType)) {
|
|
259
|
+
var _ref2 = getDefaultQuery(component, value) || {},
|
|
260
|
+
defaultQuery = _ref2.query,
|
|
261
|
+
defaultQueryOptions = _rollupPluginBabelHelpers._objectWithoutPropertiesLoose(_ref2, _excluded2);
|
|
250
262
|
|
|
251
263
|
queryList = queryReducer(queryList, {
|
|
252
264
|
type: 'SET_QUERY',
|
|
253
265
|
component: internalComponent,
|
|
254
|
-
query:
|
|
266
|
+
query: defaultQuery
|
|
255
267
|
});
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
query: getQuery(component, value, componentType)
|
|
268
|
+
queryOptions = queryOptionsReducer(queryOptions, {
|
|
269
|
+
type: 'SET_QUERY_OPTIONS',
|
|
270
|
+
component: internalComponent,
|
|
271
|
+
options: _rollupPluginBabelHelpers._extends({}, componentQueryOptions, defaultQueryOptions)
|
|
261
272
|
});
|
|
262
|
-
}
|
|
273
|
+
}
|
|
263
274
|
|
|
275
|
+
var customQuery = getCustomQuery(component, value); // set custom query for main component
|
|
276
|
+
|
|
277
|
+
queryList = queryReducer(queryList, {
|
|
278
|
+
type: 'SET_QUERY',
|
|
279
|
+
component: component.componentId,
|
|
280
|
+
query: customQuery
|
|
281
|
+
});
|
|
282
|
+
queryOptions = queryOptionsReducer(queryOptions, {
|
|
283
|
+
type: 'SET_QUERY_OPTIONS',
|
|
284
|
+
component: component.componentId,
|
|
285
|
+
options: _rollupPluginBabelHelpers._extends({}, componentQueryOptions)
|
|
286
|
+
}); // Set component type in component props
|
|
264
287
|
|
|
265
288
|
compProps.componentType = componentType;
|
|
266
289
|
componentProps[component.componentId] = compProps;
|
|
@@ -283,9 +306,23 @@ function initReactivesearch(componentCollection, searchState, settings) {
|
|
|
283
306
|
queryObj = _buildQuery.queryObj,
|
|
284
307
|
options = _buildQuery.options;
|
|
285
308
|
|
|
286
|
-
var
|
|
309
|
+
var componentQueryOptions = options;
|
|
310
|
+
var componentType = component.source.componentType;
|
|
311
|
+
console.log('COMPONENT TYPE', componentType);
|
|
312
|
+
|
|
313
|
+
if (componentType !== constants.componentTypes.reactiveComponent) {
|
|
314
|
+
// don't merge aggs, size
|
|
315
|
+
var _ref3 = options || {},
|
|
316
|
+
aggs = _ref3.aggs,
|
|
317
|
+
size = _ref3.size,
|
|
318
|
+
rest = _rollupPluginBabelHelpers._objectWithoutPropertiesLoose(_ref3, _excluded3);
|
|
319
|
+
|
|
320
|
+
componentQueryOptions = rest;
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
var validOptions = ['aggs', 'from', 'sort']; // check if query or componentQueryOptions are valid - non-empty
|
|
287
324
|
|
|
288
|
-
if (queryObj && !!Object.keys(queryObj).length ||
|
|
325
|
+
if (queryObj && !!Object.keys(queryObj).length || componentQueryOptions && Object.keys(componentQueryOptions).some(function (item) {
|
|
289
326
|
return validOptions.includes(item);
|
|
290
327
|
})) {
|
|
291
328
|
var _extends2;
|
|
@@ -300,8 +337,12 @@ function initReactivesearch(componentCollection, searchState, settings) {
|
|
|
300
337
|
|
|
301
338
|
var currentQuery = _rollupPluginBabelHelpers._extends({
|
|
302
339
|
query: _rollupPluginBabelHelpers._extends({}, queryObj)
|
|
303
|
-
},
|
|
340
|
+
}, componentQueryOptions, queryOptions[component.componentId]);
|
|
304
341
|
|
|
342
|
+
console.log('QUERY LOG build QUERY', component.componentId, queryObj);
|
|
343
|
+
console.log('QUERY LOG build OPTIONS', component.componentId, componentQueryOptions);
|
|
344
|
+
console.log('QUERY LOG OPTIONS (component)', component.componentId, queryOptions[component.componentId]);
|
|
345
|
+
console.log('QUERY LOG', component.componentId, currentQuery);
|
|
305
346
|
queryLog = _rollupPluginBabelHelpers._extends({}, queryLog, (_extends2 = {}, _extends2[component.componentId] = currentQuery, _extends2));
|
|
306
347
|
|
|
307
348
|
if (settings.enableAppbase) {
|