2018-02-06 09:44:38 -05:00
|
|
|
<script>
|
2020-07-09 14:10:09 -04:00
|
|
|
import { GlButton } from '@gitlab/ui';
|
2019-04-29 07:06:13 -04:00
|
|
|
import { getMilestone } from 'ee_else_ce/boards/boards_util';
|
2019-09-06 06:46:12 -04:00
|
|
|
import ListIssue from 'ee_else_ce/boards/models/issue';
|
2017-03-15 05:18:05 -04:00
|
|
|
import eventHub from '../eventhub';
|
2018-02-19 14:06:16 -05:00
|
|
|
import ProjectSelect from './project_select.vue';
|
2018-10-10 13:08:43 -04:00
|
|
|
import boardsStore from '../stores/boards_store';
|
2020-09-09 17:08:33 -04:00
|
|
|
import glFeatureFlagMixin from '~/vue_shared/mixins/gl_feature_flags_mixin';
|
2017-02-28 05:23:19 -05:00
|
|
|
|
2020-11-12 04:08:57 -05:00
|
|
|
// This component is being replaced in favor of './board_new_issue_new.vue' for GraphQL boards
|
|
|
|
|
2017-02-28 05:23:19 -05:00
|
|
|
export default {
|
|
|
|
name: 'BoardNewIssue',
|
2018-02-19 14:06:16 -05:00
|
|
|
components: {
|
|
|
|
ProjectSelect,
|
2020-07-09 14:10:09 -04:00
|
|
|
GlButton,
|
2018-02-19 14:06:16 -05:00
|
|
|
},
|
2020-09-09 17:08:33 -04:00
|
|
|
mixins: [glFeatureFlagMixin()],
|
2017-02-28 05:23:19 -05:00
|
|
|
props: {
|
2017-09-06 01:02:30 -04:00
|
|
|
list: {
|
|
|
|
type: Object,
|
|
|
|
required: true,
|
|
|
|
},
|
2017-02-28 05:23:19 -05:00
|
|
|
},
|
2020-10-07 05:09:13 -04:00
|
|
|
inject: ['groupId'],
|
2017-02-28 05:23:19 -05:00
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
title: '',
|
|
|
|
error: false,
|
2018-02-19 14:06:16 -05:00
|
|
|
selectedProject: {},
|
2017-02-28 05:23:19 -05:00
|
|
|
};
|
|
|
|
},
|
2018-02-19 14:06:16 -05:00
|
|
|
computed: {
|
|
|
|
disabled() {
|
|
|
|
if (this.groupId) {
|
|
|
|
return this.title === '' || !this.selectedProject.name;
|
|
|
|
}
|
|
|
|
return this.title === '';
|
|
|
|
},
|
|
|
|
},
|
2018-02-06 09:44:38 -05:00
|
|
|
mounted() {
|
|
|
|
this.$refs.input.focus();
|
2018-02-19 14:06:16 -05:00
|
|
|
eventHub.$on('setSelectedProject', this.setSelectedProject);
|
2018-02-06 09:44:38 -05:00
|
|
|
},
|
2017-02-28 05:23:19 -05:00
|
|
|
methods: {
|
|
|
|
submit(e) {
|
|
|
|
e.preventDefault();
|
2017-06-23 05:28:19 -04:00
|
|
|
if (this.title.trim() === '') return Promise.resolve();
|
2017-02-28 05:23:19 -05:00
|
|
|
|
|
|
|
this.error = false;
|
|
|
|
|
|
|
|
const labels = this.list.label ? [this.list.label] : [];
|
2018-06-07 16:54:24 -04:00
|
|
|
const assignees = this.list.assignee ? [this.list.assignee] : [];
|
2019-04-29 07:06:13 -04:00
|
|
|
const milestone = getMilestone(this.list);
|
|
|
|
|
2019-09-06 06:46:12 -04:00
|
|
|
const { weightFeatureAvailable } = boardsStore;
|
|
|
|
const { weight } = weightFeatureAvailable ? boardsStore.state.currentBoard : {};
|
|
|
|
|
2017-02-28 05:23:19 -05:00
|
|
|
const issue = new ListIssue({
|
|
|
|
title: this.title,
|
|
|
|
labels,
|
|
|
|
subscribed: true,
|
2018-06-07 16:54:24 -04:00
|
|
|
assignees,
|
2019-04-29 07:06:13 -04:00
|
|
|
milestone,
|
2018-02-19 14:06:16 -05:00
|
|
|
project_id: this.selectedProject.id,
|
2019-09-06 06:46:12 -04:00
|
|
|
weight,
|
2017-02-28 05:23:19 -05:00
|
|
|
});
|
|
|
|
|
2017-06-23 05:28:19 -04:00
|
|
|
eventHub.$emit(`scroll-board-list-${this.list.id}`);
|
|
|
|
this.cancel();
|
|
|
|
|
2018-10-30 16:28:31 -04:00
|
|
|
return this.list
|
|
|
|
.newIssue(issue)
|
2017-02-28 05:23:19 -05:00
|
|
|
.then(() => {
|
2020-11-12 04:08:57 -05:00
|
|
|
boardsStore.setIssueDetail(issue);
|
|
|
|
boardsStore.setListDetail(this.list);
|
2017-02-28 05:23:19 -05:00
|
|
|
})
|
|
|
|
.catch(() => {
|
2020-11-12 04:08:57 -05:00
|
|
|
this.list.removeIssue(issue);
|
2017-02-28 05:23:19 -05:00
|
|
|
|
|
|
|
// Show error message
|
|
|
|
this.error = true;
|
|
|
|
});
|
|
|
|
},
|
|
|
|
cancel() {
|
|
|
|
this.title = '';
|
2020-06-11 05:08:16 -04:00
|
|
|
eventHub.$emit(`toggle-issue-form-${this.list.id}`);
|
2017-02-28 05:23:19 -05:00
|
|
|
},
|
2018-02-19 14:06:16 -05:00
|
|
|
setSelectedProject(selectedProject) {
|
|
|
|
this.selectedProject = selectedProject;
|
|
|
|
},
|
2017-02-28 05:23:19 -05:00
|
|
|
},
|
|
|
|
};
|
2018-02-06 09:44:38 -05:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
2018-02-19 14:06:16 -05:00
|
|
|
<div class="board-new-issue-form">
|
2019-04-16 10:41:25 -04:00
|
|
|
<div class="board-card position-relative p-3 rounded">
|
2019-01-10 16:56:37 -05:00
|
|
|
<form @submit="submit($event)">
|
2018-11-16 15:07:38 -05:00
|
|
|
<div v-if="error" class="flash-container">
|
2019-06-28 15:28:02 -04:00
|
|
|
<div class="flash-alert">{{ __('An error occurred. Please try again.') }}</div>
|
2018-02-19 14:06:16 -05:00
|
|
|
</div>
|
2019-06-28 15:28:02 -04:00
|
|
|
<label :for="list.id + '-title'" class="label-bold">{{ __('Title') }}</label>
|
2018-02-19 14:06:16 -05:00
|
|
|
<input
|
2018-09-20 02:13:50 -04:00
|
|
|
:id="list.id + '-title'"
|
2018-06-11 05:49:47 -04:00
|
|
|
ref="input"
|
|
|
|
v-model="title"
|
2018-02-19 14:06:16 -05:00
|
|
|
class="form-control"
|
|
|
|
type="text"
|
2018-08-01 12:17:56 -04:00
|
|
|
name="issue_title"
|
2018-02-19 14:06:16 -05:00
|
|
|
autocomplete="off"
|
|
|
|
/>
|
2019-09-04 12:33:02 -04:00
|
|
|
<project-select v-if="groupId" :group-id="groupId" :list="list" />
|
2020-07-27 17:09:16 -04:00
|
|
|
<div class="clearfix gl-mt-3">
|
2020-07-09 14:10:09 -04:00
|
|
|
<gl-button
|
2020-09-17 05:09:32 -04:00
|
|
|
ref="submitButton"
|
2018-06-11 05:49:47 -04:00
|
|
|
:disabled="disabled"
|
2020-11-12 04:08:57 -05:00
|
|
|
class="float-left js-no-auto-disable"
|
2018-09-26 16:44:48 -04:00
|
|
|
variant="success"
|
2020-07-09 14:10:09 -04:00
|
|
|
category="primary"
|
2018-02-19 14:06:16 -05:00
|
|
|
type="submit"
|
2020-07-09 14:10:09 -04:00
|
|
|
>{{ __('Submit issue') }}</gl-button
|
2018-02-19 14:06:16 -05:00
|
|
|
>
|
2020-09-17 05:09:32 -04:00
|
|
|
<gl-button
|
|
|
|
ref="cancelButton"
|
|
|
|
class="float-right"
|
|
|
|
type="button"
|
|
|
|
variant="default"
|
|
|
|
@click="cancel"
|
|
|
|
>{{ __('Cancel') }}</gl-button
|
|
|
|
>
|
2018-02-19 14:06:16 -05:00
|
|
|
</div>
|
|
|
|
</form>
|
|
|
|
</div>
|
2018-02-06 09:44:38 -05:00
|
|
|
</div>
|
|
|
|
</template>
|