2018-02-06 09:44:38 -05:00
|
|
|
<script>
|
2021-03-10 04:09:29 -05:00
|
|
|
import { mapActions, mapGetters, mapState } from 'vuex';
|
2019-04-29 07:06:13 -04:00
|
|
|
import { getMilestone } from 'ee_else_ce/boards/boards_util';
|
2021-03-26 05:09:24 -04:00
|
|
|
import BoardNewIssueMixin from 'ee_else_ce/boards/mixins/board_new_issue';
|
2021-07-20 20:09:07 -04:00
|
|
|
|
2021-06-17 11:10:03 -04:00
|
|
|
import { toggleFormEventPrefix } from '../constants';
|
2021-02-01 10:08:56 -05:00
|
|
|
import eventHub from '../eventhub';
|
2021-07-20 20:09:07 -04:00
|
|
|
|
|
|
|
import BoardNewItem from './board_new_item.vue';
|
2021-02-01 10:08:56 -05:00
|
|
|
import ProjectSelect from './project_select.vue';
|
2020-11-12 04:08:57 -05:00
|
|
|
|
2017-02-28 05:23:19 -05:00
|
|
|
export default {
|
|
|
|
name: 'BoardNewIssue',
|
2018-02-19 14:06:16 -05:00
|
|
|
components: {
|
2021-07-20 20:09:07 -04:00
|
|
|
BoardNewItem,
|
2018-02-19 14:06:16 -05:00
|
|
|
ProjectSelect,
|
|
|
|
},
|
2021-03-26 05:09:24 -04:00
|
|
|
mixins: [BoardNewIssueMixin],
|
|
|
|
inject: ['groupId'],
|
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
|
|
|
},
|
2018-02-19 14:06:16 -05:00
|
|
|
computed: {
|
2021-07-20 20:09:07 -04:00
|
|
|
...mapState(['selectedProject', 'fullPath']),
|
|
|
|
...mapGetters(['isGroupBoard']),
|
|
|
|
formEventPrefix() {
|
|
|
|
return toggleFormEventPrefix.issue;
|
2021-06-17 11:10:03 -04:00
|
|
|
},
|
2021-07-20 20:09:07 -04:00
|
|
|
disableSubmit() {
|
|
|
|
return this.isGroupBoard ? !this.selectedProject.name : false;
|
2018-02-19 14:06:16 -05:00
|
|
|
},
|
2021-07-20 20:09:07 -04:00
|
|
|
projectPath() {
|
|
|
|
return this.isGroupBoard ? this.selectedProject.fullPath : this.fullPath;
|
2021-01-18 04:11:05 -05:00
|
|
|
},
|
2018-02-19 14:06:16 -05:00
|
|
|
},
|
2017-02-28 05:23:19 -05:00
|
|
|
methods: {
|
2021-01-18 04:11:05 -05:00
|
|
|
...mapActions(['addListNewIssue']),
|
2021-07-20 20:09:07 -04:00
|
|
|
submit({ title }) {
|
2017-02-28 05:23:19 -05:00
|
|
|
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);
|
|
|
|
|
2021-01-18 04:11:05 -05:00
|
|
|
return this.addListNewIssue({
|
2021-07-20 20:09:07 -04:00
|
|
|
list: this.list,
|
2021-01-18 04:11:05 -05:00
|
|
|
issueInput: {
|
|
|
|
title,
|
|
|
|
labelIds: labels?.map((l) => l.id),
|
|
|
|
assigneeIds: assignees?.map((a) => a?.id),
|
|
|
|
milestoneId: milestone?.id,
|
2021-07-20 20:09:07 -04:00
|
|
|
projectPath: this.projectPath,
|
2021-01-18 04:11:05 -05:00
|
|
|
},
|
|
|
|
}).then(() => {
|
2021-07-20 20:09:07 -04:00
|
|
|
this.cancel();
|
2021-01-18 04:11:05 -05:00
|
|
|
});
|
2017-02-28 05:23:19 -05:00
|
|
|
},
|
2021-07-20 20:09:07 -04:00
|
|
|
cancel() {
|
|
|
|
eventHub.$emit(`${this.formEventPrefix}${this.list.id}`);
|
2017-02-28 05:23:19 -05:00
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
2018-02-06 09:44:38 -05:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
2021-07-20 20:09:07 -04:00
|
|
|
<board-new-item
|
|
|
|
:list="list"
|
|
|
|
:form-event-prefix="formEventPrefix"
|
|
|
|
:submit-button-title="__('Create issue')"
|
|
|
|
:disable-submit="disableSubmit"
|
|
|
|
@form-submit="submit"
|
|
|
|
@form-cancel="cancel"
|
|
|
|
>
|
|
|
|
<project-select v-if="isGroupBoard" :group-id="groupId" :list="list" />
|
|
|
|
</board-new-item>
|
2018-02-06 09:44:38 -05:00
|
|
|
</template>
|