globalSearch.js 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729
  1. const subManager = new SubsManager();
  2. BlazeComponent.extendComponent({
  3. events() {
  4. return [
  5. {
  6. 'click .js-due-cards-view-change': Popup.open('globalSearchViewChange'),
  7. },
  8. ];
  9. },
  10. }).register('globalSearchHeaderBar');
  11. Template.globalSearch.helpers({
  12. userId() {
  13. return Meteor.userId();
  14. },
  15. });
  16. BlazeComponent.extendComponent({
  17. events() {
  18. return [
  19. {
  20. 'click .js-due-cards-view-me'() {
  21. Utils.setDueCardsView('me');
  22. Popup.close();
  23. },
  24. 'click .js-due-cards-view-all'() {
  25. Utils.setDueCardsView('all');
  26. Popup.close();
  27. },
  28. },
  29. ];
  30. },
  31. }).register('globalSearchViewChangePopup');
  32. BlazeComponent.extendComponent({
  33. onCreated() {
  34. this.searching = new ReactiveVar(false);
  35. this.hasResults = new ReactiveVar(false);
  36. this.hasQueryErrors = new ReactiveVar(false);
  37. this.query = new ReactiveVar('');
  38. this.resultsHeading = new ReactiveVar('');
  39. this.searchLink = new ReactiveVar(null);
  40. this.myLists = new ReactiveVar([]);
  41. this.myLabelNames = new ReactiveVar([]);
  42. this.myBoardNames = new ReactiveVar([]);
  43. this.results = new ReactiveVar([]);
  44. this.hasNextPage = new ReactiveVar(false);
  45. this.hasPreviousPage = new ReactiveVar(false);
  46. this.queryParams = null;
  47. this.parsingErrors = [];
  48. this.resultsCount = 0;
  49. this.totalHits = 0;
  50. this.queryErrors = null;
  51. this.colorMap = null;
  52. this.resultsPerPage = 25;
  53. Meteor.call('myLists', (err, data) => {
  54. if (!err) {
  55. this.myLists.set(data);
  56. }
  57. });
  58. Meteor.call('myLabelNames', (err, data) => {
  59. if (!err) {
  60. this.myLabelNames.set(data);
  61. }
  62. });
  63. Meteor.call('myBoardNames', (err, data) => {
  64. if (!err) {
  65. this.myBoardNames.set(data);
  66. }
  67. });
  68. },
  69. onRendered() {
  70. Meteor.subscribe('setting');
  71. // eslint-disable-next-line no-console
  72. //console.log('lang:', TAPi18n.getLanguage());
  73. this.colorMap = Boards.colorMap();
  74. // eslint-disable-next-line no-console
  75. // console.log('colorMap:', this.colorMap);
  76. if (Session.get('globalQuery')) {
  77. this.searchAllBoards(Session.get('globalQuery'));
  78. }
  79. },
  80. resetSearch() {
  81. this.searching.set(false);
  82. this.results.set([]);
  83. this.hasResults.set(false);
  84. this.hasQueryErrors.set(false);
  85. this.resultsHeading.set('');
  86. this.parsingErrors = [];
  87. this.resultsCount = 0;
  88. this.totalHits = 0;
  89. this.queryErrors = null;
  90. },
  91. getSessionData() {
  92. return SessionData.findOne({
  93. userId: Meteor.userId(),
  94. sessionId: SessionData.getSessionId(),
  95. });
  96. },
  97. getResults() {
  98. // eslint-disable-next-line no-console
  99. // console.log('getting results');
  100. if (this.queryParams) {
  101. const sessionData = this.getSessionData();
  102. // eslint-disable-next-line no-console
  103. // console.log('selector:', sessionData.getSelector());
  104. // console.log('session data:', sessionData);
  105. const projection = sessionData.getProjection();
  106. projection.skip = 0;
  107. const cards = Cards.find({ _id: { $in: sessionData.cards } }, projection);
  108. this.queryErrors = sessionData.errors;
  109. if (this.queryErrors.length) {
  110. this.hasQueryErrors.set(true);
  111. return null;
  112. }
  113. if (cards) {
  114. this.totalHits = sessionData.totalHits;
  115. this.resultsCount = cards.count();
  116. this.resultsStart = sessionData.lastHit - this.resultsCount + 1;
  117. this.resultsEnd = sessionData.lastHit;
  118. this.resultsHeading.set(this.getResultsHeading());
  119. this.results.set(cards);
  120. this.hasNextPage.set(sessionData.lastHit < sessionData.totalHits);
  121. this.hasPreviousPage.set(
  122. sessionData.lastHit - sessionData.resultsCount > 0,
  123. );
  124. }
  125. }
  126. this.resultsCount = 0;
  127. return null;
  128. },
  129. errorMessages() {
  130. if (this.parsingErrors.length) {
  131. return this.parsingErrorMessages();
  132. }
  133. return this.queryErrorMessages();
  134. },
  135. parsingErrorMessages() {
  136. const messages = [];
  137. if (this.parsingErrors.length) {
  138. this.parsingErrors.forEach(err => {
  139. messages.push(TAPi18n.__(err.tag, err.value));
  140. });
  141. }
  142. return messages;
  143. },
  144. queryErrorMessages() {
  145. messages = [];
  146. this.queryErrors.forEach(err => {
  147. let value = err.color ? TAPi18n.__(`color-${err.value}`) : err.value;
  148. if (!value) {
  149. value = err.value;
  150. }
  151. messages.push(TAPi18n.__(err.tag, value));
  152. });
  153. return messages;
  154. },
  155. searchAllBoards(query) {
  156. query = query.trim();
  157. // eslint-disable-next-line no-console
  158. //console.log('query:', query);
  159. this.query.set(query);
  160. this.resetSearch();
  161. if (!query) {
  162. return;
  163. }
  164. this.searching.set(true);
  165. const reOperator1 = new RegExp(
  166. '^((?<operator>[\\p{Letter}\\p{Mark}]+):|(?<abbrev>[#@]))(?<value>[\\p{Letter}\\p{Mark}]+)(\\s+|$)',
  167. 'iu',
  168. );
  169. const reOperator2 = new RegExp(
  170. '^((?<operator>[\\p{Letter}\\p{Mark}]+):|(?<abbrev>[#@]))(?<quote>["\']*)(?<value>.*?)\\k<quote>(\\s+|$)',
  171. 'iu',
  172. );
  173. const reText = new RegExp('^(?<text>\\S+)(\\s+|$)', 'u');
  174. const reQuotedText = new RegExp(
  175. '^(?<quote>["\'])(?<text>.*?)\\k<quote>(\\s+|$)',
  176. 'u',
  177. );
  178. const reNegatedOperator = new RegExp('^-(?<operator>.*)$');
  179. const operators = {
  180. 'operator-board': 'boards',
  181. 'operator-board-abbrev': 'boards',
  182. 'operator-swimlane': 'swimlanes',
  183. 'operator-swimlane-abbrev': 'swimlanes',
  184. 'operator-list': 'lists',
  185. 'operator-list-abbrev': 'lists',
  186. 'operator-label': 'labels',
  187. 'operator-label-abbrev': 'labels',
  188. 'operator-user': 'users',
  189. 'operator-user-abbrev': 'users',
  190. 'operator-member': 'members',
  191. 'operator-member-abbrev': 'members',
  192. 'operator-assignee': 'assignees',
  193. 'operator-assignee-abbrev': 'assignees',
  194. 'operator-status': 'status',
  195. 'operator-due': 'dueAt',
  196. 'operator-created': 'createdAt',
  197. 'operator-modified': 'modifiedAt',
  198. 'operator-comment': 'comments',
  199. 'operator-has': 'has',
  200. 'operator-sort': 'sort',
  201. };
  202. const predicates = {
  203. due: {
  204. 'predicate-overdue': 'overdue',
  205. },
  206. durations: {
  207. 'predicate-week': 'week',
  208. 'predicate-month': 'month',
  209. 'predicate-quarter': 'quarter',
  210. 'predicate-year': 'year',
  211. },
  212. status: {
  213. 'predicate-archived': 'archived',
  214. 'predicate-all': 'all',
  215. 'predicate-ended': 'ended',
  216. 'predicate-public': 'public',
  217. 'predicate-private': 'private',
  218. },
  219. sorts: {
  220. 'predicate-due': 'dueAt',
  221. 'predicate-created': 'createdAt',
  222. 'predicate-modified': 'modifiedAt',
  223. },
  224. has: {
  225. 'predicate-description': 'description',
  226. 'predicate-checklist': 'checklist',
  227. 'predicate-attachment': 'attachment',
  228. },
  229. };
  230. const predicateTranslations = {};
  231. Object.entries(predicates).forEach(([category, catPreds]) => {
  232. predicateTranslations[category] = {};
  233. Object.entries(catPreds).forEach(([tag, value]) => {
  234. predicateTranslations[category][TAPi18n.__(tag)] = value;
  235. });
  236. });
  237. // eslint-disable-next-line no-console
  238. // console.log('predicateTranslations:', predicateTranslations);
  239. const operatorMap = {};
  240. Object.entries(operators).forEach(([key, value]) => {
  241. operatorMap[TAPi18n.__(key).toLowerCase()] = value;
  242. });
  243. // eslint-disable-next-line no-console
  244. // console.log('operatorMap:', operatorMap);
  245. const params = {
  246. limit: this.resultsPerPage,
  247. boards: [],
  248. swimlanes: [],
  249. lists: [],
  250. users: [],
  251. members: [],
  252. assignees: [],
  253. labels: [],
  254. status: [],
  255. dueAt: null,
  256. createdAt: null,
  257. modifiedAt: null,
  258. comments: [],
  259. has: [],
  260. };
  261. let text = '';
  262. while (query) {
  263. m = query.match(reOperator1);
  264. if (!m) {
  265. m = query.match(reOperator2);
  266. if (m) {
  267. query = query.replace(reOperator2, '');
  268. }
  269. } else {
  270. query = query.replace(reOperator1, '');
  271. }
  272. if (m) {
  273. let op;
  274. if (m.groups.operator) {
  275. op = m.groups.operator.toLowerCase();
  276. } else {
  277. op = m.groups.abbrev.toLowerCase();
  278. }
  279. // eslint-disable-next-line no-prototype-builtins
  280. if (operatorMap.hasOwnProperty(op)) {
  281. const operator = operatorMap[op];
  282. let value = m.groups.value;
  283. if (operator === 'labels') {
  284. if (value in this.colorMap) {
  285. value = this.colorMap[value];
  286. // console.log('found color:', value);
  287. }
  288. } else if (['dueAt', 'createdAt', 'modifiedAt'].includes(operator)) {
  289. let days = parseInt(value, 10);
  290. let duration = null;
  291. if (isNaN(days)) {
  292. // duration was specified as text
  293. if (predicateTranslations.durations[value]) {
  294. duration = predicateTranslations.durations[value];
  295. let date = null;
  296. switch (duration) {
  297. case 'week':
  298. let week = moment().week();
  299. if (week === 52) {
  300. date = moment(1, 'W');
  301. date.set('year', date.year() + 1);
  302. } else {
  303. date = moment(week + 1, 'W');
  304. }
  305. break;
  306. case 'month':
  307. let month = moment().month();
  308. // .month() is zero indexed
  309. if (month === 11) {
  310. date = moment(1, 'M');
  311. date.set('year', date.year() + 1);
  312. } else {
  313. date = moment(month + 2, 'M');
  314. }
  315. break;
  316. case 'quarter':
  317. let quarter = moment().quarter();
  318. if (quarter === 4) {
  319. date = moment(1, 'Q');
  320. date.set('year', date.year() + 1);
  321. } else {
  322. date = moment(quarter + 1, 'Q');
  323. }
  324. break;
  325. case 'year':
  326. date = moment(moment().year() + 1, 'YYYY');
  327. break;
  328. }
  329. if (date) {
  330. value = {
  331. operator: '$lt',
  332. value: date.format(),
  333. };
  334. }
  335. } else if (operator === 'dueAt' && value === 'overdue') {
  336. value = {
  337. operator: '$lt',
  338. value: moment().format(),
  339. };
  340. } else {
  341. this.parsingErrors.push({
  342. tag: 'operator-number-expected',
  343. value: { operator: op, value },
  344. });
  345. value = null;
  346. }
  347. } else {
  348. if (operator === 'dueAt') {
  349. value = {
  350. operator: '$lte',
  351. value: moment()
  352. .add(days, duration ? duration : 'days')
  353. .format(),
  354. };
  355. } else {
  356. value = {
  357. operator: '$gte',
  358. value: moment()
  359. .subtract(days, duration ? duration : 'days')
  360. .format(),
  361. };
  362. }
  363. }
  364. } else if (operator === 'sort') {
  365. let negated = false;
  366. const m = value.match(reNegatedOperator);
  367. if (m) {
  368. value = m.groups.operator;
  369. negated = true;
  370. }
  371. if (!predicateTranslations.sorts[value]) {
  372. this.parsingErrors.push({
  373. tag: 'operator-sort-invalid',
  374. value,
  375. });
  376. } else {
  377. value = {
  378. name: predicateTranslations.sorts[value],
  379. order: negated ? 'des' : 'asc',
  380. };
  381. }
  382. } else if (operator === 'status') {
  383. if (!predicateTranslations.status[value]) {
  384. this.parsingErrors.push({
  385. tag: 'operator-status-invalid',
  386. value,
  387. });
  388. } else {
  389. value = predicateTranslations.status[value];
  390. }
  391. } else if (operator === 'has') {
  392. if (!predicateTranslations.has[value]) {
  393. this.parsingErrors.push({
  394. tag: 'operator-has-invalid',
  395. value,
  396. });
  397. } else {
  398. value = predicateTranslations.has[value];
  399. }
  400. }
  401. if (Array.isArray(params[operator])) {
  402. params[operator].push(value);
  403. } else {
  404. params[operator] = value;
  405. }
  406. } else {
  407. this.parsingErrors.push({
  408. tag: 'operator-unknown-error',
  409. value: op,
  410. });
  411. }
  412. continue;
  413. }
  414. m = query.match(reQuotedText);
  415. if (!m) {
  416. m = query.match(reText);
  417. if (m) {
  418. query = query.replace(reText, '');
  419. }
  420. } else {
  421. query = query.replace(reQuotedText, '');
  422. }
  423. if (m) {
  424. text += (text ? ' ' : '') + m.groups.text;
  425. }
  426. }
  427. // eslint-disable-next-line no-console
  428. // console.log('text:', text);
  429. params.text = text;
  430. // eslint-disable-next-line no-console
  431. console.log('params:', params);
  432. this.queryParams = params;
  433. if (this.parsingErrors.length) {
  434. this.searching.set(false);
  435. this.queryErrors = this.parsingErrorMessages();
  436. this.hasResults.set(true);
  437. this.hasQueryErrors.set(true);
  438. return;
  439. }
  440. this.autorun(() => {
  441. const handle = Meteor.subscribe(
  442. 'globalSearch',
  443. SessionData.getSessionId(),
  444. params,
  445. );
  446. Tracker.nonreactive(() => {
  447. Tracker.autorun(() => {
  448. if (handle.ready()) {
  449. this.getResults();
  450. this.searching.set(false);
  451. this.hasResults.set(true);
  452. }
  453. });
  454. });
  455. });
  456. },
  457. nextPage() {
  458. const sessionData = this.getSessionData();
  459. this.autorun(() => {
  460. const handle = Meteor.subscribe('nextPage', sessionData.sessionId);
  461. Tracker.nonreactive(() => {
  462. Tracker.autorun(() => {
  463. if (handle.ready()) {
  464. this.getResults();
  465. this.searching.set(false);
  466. this.hasResults.set(true);
  467. }
  468. });
  469. });
  470. });
  471. },
  472. previousPage() {
  473. const sessionData = this.getSessionData();
  474. this.autorun(() => {
  475. const handle = Meteor.subscribe('previousPage', sessionData.sessionId);
  476. Tracker.nonreactive(() => {
  477. Tracker.autorun(() => {
  478. if (handle.ready()) {
  479. this.getResults();
  480. this.searching.set(false);
  481. this.hasResults.set(true);
  482. }
  483. });
  484. });
  485. });
  486. },
  487. getResultsHeading() {
  488. if (this.resultsCount === 0) {
  489. return TAPi18n.__('no-cards-found');
  490. } else if (this.resultsCount === 1) {
  491. return TAPi18n.__('one-card-found');
  492. } else if (this.resultsCount === this.totalHits) {
  493. return TAPi18n.__('n-cards-found', this.resultsCount);
  494. }
  495. return TAPi18n.__('n-n-of-n-cards-found', {
  496. start: this.resultsStart,
  497. end: this.resultsEnd,
  498. total: this.totalHits,
  499. });
  500. },
  501. getSearchHref() {
  502. const baseUrl = window.location.href.replace(/([?#].*$|\s*$)/, '');
  503. return `${baseUrl}?q=${encodeURIComponent(this.query.get())}`;
  504. },
  505. searchInstructions() {
  506. tags = {
  507. operator_board: TAPi18n.__('operator-board'),
  508. operator_list: TAPi18n.__('operator-list'),
  509. operator_swimlane: TAPi18n.__('operator-swimlane'),
  510. operator_comment: TAPi18n.__('operator-comment'),
  511. operator_label: TAPi18n.__('operator-label'),
  512. operator_label_abbrev: TAPi18n.__('operator-label-abbrev'),
  513. operator_user: TAPi18n.__('operator-user'),
  514. operator_user_abbrev: TAPi18n.__('operator-user-abbrev'),
  515. operator_member: TAPi18n.__('operator-member'),
  516. operator_member_abbrev: TAPi18n.__('operator-member-abbrev'),
  517. operator_assignee: TAPi18n.__('operator-assignee'),
  518. operator_assignee_abbrev: TAPi18n.__('operator-assignee-abbrev'),
  519. operator_due: TAPi18n.__('operator-due'),
  520. operator_created: TAPi18n.__('operator-created'),
  521. operator_modified: TAPi18n.__('operator-modified'),
  522. operator_status: TAPi18n.__('operator-status'),
  523. operator_has: TAPi18n.__('operator-has'),
  524. predicate_overdue: TAPi18n.__('predicate-overdue'),
  525. predicate_archived: TAPi18n.__('predicate-archived'),
  526. predicate_all: TAPi18n.__('predicate-all'),
  527. predicate_ended: TAPi18n.__('predicate-ended'),
  528. predicate_week: TAPi18n.__('predicate-week'),
  529. predicate_month: TAPi18n.__('predicate-month'),
  530. predicate_quarter: TAPi18n.__('predicate-quarter'),
  531. predicate_year: TAPi18n.__('predicate-year'),
  532. predicate_attachment: TAPi18n.__('predicate-attachment'),
  533. predicate_description: TAPi18n.__('predicate-description'),
  534. predicate_checklist: TAPi18n.__('predicate-checklist'),
  535. predicate_public: TAPi18n.__('predicate-public'),
  536. predicate_private: TAPi18n.__('predicate-private'),
  537. };
  538. text = `# ${TAPi18n.__('globalSearch-instructions-heading')}`;
  539. text += `\n${TAPi18n.__('globalSearch-instructions-description', tags)}`;
  540. text += `\n${TAPi18n.__('globalSearch-instructions-operators', tags)}`;
  541. text += `\n* ${TAPi18n.__(
  542. 'globalSearch-instructions-operator-board',
  543. tags,
  544. )}`;
  545. text += `\n* ${TAPi18n.__(
  546. 'globalSearch-instructions-operator-list',
  547. tags,
  548. )}`;
  549. text += `\n* ${TAPi18n.__(
  550. 'globalSearch-instructions-operator-swimlane',
  551. tags,
  552. )}`;
  553. text += `\n* ${TAPi18n.__(
  554. 'globalSearch-instructions-operator-comment',
  555. tags,
  556. )}`;
  557. text += `\n* ${TAPi18n.__(
  558. 'globalSearch-instructions-operator-label',
  559. tags,
  560. )}`;
  561. text += `\n* ${TAPi18n.__(
  562. 'globalSearch-instructions-operator-hash',
  563. tags,
  564. )}`;
  565. text += `\n* ${TAPi18n.__(
  566. 'globalSearch-instructions-operator-user',
  567. tags,
  568. )}`;
  569. text += `\n* ${TAPi18n.__('globalSearch-instructions-operator-at', tags)}`;
  570. text += `\n* ${TAPi18n.__(
  571. 'globalSearch-instructions-operator-member',
  572. tags,
  573. )}`;
  574. text += `\n* ${TAPi18n.__(
  575. 'globalSearch-instructions-operator-assignee',
  576. tags,
  577. )}`;
  578. text += `\n* ${TAPi18n.__('globalSearch-instructions-operator-due', tags)}`;
  579. text += `\n* ${TAPi18n.__(
  580. 'globalSearch-instructions-operator-created',
  581. tags,
  582. )}`;
  583. text += `\n* ${TAPi18n.__(
  584. 'globalSearch-instructions-operator-modified',
  585. tags,
  586. )}`;
  587. text += `\n* ${TAPi18n.__(
  588. 'globalSearch-instructions-status-archived',
  589. tags,
  590. )}`;
  591. text += `\n* ${TAPi18n.__(
  592. 'globalSearch-instructions-status-public',
  593. tags,
  594. )}`;
  595. text += `\n* ${TAPi18n.__(
  596. 'globalSearch-instructions-status-private',
  597. tags,
  598. )}`;
  599. text += `\n* ${TAPi18n.__('globalSearch-instructions-status-all', tags)}`;
  600. text += `\n* ${TAPi18n.__('globalSearch-instructions-status-ended', tags)}`;
  601. text += `\n* ${TAPi18n.__('globalSearch-instructions-operator-has', tags)}`;
  602. text += `\n## ${TAPi18n.__('heading-notes')}`;
  603. text += `\n* ${TAPi18n.__('globalSearch-instructions-notes-1', tags)}`;
  604. text += `\n* ${TAPi18n.__('globalSearch-instructions-notes-2', tags)}`;
  605. text += `\n* ${TAPi18n.__('globalSearch-instructions-notes-3', tags)}`;
  606. text += `\n* ${TAPi18n.__('globalSearch-instructions-notes-3-2', tags)}`;
  607. text += `\n* ${TAPi18n.__('globalSearch-instructions-notes-4', tags)}`;
  608. text += `\n* ${TAPi18n.__('globalSearch-instructions-notes-5', tags)}`;
  609. return text;
  610. },
  611. labelColors() {
  612. return Boards.simpleSchema()._schema['labels.$.color'].allowedValues.map(
  613. color => {
  614. return { color, name: TAPi18n.__(`color-${color}`) };
  615. },
  616. );
  617. },
  618. events() {
  619. return [
  620. {
  621. 'submit .js-search-query-form'(evt) {
  622. evt.preventDefault();
  623. this.searchAllBoards(evt.target.searchQuery.value);
  624. },
  625. 'click .js-next-page'(evt) {
  626. evt.preventDefault();
  627. this.nextPage();
  628. },
  629. 'click .js-previous-page'(evt) {
  630. evt.preventDefault();
  631. this.previousPage();
  632. },
  633. 'click .js-label-color'(evt) {
  634. evt.preventDefault();
  635. const input = document.getElementById('global-search-input');
  636. this.query.set(
  637. `${input.value} ${TAPi18n.__('operator-label')}:"${
  638. evt.currentTarget.textContent
  639. }"`,
  640. );
  641. document.getElementById('global-search-input').focus();
  642. },
  643. 'click .js-board-title'(evt) {
  644. evt.preventDefault();
  645. const input = document.getElementById('global-search-input');
  646. this.query.set(
  647. `${input.value} ${TAPi18n.__('operator-board')}:"${
  648. evt.currentTarget.textContent
  649. }"`,
  650. );
  651. document.getElementById('global-search-input').focus();
  652. },
  653. 'click .js-list-title'(evt) {
  654. evt.preventDefault();
  655. const input = document.getElementById('global-search-input');
  656. this.query.set(
  657. `${input.value} ${TAPi18n.__('operator-list')}:"${
  658. evt.currentTarget.textContent
  659. }"`,
  660. );
  661. document.getElementById('global-search-input').focus();
  662. },
  663. 'click .js-label-name'(evt) {
  664. evt.preventDefault();
  665. const input = document.getElementById('global-search-input');
  666. this.query.set(
  667. `${input.value} ${TAPi18n.__('operator-label')}:"${
  668. evt.currentTarget.textContent
  669. }"`,
  670. );
  671. document.getElementById('global-search-input').focus();
  672. },
  673. },
  674. ];
  675. },
  676. }).register('globalSearch');