Commit a3cfd4b4 authored by Kushal Pandya's avatar Kushal Pandya Committed by Mark Chao

Add `&` support for epics autocompletion

parent 499fb780
import $ from 'jquery';
import _ from 'underscore';
// EE-specific
import setupAutoCompleteEpics from 'ee/gfm_auto_complete_ee';
import glRegexp from './lib/utils/regexp';
import AjaxCache from './lib/utils/ajax_cache';
......@@ -51,6 +55,9 @@ class GfmAutoComplete {
if (this.enableMap.mergeRequests) this.setupMergeRequests($input);
if (this.enableMap.labels) this.setupLabels($input);
// EE-specific
if (this.enableMap.epics) setupAutoCompleteEpics($input, this.getDefaultCallbacks());
// We don't instantiate the quick actions autocomplete for note and issue/MR edit forms
$input.filter('[data-supports-quick-actions="true"]').atwho({
at: '/',
......
import $ from 'jquery';
import GfmAutoComplete from '~/gfm_auto_complete';
const setupAutoCompleteEpics = ($input, defaultCallbacks) => {
$input.atwho({
at: '&',
alias: 'epics',
searchKey: 'search',
displayTpl(value) {
let tmpl = GfmAutoComplete.Loading.template;
if (value.title != null) {
tmpl = GfmAutoComplete.Issues.template;
}
return tmpl;
},
data: GfmAutoComplete.defaultLoadingData,
// eslint-disable-next-line no-template-curly-in-string
insertTpl: '${atwho-at}${id}',
callbacks: {
...defaultCallbacks,
beforeSave(merges) {
return $.map(merges, (m) => {
if (m.title == null) {
return m;
}
return {
id: m.iid,
title: m.title.replace(/<(?:.|\n)*?>/gm, ''),
search: `${m.iid} ${m.title}`,
};
});
},
},
});
};
export default setupAutoCompleteEpics;
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment