debian-mirror-gitlab/app/assets/javascripts/boards/components/board_new_issue.vue

78 lines
2 KiB
Vue
Raw Normal View History

2018-03-27 19:54:05 +05:30
<script>
2021-04-17 20:07:23 +05:30
import { mapActions, mapGetters, mapState } from 'vuex';
2019-07-31 22:56:46 +05:30
import { getMilestone } from 'ee_else_ce/boards/boards_util';
2021-04-29 21:17:54 +05:30
import BoardNewIssueMixin from 'ee_else_ce/boards/mixins/board_new_issue';
2021-10-27 15:23:28 +05:30
2021-09-30 23:02:18 +05:30
import { toggleFormEventPrefix } from '../constants';
2017-08-17 22:00:37 +05:30
import eventHub from '../eventhub';
2021-10-27 15:23:28 +05:30
import BoardNewItem from './board_new_item.vue';
2018-03-27 19:54:05 +05:30
import ProjectSelect from './project_select.vue';
2021-01-29 00:20:46 +05:30
2017-08-17 22:00:37 +05:30
export default {
name: 'BoardNewIssue',
2018-03-27 19:54:05 +05:30
components: {
2021-10-27 15:23:28 +05:30
BoardNewItem,
2018-03-27 19:54:05 +05:30
ProjectSelect,
},
2021-04-29 21:17:54 +05:30
mixins: [BoardNewIssueMixin],
inject: ['groupId'],
2017-08-17 22:00:37 +05:30
props: {
2018-03-17 18:26:18 +05:30
list: {
type: Object,
required: true,
},
2017-08-17 22:00:37 +05:30
},
2018-03-27 19:54:05 +05:30
computed: {
2021-10-27 15:23:28 +05:30
...mapState(['selectedProject', 'fullPath']),
...mapGetters(['isGroupBoard']),
formEventPrefix() {
return toggleFormEventPrefix.issue;
2021-09-30 23:02:18 +05:30
},
2021-10-27 15:23:28 +05:30
disableSubmit() {
return this.isGroupBoard ? !this.selectedProject.name : false;
2018-03-27 19:54:05 +05:30
},
2021-10-27 15:23:28 +05:30
projectPath() {
return this.isGroupBoard ? this.selectedProject.fullPath : this.fullPath;
2021-03-08 18:12:59 +05:30
},
2018-03-27 19:54:05 +05:30
},
2017-08-17 22:00:37 +05:30
methods: {
2021-03-08 18:12:59 +05:30
...mapActions(['addListNewIssue']),
2021-10-27 15:23:28 +05:30
submit({ title }) {
2017-08-17 22:00:37 +05:30
const labels = this.list.label ? [this.list.label] : [];
2018-11-08 19:23:39 +05:30
const assignees = this.list.assignee ? [this.list.assignee] : [];
2019-07-31 22:56:46 +05:30
const milestone = getMilestone(this.list);
2021-03-08 18:12:59 +05:30
return this.addListNewIssue({
2021-10-27 15:23:28 +05:30
list: this.list,
2021-03-08 18:12:59 +05:30
issueInput: {
title,
labelIds: labels?.map((l) => l.id),
assigneeIds: assignees?.map((a) => a?.id),
milestoneId: milestone?.id,
2021-10-27 15:23:28 +05:30
projectPath: this.projectPath,
2021-03-08 18:12:59 +05:30
},
}).then(() => {
2021-10-27 15:23:28 +05:30
this.cancel();
2021-03-08 18:12:59 +05:30
});
2017-08-17 22:00:37 +05:30
},
2021-10-27 15:23:28 +05:30
cancel() {
eventHub.$emit(`${this.formEventPrefix}${this.list.id}`);
2017-08-17 22:00:37 +05:30
},
},
2018-03-27 19:54:05 +05:30
};
</script>
<template>
2021-10-27 15:23:28 +05:30
<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-03-27 19:54:05 +05:30
</template>