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

127 lines
3.3 KiB
Vue
Raw Normal View History

2018-03-27 19:54:05 +05:30
<script>
2021-03-08 18:12:59 +05:30
import { mapActions, mapState } from 'vuex';
2020-07-28 23:09:34 +05:30
import { GlButton } from '@gitlab/ui';
2019-07-31 22:56:46 +05:30
import { getMilestone } from 'ee_else_ce/boards/boards_util';
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';
2020-11-24 15:15:51 +05:30
import glFeatureFlagMixin from '~/vue_shared/mixins/gl_feature_flags_mixin';
2021-03-08 18:12:59 +05:30
import { __ } from '~/locale';
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: {
submit: __('Submit issue'),
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
},
2020-11-24 15:15:51 +05:30
mixins: [glFeatureFlagMixin()],
2021-03-08 18:12:59 +05:30
inject: ['groupId', 'weightFeatureAvailable', 'boardWeight'],
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']),
2018-03-27 19:54:05 +05:30
disabled() {
if (this.groupId) {
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();
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
const weight = this.weightFeatureAvailable ? this.boardWeight : undefined;
2019-12-04 20:38:33 +05:30
2021-03-08 18:12:59 +05:30
const { title } = this;
2017-08-17 22:00:37 +05:30
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,
weight: weight >= 0 ? weight : null,
},
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
/>
2019-12-04 20:38:33 +05:30
<project-select v-if="groupId" :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"
2018-12-05 23:21:45 +05:30
variant="success"
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>