@appbaseio/reactivesearch-vue 1.16.0-alpha.36 → 1.16.0-alpha.37
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 +437 -896
- 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 +21 -16
- package/dist/cjs/MultiList.js +21 -15
- package/dist/cjs/ReactiveComponent.js +30 -60
- package/dist/cjs/ReactiveList.js +47 -47
- package/dist/cjs/SingleDropdownList.js +16 -11
- package/dist/cjs/SingleList.js +16 -11
- package/dist/cjs/initReactivesearch.js +97 -80
- 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 +21 -16
- package/dist/es/MultiList.js +21 -15
- package/dist/es/ReactiveComponent.js +30 -60
- package/dist/es/ReactiveList.js +47 -47
- package/dist/es/SingleDropdownList.js +16 -11
- package/dist/es/SingleList.js +16 -11
- package/dist/es/initReactivesearch.js +98 -81
- 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() {
|
|
@@ -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,9 @@ 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"];
|
|
22
23
|
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
24
|
var componentsWithoutFilters = [constants.componentTypes.numberBox, constants.componentTypes.ratingsFilter];
|
|
26
25
|
var resultComponents = [constants.componentTypes.reactiveList, constants.componentTypes.reactiveMap];
|
|
27
26
|
|
|
@@ -55,23 +54,35 @@ function parseValue(value, component) {
|
|
|
55
54
|
}
|
|
56
55
|
|
|
57
56
|
return value;
|
|
58
|
-
}
|
|
57
|
+
} // Returns query DSL with query property and other options
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
function getDefaultQuery(component, value) {
|
|
61
|
+
// get custom or default query of sensor components
|
|
62
|
+
var currentValue = parseValue(value, component); // get default query of result components
|
|
63
|
+
|
|
64
|
+
if (component.defaultQuery) {
|
|
65
|
+
var defaultQuery = component.defaultQuery(currentValue, component);
|
|
66
|
+
return _rollupPluginBabelHelpers._extends({
|
|
67
|
+
query: helper.extractQueryFromCustomQuery(defaultQuery)
|
|
68
|
+
}, helper.getOptionsForCustomQuery(defaultQuery));
|
|
69
|
+
}
|
|
59
70
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
} // get custom or default query of sensor components
|
|
71
|
+
return component.source.defaultQuery ? {
|
|
72
|
+
query: component.source.defaultQuery(currentValue, component)
|
|
73
|
+
} : {};
|
|
74
|
+
} // Only results the query part
|
|
65
75
|
|
|
66
76
|
|
|
77
|
+
function getCustomQuery(component, value) {
|
|
78
|
+
// get custom or default query of sensor components
|
|
67
79
|
var currentValue = parseValue(value, component);
|
|
68
80
|
|
|
69
81
|
if (component.customQuery) {
|
|
70
|
-
|
|
71
|
-
return customQuery && customQuery.query;
|
|
82
|
+
return helper.extractQueryFromCustomQuery(component.customQuery(currentValue, component));
|
|
72
83
|
}
|
|
73
84
|
|
|
74
|
-
return component.source.defaultQuery ? component.source.defaultQuery(currentValue, component) :
|
|
85
|
+
return component.source.defaultQuery ? component.source.defaultQuery(currentValue, component) : null;
|
|
75
86
|
}
|
|
76
87
|
|
|
77
88
|
function initReactivesearch(componentCollection, searchState, settings) {
|
|
@@ -126,6 +137,11 @@ function initReactivesearch(componentCollection, searchState, settings) {
|
|
|
126
137
|
}
|
|
127
138
|
});
|
|
128
139
|
var isInternalComponentPresent = false;
|
|
140
|
+
|
|
141
|
+
if (component.source.hasInternalComponent) {
|
|
142
|
+
isInternalComponentPresent = component.source.hasInternalComponent(component);
|
|
143
|
+
}
|
|
144
|
+
|
|
129
145
|
var isResultComponent = resultComponents.includes(componentType);
|
|
130
146
|
var internalComponent = component.componentId + "__internal";
|
|
131
147
|
var label = component.filterLabel || component.componentId;
|
|
@@ -157,74 +173,66 @@ function initReactivesearch(componentCollection, searchState, settings) {
|
|
|
157
173
|
|
|
158
174
|
if (component.defaultQuery && typeof component.defaultQuery === 'function') {
|
|
159
175
|
defaultQueries[component.componentId] = component.defaultQuery(value, compProps);
|
|
160
|
-
}
|
|
161
|
-
|
|
176
|
+
}
|
|
162
177
|
|
|
163
|
-
|
|
164
|
-
var options = component.source.generateQueryOptions ? component.source.generateQueryOptions(component) : null;
|
|
165
|
-
var highlightQuery = {};
|
|
178
|
+
var componentQueryOptions = {}; // [2] set query options - main component query (valid for result components)
|
|
166
179
|
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
180
|
+
if (component && component.source.generateQueryOptions) {
|
|
181
|
+
componentQueryOptions = _rollupPluginBabelHelpers._extends({}, componentQueryOptions, component.source.generateQueryOptions(component));
|
|
182
|
+
}
|
|
170
183
|
|
|
171
|
-
|
|
172
|
-
// eslint-disable-next-line
|
|
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
|
|
184
|
+
var highlightQuery = {};
|
|
191
185
|
|
|
186
|
+
if (component.source.highlightQuery) {
|
|
187
|
+
highlightQuery = component.source.highlightQuery(component);
|
|
188
|
+
}
|
|
192
189
|
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
190
|
+
if (componentQueryOptions && Object.keys(componentQueryOptions).length || highlightQuery && Object.keys(highlightQuery).length) {
|
|
191
|
+
// eslint-disable-next-line
|
|
192
|
+
var _ref = componentQueryOptions || {},
|
|
193
|
+
aggs = _ref.aggs,
|
|
194
|
+
size = _ref.size,
|
|
195
|
+
otherQueryOptions = _rollupPluginBabelHelpers._objectWithoutPropertiesLoose(_ref, _excluded);
|
|
196
|
+
|
|
197
|
+
if (aggs && Object.keys(aggs).length) {
|
|
198
|
+
isInternalComponentPresent = true;
|
|
199
|
+
componentQueryOptions = _rollupPluginBabelHelpers._extends({}, componentQueryOptions, {
|
|
200
|
+
aggs: aggs,
|
|
201
|
+
size: typeof size === 'undefined' ? 100 : size
|
|
202
|
+
});
|
|
203
|
+
} // sort, highlight, size, from - query should be applied on the main component
|
|
196
204
|
|
|
197
|
-
var mainQueryOptions = _rollupPluginBabelHelpers._extends({}, otherQueryOptions, highlightQuery, {
|
|
198
|
-
size: size
|
|
199
|
-
});
|
|
200
205
|
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
206
|
+
if (otherQueryOptions && Object.keys(otherQueryOptions).length || highlightQuery && Object.keys(highlightQuery).length) {
|
|
207
|
+
if (!otherQueryOptions) otherQueryOptions = {};
|
|
208
|
+
if (!highlightQuery) highlightQuery = {};
|
|
204
209
|
|
|
205
|
-
|
|
206
|
-
|
|
210
|
+
var mainQueryOptions = _rollupPluginBabelHelpers._extends({}, otherQueryOptions, highlightQuery, {
|
|
211
|
+
size: size
|
|
212
|
+
});
|
|
207
213
|
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
214
|
+
if (isInternalComponentPresent) {
|
|
215
|
+
mainQueryOptions = _rollupPluginBabelHelpers._extends({}, otherQueryOptions, highlightQuery);
|
|
216
|
+
}
|
|
211
217
|
|
|
212
|
-
|
|
213
|
-
|
|
218
|
+
if (isResultComponent) {
|
|
219
|
+
var currentPage = component.currentPage ? component.currentPage - 1 : 0;
|
|
214
220
|
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
size: resultSize,
|
|
218
|
-
from: from
|
|
219
|
-
});
|
|
221
|
+
if (selectedValues[component.componentId] && selectedValues[component.componentId].value) {
|
|
222
|
+
currentPage = selectedValues[component.componentId].value - 1 || 0;
|
|
220
223
|
}
|
|
221
224
|
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
225
|
+
var resultSize = component.size || 10;
|
|
226
|
+
var from = currentPage * resultSize; // Update props for RS API
|
|
227
|
+
|
|
228
|
+
compProps.from = from;
|
|
229
|
+
mainQueryOptions = _rollupPluginBabelHelpers._extends({}, mainQueryOptions, highlightQuery, {
|
|
230
|
+
size: resultSize,
|
|
231
|
+
from: from
|
|
226
232
|
});
|
|
227
233
|
}
|
|
234
|
+
|
|
235
|
+
componentQueryOptions = _rollupPluginBabelHelpers._extends({}, componentQueryOptions, mainQueryOptions);
|
|
228
236
|
}
|
|
229
237
|
} // [3] set dependency tree
|
|
230
238
|
|
|
@@ -244,23 +252,32 @@ function initReactivesearch(componentCollection, searchState, settings) {
|
|
|
244
252
|
} // [4] set query list
|
|
245
253
|
|
|
246
254
|
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
255
|
+
var _ref2 = getDefaultQuery(component, value) || {},
|
|
256
|
+
defaultQuery = _ref2.query,
|
|
257
|
+
defaultQueryOptions = _rollupPluginBabelHelpers._objectWithoutPropertiesLoose(_ref2, _excluded2);
|
|
250
258
|
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
} // Set component type in component props
|
|
259
|
+
queryList = queryReducer(queryList, {
|
|
260
|
+
type: 'SET_QUERY',
|
|
261
|
+
component: internalComponent,
|
|
262
|
+
query: defaultQuery
|
|
263
|
+
});
|
|
264
|
+
queryOptions = queryOptionsReducer(queryOptions, {
|
|
265
|
+
type: 'SET_QUERY_OPTIONS',
|
|
266
|
+
component: internalComponent,
|
|
267
|
+
options: _rollupPluginBabelHelpers._extends({}, componentQueryOptions, defaultQueryOptions)
|
|
268
|
+
});
|
|
269
|
+
var customQuery = getCustomQuery(component, value); // set custom query for main component
|
|
263
270
|
|
|
271
|
+
queryList = queryReducer(queryList, {
|
|
272
|
+
type: 'SET_QUERY',
|
|
273
|
+
component: component.componentId,
|
|
274
|
+
query: customQuery
|
|
275
|
+
});
|
|
276
|
+
queryOptions = queryOptionsReducer(queryOptions, {
|
|
277
|
+
type: 'SET_QUERY_OPTIONS',
|
|
278
|
+
component: component.componentId,
|
|
279
|
+
options: _rollupPluginBabelHelpers._extends({}, componentQueryOptions)
|
|
280
|
+
}); // Set component type in component props
|
|
264
281
|
|
|
265
282
|
compProps.componentType = componentType;
|
|
266
283
|
componentProps[component.componentId] = compProps;
|