Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 | import { __ } from '~/locale'; import Filter from './droplab/plugins/filter'; import DropdownUtils from './dropdown_utils'; import FilteredSearchDropdown from './filtered_search_dropdown'; import FilteredSearchDropdownManager from './filtered_search_dropdown_manager'; import FilteredSearchVisualTokens from './filtered_search_visual_tokens'; export default class DropdownOperator extends FilteredSearchDropdown { constructor(options = {}) { const { input, tokenKeys } = options; super(options); this.config = { Filter: { filterFunction: DropdownUtils.filterWithSymbol.bind(null, '', input), template: 'title', }, }; this.tokenKeys = tokenKeys; } itemClicked(e) { const { selected } = e.detail; if (selected.tagName === 'LI') { if (Object.prototype.hasOwnProperty.call(selected.dataset, 'value')) { const name = FilteredSearchVisualTokens.getLastTokenPartial(); const operator = selected.dataset.value; FilteredSearchVisualTokens.removeLastTokenPartial(); FilteredSearchDropdownManager.addWordToInput({ tokenName: name, tokenOperator: operator, clicked: false, }); } } this.dismissDropdown(); this.dispatchInputEvent(); } renderContent(forceShowList = false, dropdownName = '') { const dropdownData = [ { tag: 'equal', type: 'string', title: '=', help: __('is'), }, ]; const dropdownToken = this.tokenKeys.searchByKey(dropdownName.toLowerCase()); if (!dropdownToken?.hideNotEqual) { dropdownData.push({ tag: 'not-equal', type: 'string', title: '!=', help: __('is not'), }); } this.droplab.changeHookList(this.hookId, this.dropdown, [Filter], this.config); this.droplab.setData(this.hookId, dropdownData); super.renderContent(forceShowList); } init() { this.droplab.addHook(this.input, this.dropdown, [Filter], this.config).init(); } } |