2018-06-21 15:11:21 +02:00
|
|
|
var search_pill = (function () {
|
|
|
|
var exports = {};
|
|
|
|
|
|
|
|
exports.create_item_from_search_string = function (search_string) {
|
|
|
|
var operator = Filter.parse(search_string);
|
|
|
|
var description = Filter.describe(operator);
|
|
|
|
return {
|
2018-07-14 16:10:00 +02:00
|
|
|
display_value: search_string,
|
|
|
|
description: description,
|
2018-06-21 15:11:21 +02:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
exports.get_search_string_from_item = function (item) {
|
2018-07-14 16:10:00 +02:00
|
|
|
return item.display_value;
|
2018-06-21 15:11:21 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
exports.create_pills = function (pill_container) {
|
|
|
|
var pills = input_pill.create({
|
|
|
|
container: pill_container,
|
|
|
|
create_item_from_text: exports.create_item_from_search_string,
|
|
|
|
get_text_from_item: exports.get_search_string_from_item,
|
|
|
|
});
|
|
|
|
return pills;
|
|
|
|
};
|
|
|
|
|
|
|
|
exports.append_search_string = function (search_string, pill_widget) {
|
|
|
|
pill_widget.appendValue(search_string);
|
|
|
|
if (pill_widget.clear_text !== undefined) {
|
|
|
|
pill_widget.clear_text();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
exports.get_search_string_for_current_filter = function (pill_widget) {
|
|
|
|
var items = pill_widget.items();
|
2018-07-14 16:10:00 +02:00
|
|
|
var search_strings = _.pluck(items, 'display_value');
|
2018-06-21 15:11:21 +02:00
|
|
|
return search_strings.join(' ');
|
|
|
|
};
|
|
|
|
|
|
|
|
return exports;
|
|
|
|
}());
|
|
|
|
|
|
|
|
if (typeof module !== 'undefined') {
|
|
|
|
module.exports = search_pill;
|
|
|
|
}
|
2018-05-28 08:04:36 +02:00
|
|
|
|
|
|
|
window.search_pill = search_pill;
|