mirror of
https://github.com/zulip/zulip.git
synced 2025-11-04 14:03:30 +00:00
minor: Specify types of pills while initializing pill typeahead.
In options that we pass to pill_typeahead.set_up we specify if we want typeahead to support stream or user_group pills, and use users as source by default. Using users for source by default, can have unnecessary suggestions in typeaheads where only user_groups or streams are needed. So to solve that, we specify if we want users pill in the input. This is then utilized in further commits, to clean up hacky code that deals with intializing source for typeahead.
This commit is contained in:
committed by
Tim Abbott
parent
637f648828
commit
0080daa5a3
@@ -1,3 +1,4 @@
|
||||
import * as blueslip from "./blueslip";
|
||||
import * as composebox_typeahead from "./composebox_typeahead";
|
||||
import * as people from "./people";
|
||||
import * as stream_pill from "./stream_pill";
|
||||
@@ -21,6 +22,10 @@ function group_matcher(query, item) {
|
||||
}
|
||||
|
||||
export function set_up(input, pills, opts) {
|
||||
if (!opts.user && !opts.user_group && !opts.stream) {
|
||||
blueslip.error("Unspecified possible item types");
|
||||
return;
|
||||
}
|
||||
let source = opts.source;
|
||||
if (!opts.source) {
|
||||
source = () => user_pill.typeahead_source(pills);
|
||||
|
||||
@@ -255,13 +255,13 @@ export function initialize_custom_user_type_fields(
|
||||
if (is_editable) {
|
||||
const input = pill_container.children(".input");
|
||||
if (set_handler_on_update) {
|
||||
const opts = {update_func: update_custom_user_field};
|
||||
const opts = {update_func: update_custom_user_field, user: true};
|
||||
pill_typeahead.set_up(input, pills, opts);
|
||||
pills.onPillRemove(() => {
|
||||
update_custom_user_field();
|
||||
});
|
||||
} else {
|
||||
pill_typeahead.set_up(input, pills, {});
|
||||
pill_typeahead.set_up(input, pills, {user: true});
|
||||
}
|
||||
}
|
||||
user_pills.set(field.id, pills);
|
||||
|
||||
@@ -275,7 +275,7 @@ export function populate_user_groups() {
|
||||
|
||||
const input = pill_container.children(".input");
|
||||
if (can_edit(data.id)) {
|
||||
const opts = {update_func: update_cancel_button};
|
||||
const opts = {update_func: update_cancel_button, user: true};
|
||||
pill_typeahead.set_up(input, pills, opts);
|
||||
}
|
||||
|
||||
|
||||
@@ -418,7 +418,12 @@ function show_subscription_settings(sub) {
|
||||
simplebar_container: $(".subscriber_list_container"),
|
||||
});
|
||||
|
||||
const opts = {source: get_users_for_subscriber_typeahead, stream: true, user_group: true};
|
||||
const opts = {
|
||||
source: get_users_for_subscriber_typeahead,
|
||||
stream: true,
|
||||
user_group: true,
|
||||
user: true,
|
||||
};
|
||||
pill_typeahead.set_up(sub_settings.find(".input"), pill_widget, opts);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user