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

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

86 lines
1.9 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';
2023-06-20 00:43:36 +05:30
import { parseBoolean } from '~/lib/utils/common_utils';
2022-01-26 12:08:38 +05:30
import TitleSuggestions from './components/title_suggestions.vue';
import TypePopover from './components/type_popover.vue';
2023-06-20 00:43:36 +05:30
import TypeSelect from './components/type_select.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),
});
}
2023-06-20 00:43:36 +05:30
export function initTypeSelect() {
const el = document.getElementById('js-type-select');
if (!el) {
return undefined;
}
const { selectedType, isIssueAllowed, isIncidentAllowed, issuePath, incidentPath } = el.dataset;
return new Vue({
el,
name: 'TypeSelectRoot',
render: (createElement) =>
createElement(TypeSelect, {
props: {
selectedType,
isIssueAllowed: parseBoolean(isIssueAllowed),
isIncidentAllowed: parseBoolean(isIncidentAllowed),
issuePath,
incidentPath,
},
}),
});
}