mirror of
https://github.com/zulip/zulip.git
synced 2025-11-18 12:54:58 +00:00
js: Convert static/js/search_pill.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
committed by
Tim Abbott
parent
e16687af83
commit
8a6fdb662a
@@ -1,28 +1,26 @@
|
||||
"use strict";
|
||||
|
||||
exports.create_item_from_search_string = function (search_string) {
|
||||
export function create_item_from_search_string(search_string) {
|
||||
const operator = Filter.parse(search_string);
|
||||
const description = Filter.describe(operator);
|
||||
return {
|
||||
display_value: search_string,
|
||||
description,
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
exports.get_search_string_from_item = function (item) {
|
||||
export function get_search_string_from_item(item) {
|
||||
return item.display_value;
|
||||
};
|
||||
}
|
||||
|
||||
exports.create_pills = function (pill_container) {
|
||||
export function create_pills(pill_container) {
|
||||
const 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,
|
||||
create_item_from_text: create_item_from_search_string,
|
||||
get_text_from_item: get_search_string_from_item,
|
||||
});
|
||||
return pills;
|
||||
};
|
||||
}
|
||||
|
||||
exports.append_search_string = function (search_string, pill_widget) {
|
||||
export function append_search_string(search_string, pill_widget) {
|
||||
const operators = Filter.parse(search_string);
|
||||
for (const operator of operators) {
|
||||
const input = Filter.unparse([operator]);
|
||||
@@ -31,12 +29,10 @@ exports.append_search_string = function (search_string, pill_widget) {
|
||||
if (pill_widget.clear_text !== undefined) {
|
||||
pill_widget.clear_text();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
exports.get_search_string_for_current_filter = function (pill_widget) {
|
||||
export function get_search_string_for_current_filter(pill_widget) {
|
||||
const items = pill_widget.items();
|
||||
const search_strings = items.map((item) => item.display_value);
|
||||
return search_strings.join(" ");
|
||||
};
|
||||
|
||||
window.search_pill = exports;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user