debian-mirror-gitlab/app/assets/javascripts/issues/new/index.js

59 lines
1.3 KiB
JavaScript
Raw Normal View History

2019-02-15 15:39:39 +05:30
import Vue from 'vue';
import VueApollo from 'vue-apollo';
2019-07-07 11:18:12 +05:30
import createDefaultClient from '~/lib/graphql';
2022-01-26 12:08:38 +05:30
import TitleSuggestions from './components/title_suggestions.vue';
import TypePopover from './components/type_popover.vue';
2019-02-15 15:39:39 +05:30
2022-01-26 12:08:38 +05:30
export function initTitleSuggestions() {
2019-02-15 15:39:39 +05:30
const el = document.getElementById('js-suggestions');
const issueTitle = document.getElementById('issue_title');
2022-01-26 12:08:38 +05:30
if (!el) {
return undefined;
}
2022-03-02 08:16:31 +05:30
Vue.use(VueApollo);
2019-02-15 15:39:39 +05:30
const apolloProvider = new VueApollo({
2021-12-11 22:18:48 +05:30
defaultClient: createDefaultClient(),
2019-02-15 15:39:39 +05:30
});
return new Vue({
el,
2022-04-04 11:22:00 +05:30
name: 'TitleSuggestionsRoot',
2019-02-15 15:39:39 +05:30
apolloProvider,
data() {
return {
search: issueTitle.value,
};
},
mounted() {
issueTitle.addEventListener('input', () => {
this.search = issueTitle.value;
});
},
2022-01-26 12:08:38 +05:30
render(createElement) {
return createElement(TitleSuggestions, {
2019-02-15 15:39:39 +05:30
props: {
2022-01-26 12:08:38 +05:30
projectPath: el.dataset.projectPath,
2019-02-15 15:39:39 +05:30
search: this.search,
},
});
},
});
}
2022-01-26 12:08:38 +05:30
export function initTypePopover() {
const el = document.getElementById('js-type-popover');
if (!el) {
return undefined;
}
return new Vue({
el,
2022-04-04 11:22:00 +05:30
name: 'TypePopoverRoot',
2022-01-26 12:08:38 +05:30
render: (createElement) => createElement(TypePopover),
});
}