Skip to content

Commit 8b7ab72

Browse files
committed
Build
1 parent 29d5c47 commit 8b7ab72

6 files changed

+185
-141
lines changed

lib/sensors/CategorySearch.js

+47-37
Original file line numberDiff line numberDiff line change
@@ -189,43 +189,53 @@ var CategorySearch = function (_Component) {
189189
}, {
190190
key: "defaultSearchQuery",
191191
value: function defaultSearchQuery(input) {
192+
var _this2 = this;
193+
192194
if (input && input.value) {
193-
var query = [];
194-
if (this.fieldType === "string") {
195-
query.push({
196-
match_phrase_prefix: _defineProperty({}, this.props.appbaseField, input.value)
197-
});
198-
} else {
199-
this.props.appbaseField.forEach(function (field) {
195+
var _ret = function () {
196+
var query = [];
197+
if (_this2.fieldType === "string") {
200198
query.push({
201-
match_phrase_prefix: _defineProperty({}, field, input.value)
199+
match_phrase_prefix: _defineProperty({}, _this2.props.appbaseField, input.value)
200+
});
201+
} else {
202+
_this2.props.appbaseField.forEach(function (field) {
203+
query.push({
204+
match_phrase_prefix: _defineProperty({}, field, input.value)
205+
});
202206
});
203-
});
204207

205-
query = {
206-
bool: {
207-
should: query,
208-
minimum_should_match: 1
209-
}
210-
};
211-
}
208+
query = {
209+
bool: {
210+
should: query,
211+
minimum_should_match: 1
212+
}
213+
};
214+
}
215+
216+
if (input.category && input.category !== null) {
217+
return {
218+
v: {
219+
bool: {
220+
must: [query, {
221+
term: _defineProperty({}, _this2.props.categoryField, input.category)
222+
}]
223+
}
224+
}
225+
};
226+
}
212227

213-
if (input.category && input.category !== null) {
214228
return {
215-
bool: {
216-
must: [query, {
217-
term: _defineProperty({}, this.props.categoryField, input.category)
218-
}]
229+
v: {
230+
bool: {
231+
should: query,
232+
minimum_should_match: 1
233+
}
219234
}
220235
};
221-
}
236+
}();
222237

223-
return {
224-
bool: {
225-
should: query,
226-
minimum_should_match: 1
227-
}
228-
};
238+
if ((typeof _ret === "undefined" ? "undefined" : _typeof(_ret)) === "object") return _ret.v;
229239
}
230240
return null;
231241
}
@@ -235,7 +245,7 @@ var CategorySearch = function (_Component) {
235245
}, {
236246
key: "createChannel",
237247
value: function createChannel() {
238-
var _this2 = this;
248+
var _this3 = this;
239249

240250
var react = this.props.react ? this.props.react : {};
241251
react.aggs = {
@@ -253,26 +263,26 @@ var CategorySearch = function (_Component) {
253263
var data = res.data;
254264
var rawData = void 0;
255265
if (res.mode === "streaming") {
256-
rawData = _this2.state.rawData;
266+
rawData = _this3.state.rawData;
257267
rawData.hits.hits.push(res.data);
258268
} else if (res.mode === "historic") {
259269
rawData = data;
260270
}
261-
_this2.setState({
271+
_this3.setState({
262272
rawData: rawData
263273
});
264-
_this2.setData(rawData, res.appliedQuery.body.query);
274+
_this3.setData(rawData, res.appliedQuery.body.query);
265275
});
266276
this.listenLoadingChannel(channelObj);
267277
}
268278
}, {
269279
key: "listenLoadingChannel",
270280
value: function listenLoadingChannel(channelObj) {
271-
var _this3 = this;
281+
var _this4 = this;
272282

273283
this.loadListener = channelObj.emitter.addListener(channelObj.channelId + "-query", function (res) {
274284
if (res.appliedQuery) {
275-
_this3.setState({
285+
_this4.setState({
276286
queryStart: res.queryState
277287
});
278288
}
@@ -281,7 +291,7 @@ var CategorySearch = function (_Component) {
281291
}, {
282292
key: "setData",
283293
value: function setData(data, loadSuggestions) {
284-
var _this4 = this;
294+
var _this5 = this;
285295

286296
var aggs = [];
287297
var options = [];
@@ -297,8 +307,8 @@ var CategorySearch = function (_Component) {
297307
data.hits.hits.forEach(function (hit) {
298308
if (searchField) {
299309
options.push({ value: eval(searchField), label: eval(searchField) });
300-
} else if (_this4.fieldType === "object") {
301-
_this4.props.appbaseField.forEach(function (field) {
310+
} else if (_this5.fieldType === "object") {
311+
_this5.props.appbaseField.forEach(function (field) {
302312
var tempField = "hit._source." + field;
303313
if (eval(tempField)) {
304314
options.push({ value: eval(tempField), label: eval(tempField) });

lib/sensors/DynamicRangeSlider.js

+11-9
Original file line numberDiff line numberDiff line change
@@ -319,13 +319,15 @@ var DynamicRangeSlider = function (_Component) {
319319
key: "updateValues",
320320
value: function updateValues(defaultSelected) {
321321
if (defaultSelected) {
322-
var _state$range = this.state.range,
323-
min = _state$range.min,
324-
max = _state$range.max;
322+
var _state$range = this.state.range;
323+
var min = _state$range.min;
324+
var max = _state$range.max;
325+
326+
var _ref = this.urlParams !== null ? this.urlParams : defaultSelected(min, max);
327+
328+
var start = _ref.start;
329+
var end = _ref.end;
325330

326-
var _ref = this.urlParams !== null ? this.urlParams : defaultSelected(min, max),
327-
start = _ref.start,
328-
end = _ref.end;
329331

330332
if (start >= min && end <= max) {
331333
var values = {
@@ -398,9 +400,9 @@ var DynamicRangeSlider = function (_Component) {
398400
histogram = null,
399401
marks = {};
400402

401-
var _state$range2 = this.state.range,
402-
min = _state$range2.min,
403-
max = _state$range2.max;
403+
var _state$range2 = this.state.range;
404+
var min = _state$range2.min;
405+
var max = _state$range2.max;
404406

405407

406408
if (this.props.title) {

lib/sensors/NestedList.js

+38-8
Original file line numberDiff line numberDiff line change
@@ -376,20 +376,23 @@ var NestedList = function (_Component) {
376376
key: "setValue",
377377
value: function setValue(value) {
378378
var isExecuteQuery = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
379+
var changeNestedValue = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
379380

380381
var obj = {
381382
key: this.props.componentId,
382383
value: value
383384
};
384-
var nestedObj = {
385-
key: "nestedSelectedValues",
386-
value: value
387-
};
385+
if (changeNestedValue) {
386+
var nestedObj = {
387+
key: "nestedSelectedValues",
388+
value: value
389+
};
390+
_reactivemaps.AppbaseSensorHelper.selectedSensor.set(nestedObj, isExecuteQuery);
391+
}
388392
if (this.props.onValueChange) {
389393
this.props.onValueChange(obj.value);
390394
}
391395
_reactivemaps.AppbaseSensorHelper.URLParams.update(this.props.componentId, value, this.props.URLParams);
392-
_reactivemaps.AppbaseSensorHelper.selectedSensor.set(nestedObj, isExecuteQuery);
393396
_reactivemaps.AppbaseSensorHelper.selectedSensor.set(obj, isExecuteQuery);
394397
}
395398

@@ -415,8 +418,21 @@ var NestedList = function (_Component) {
415418
key: "onItemClick",
416419
value: function onItemClick(event) {
417420
var selectedValues = $(event.currentTarget).data("value").split(",");
421+
var level = Number($(event.currentTarget).data("level"));
418422
event.stopPropagation();
419-
this.onItemSelect(selectedValues);
423+
if (selectedValues[level] === this.state.selectedValues[level]) {
424+
selectedValues = this.state.selectedValues.filter(function (item, index) {
425+
return index < level;
426+
});
427+
var items = this.state.items;
428+
items[level + 1] = null;
429+
this.setState({
430+
items: items,
431+
selectedValues: selectedValues
432+
}, this.setValue(selectedValues, true, false));
433+
} else {
434+
this.onItemSelect(selectedValues);
435+
}
420436
}
421437
}, {
422438
key: "onItemSelect",
@@ -469,7 +485,7 @@ var NestedList = function (_Component) {
469485
},
470486
_react2.default.createElement(
471487
"button",
472-
{ className: "rbc-list-item " + cx, "data-value": item.value, onClick: _this10.onItemClick },
488+
{ className: "rbc-list-item " + cx, "data-value": item.value, "data-level": level, onClick: _this10.onItemClick },
473489
_react2.default.createElement(
474490
"span",
475491
{ className: "rbc-label" },
@@ -562,9 +578,23 @@ var NestedList = function (_Component) {
562578
exports.default = NestedList;
563579

564580

581+
var NestedingValidation = function NestedingValidation(props, propName) {
582+
var err = null;
583+
if (!props[propName]) {
584+
err = new Error("appbaseField is required prop!");
585+
} else if (!_.isArray(props[propName])) {
586+
err = new Error("appbaseField should be an array!");
587+
} else if (props[propName].length === 0) {
588+
err = new Error("appbaseField should not have an empty array.");
589+
} else if (props[propName].length > 9) {
590+
err = new Error("appbaseField can have maximum 10 fields.");
591+
}
592+
return err;
593+
};
594+
565595
NestedList.propTypes = {
566596
componentId: _react2.default.PropTypes.string.isRequired,
567-
appbaseField: _react2.default.PropTypes.array.isRequired,
597+
appbaseField: NestedingValidation,
568598
title: _react2.default.PropTypes.oneOfType([_react2.default.PropTypes.string, _react2.default.PropTypes.element]),
569599
showCount: _react2.default.PropTypes.bool,
570600
showSearch: _react2.default.PropTypes.bool,

lib/sensors/RatingsFilter.js

+30-28
Original file line numberDiff line numberDiff line change
@@ -147,37 +147,39 @@ var RatingsFilter = function (_Component) {
147147
var buttons = void 0;
148148
var selectedItem = this.state.selected && this.state.selected.start ? this.state.selected.start : this.props.data.start;
149149
if (this.props.data) {
150-
var maxEnd = 5;
151-
this.props.data.forEach(function (item) {
152-
maxEnd = item.end > maxEnd ? item.end : maxEnd;
153-
});
150+
(function () {
151+
var maxEnd = 5;
152+
_this4.props.data.forEach(function (item) {
153+
maxEnd = item.end > maxEnd ? item.end : maxEnd;
154+
});
154155

155-
buttons = this.props.data.map(function (record) {
156-
var cx = selectedItem === record.start ? "rbc-active" : "";
157-
return _react2.default.createElement(
158-
"div",
159-
{ className: "rbc-list-item row", key: record.label, onClick: function onClick() {
160-
return _this4.handleChange(record);
161-
} },
162-
_react2.default.createElement(
163-
"label",
164-
{ className: "rbc-label " + cx },
165-
_react2.default.createElement(_reactStars2.default, {
166-
count: maxEnd,
167-
value: record.start,
168-
size: 20,
169-
color1: "#bbb",
170-
edit: false,
171-
color2: "#ffd700"
172-
}),
156+
buttons = _this4.props.data.map(function (record) {
157+
var cx = selectedItem === record.start ? "rbc-active" : "";
158+
return _react2.default.createElement(
159+
"div",
160+
{ className: "rbc-list-item row", key: record.label, onClick: function onClick() {
161+
return _this4.handleChange(record);
162+
} },
173163
_react2.default.createElement(
174-
"span",
175-
null,
176-
record.label
164+
"label",
165+
{ className: "rbc-label " + cx },
166+
_react2.default.createElement(_reactStars2.default, {
167+
count: maxEnd,
168+
value: record.start,
169+
size: 20,
170+
color1: "#bbb",
171+
edit: false,
172+
color2: "#ffd700"
173+
}),
174+
_react2.default.createElement(
175+
"span",
176+
null,
177+
record.label
178+
)
177179
)
178-
)
179-
);
180-
});
180+
);
181+
});
182+
})();
181183
}
182184
return buttons;
183185
}

lib/sensors/ToggleList.js

+21-19
Original file line numberDiff line numberDiff line change
@@ -97,25 +97,27 @@ var ToggleList = function (_Component) {
9797
}
9898
} else if ((typeof defaultValue === "undefined" ? "undefined" : _typeof(defaultValue)) === "object") {
9999
if (!_.isEqual(_this2.defaultSelected, defaultValue)) {
100-
_this2.defaultSelected = defaultValue;
101-
var _records = [];
102-
_this2.defaultSelected.forEach(function (item) {
103-
_records = _records.concat(props.data.filter(function (record) {
104-
return item.indexOf(record.label) > -1;
105-
}));
106-
});
107-
_this2.setState({
108-
selected: _records
109-
});
110-
if (_this2.props.onValueChange) {
111-
_this2.props.onValueChange(_obj2.value);
112-
}
113-
var _obj2 = {
114-
key: props.componentId,
115-
value: _records
116-
};
117-
_reactivemaps.AppbaseSensorHelper.URLParams.update(_this2.props.componentId, _this2.setURLParam(_obj2.value), _this2.props.URLParams);
118-
_reactivemaps.AppbaseSensorHelper.selectedSensor.set(_obj2, true);
100+
(function () {
101+
_this2.defaultSelected = defaultValue;
102+
var records = [];
103+
_this2.defaultSelected.forEach(function (item) {
104+
records = records.concat(props.data.filter(function (record) {
105+
return item.indexOf(record.label) > -1;
106+
}));
107+
});
108+
_this2.setState({
109+
selected: records
110+
});
111+
if (_this2.props.onValueChange) {
112+
_this2.props.onValueChange(obj.value);
113+
}
114+
var obj = {
115+
key: props.componentId,
116+
value: records
117+
};
118+
_reactivemaps.AppbaseSensorHelper.URLParams.update(_this2.props.componentId, _this2.setURLParam(obj.value), _this2.props.URLParams);
119+
_reactivemaps.AppbaseSensorHelper.selectedSensor.set(obj, true);
120+
})();
119121
}
120122
} else {
121123
console.error(props.componentId + " - defaultSelected prop should be an \"array\"");

umd/ReactiveSearch.js

+38-40
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)