blob: 2fe1dcd4e194ab40cd6d0c94e366160889ba2b9f [file] [log] [blame]
Copybara854996b2021-09-07 19:36:02 +00001/* Copyright 2016 The Chromium Authors. All Rights Reserved.
2 *
3 * Use of this source code is governed by a BSD-style
4 * license that can be found in the LICENSE file or at
5 * https://developers.google.com/open-source/licenses/bsd
6 */
7/* eslint-disable camelcase */
8/* eslint-disable no-unused-vars */
9
10/**
11 * Sets up the legacy autocomplete editing widget on DOM elements that are
12 * set to use it.
13 */
14function TKR_install_ac() {
15 _ac_install();
16
17 _ac_register(function(input, event) {
18 if (input.id.startsWith('hotlists')) return TKR_hotlistsStore;
19 if (input.id.startsWith('search')) return TKR_searchStore;
20 if (input.id.startsWith('query_') || input.id.startsWith('predicate_')) {
21 return TKR_projectQueryStore;
22 }
23 if (input.id.startsWith('cmd')) return TKR_quickEditStore;
24 if (input.id.startsWith('labelPrefix')) return TKR_labelPrefixStore;
25 if (input.id.startsWith('label') && input.id != 'labelsInput') return TKR_labelStore;
26 if (input.dataset.acType === 'label' && input.id != 'labelsInput') return TKR_labelMultiStore;
27 if ((input.id.startsWith('component') || input.dataset.acType === 'component')
28 && input.id != 'componentsInput') return TKR_componentListStore;
29 if (input.id.startsWith('status')) return TKR_statusStore;
30 if (input.id.startsWith('member') || input.dataset.acType === 'member') return TKR_memberListStore;
31
32 if (input.id == 'admin_names_editor') return TKR_memberListStore;
33 if (input.id.startsWith('owner') && input.id != 'ownerInput') return TKR_ownerStore;
34 if (input.name == 'needs_perm' || input.name == 'grants_perm') {
35 return TKR_customPermissionsStore;
36 }
37 if (input.id == 'owner_editor' || input.dataset.acType === 'owner') return TKR_ownerStore;
38 if (input.className.indexOf('userautocomplete') != -1) {
39 const customFieldIDStr = input.name;
40 const uac = TKR_userAutocompleteStores[customFieldIDStr];
41 if (uac) return uac;
42 return TKR_ownerStore;
43 }
44 if (input.className.indexOf('autocomplete') != -1) {
45 return TKR_autoCompleteStore;
46 }
47 if (input.id.startsWith('copy_to') || input.id.startsWith('move_to') ||
48 input.id.startsWith('new_savedquery_projects') ||
49 input.id.startsWith('savedquery_projects')) {
50 return TKR_projectStore;
51 }
52 });
53};