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

125 lines
3.2 KiB
Vue
Raw Normal View History

2018-03-27 19:54:05 +05:30
<script>
2020-07-28 23:09:34 +05:30
import { GlButton } from '@gitlab/ui';
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-03-11 19:13:27 +05:30
import { __ } from '~/locale';
2017-08-17 22:00:37 +05:30
import eventHub from '../eventhub';
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',
2021-03-08 18:12:59 +05:30
i18n: {
2021-04-29 21:17:54 +05:30
submit: __('Create issue'),
2021-03-08 18:12:59 +05:30
cancel: __('Cancel'),
},
2018-03-27 19:54:05 +05:30
components: {
ProjectSelect,
2020-07-28 23:09:34 +05:30
GlButton,
2018-03-27 19:54:05 +05:30
},
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
},
data() {
return {
title: '',
};
},
2018-03-27 19:54:05 +05:30
computed: {
2021-03-08 18:12:59 +05:30
...mapState(['selectedProject']),
2021-04-17 20:07:23 +05:30
...mapGetters(['isGroupBoard']),
2018-03-27 19:54:05 +05:30
disabled() {
2021-04-17 20:07:23 +05:30
if (this.isGroupBoard) {
2018-03-27 19:54:05 +05:30
return this.title === '' || !this.selectedProject.name;
}
return this.title === '';
},
2021-03-08 18:12:59 +05:30
inputFieldId() {
// eslint-disable-next-line @gitlab/require-i18n-strings
return `${this.list.id}-title`;
},
2018-03-27 19:54:05 +05:30
},
mounted() {
this.$refs.input.focus();
eventHub.$on('setSelectedProject', this.setSelectedProject);
},
2017-08-17 22:00:37 +05:30
methods: {
2021-03-08 18:12:59 +05:30
...mapActions(['addListNewIssue']),
2017-08-17 22:00:37 +05:30
submit(e) {
e.preventDefault();
2021-04-29 21:17:54 +05:30
const { title } = this;
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);
2017-09-10 17:25:29 +05:30
eventHub.$emit(`scroll-board-list-${this.list.id}`);
2021-03-08 18:12:59 +05:30
return this.addListNewIssue({
issueInput: {
title,
labelIds: labels?.map((l) => l.id),
assigneeIds: assignees?.map((a) => a?.id),
milestoneId: milestone?.id,
projectPath: this.selectedProject.fullPath,
2021-04-29 21:17:54 +05:30
...this.extraIssueInput(),
2021-03-08 18:12:59 +05:30
},
list: this.list,
}).then(() => {
this.reset();
});
2017-08-17 22:00:37 +05:30
},
2021-03-08 18:12:59 +05:30
reset() {
2017-08-17 22:00:37 +05:30
this.title = '';
2020-06-23 00:09:42 +05:30
eventHub.$emit(`toggle-issue-form-${this.list.id}`);
2017-08-17 22:00:37 +05:30
},
},
2018-03-27 19:54:05 +05:30
};
</script>
<template>
<div class="board-new-issue-form">
2019-07-31 22:56:46 +05:30
<div class="board-card position-relative p-3 rounded">
2021-03-08 18:12:59 +05:30
<form ref="submitForm" @submit="submit">
<label :for="inputFieldId" class="label-bold">{{ __('Title') }}</label>
2018-03-27 19:54:05 +05:30
<input
2021-03-08 18:12:59 +05:30
:id="inputFieldId"
2018-11-08 19:23:39 +05:30
ref="input"
v-model="title"
2018-03-27 19:54:05 +05:30
class="form-control"
2017-08-17 22:00:37 +05:30
type="text"
2018-11-18 11:00:15 +05:30
name="issue_title"
2017-09-10 17:25:29 +05:30
autocomplete="off"
2018-03-27 19:54:05 +05:30
/>
2021-04-17 20:07:23 +05:30
<project-select v-if="isGroupBoard" :group-id="groupId" :list="list" />
2020-10-24 23:57:45 +05:30
<div class="clearfix gl-mt-3">
2020-07-28 23:09:34 +05:30
<gl-button
2020-11-24 15:15:51 +05:30
ref="submitButton"
2018-11-08 19:23:39 +05:30
:disabled="disabled"
2021-01-29 00:20:46 +05:30
class="float-left js-no-auto-disable"
2021-09-04 01:27:46 +05:30
variant="confirm"
2020-07-28 23:09:34 +05:30
category="primary"
2018-11-08 19:23:39 +05:30
type="submit"
2018-03-27 19:54:05 +05:30
>
2021-03-08 18:12:59 +05:30
{{ $options.i18n.submit }}
</gl-button>
2020-11-24 15:15:51 +05:30
<gl-button
ref="cancelButton"
class="float-right"
type="button"
variant="default"
2021-03-08 18:12:59 +05:30
@click="reset"
2020-11-24 15:15:51 +05:30
>
2021-03-08 18:12:59 +05:30
{{ $options.i18n.cancel }}
</gl-button>
2017-08-17 22:00:37 +05:30
</div>
</form>
</div>
2018-03-27 19:54:05 +05:30
</div>
</template>