Welcome to mirror list, hosted at ThFree Co, Russian Federation.

board_new_item.vue « components « boards « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 084b7519d1f613793cb970f85a0b66ae7b87318b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
<script>
import { GlForm, GlFormInput, GlButton } from '@gitlab/ui';
import { __ } from '~/locale';

import eventHub from '../eventhub';

export default {
  i18n: {
    cancel: __('Cancel'),
  },
  components: {
    GlForm,
    GlFormInput,
    GlButton,
  },
  props: {
    list: {
      type: Object,
      required: true,
    },
    formEventPrefix: {
      type: String,
      required: true,
    },
    disableSubmit: {
      type: Boolean,
      required: false,
      default: false,
    },
    submitButtonTitle: {
      type: String,
      required: false,
      default: __('Create issue'),
    },
  },
  data() {
    return {
      title: '',
    };
  },
  computed: {
    inputFieldId() {
      // eslint-disable-next-line @gitlab/require-i18n-strings
      return `${this.list.id}-title`;
    },
    isIssueTitleEmpty() {
      return this.title.trim() === '';
    },
    isCreatingIssueDisabled() {
      return this.isIssueTitleEmpty || this.disableSubmit;
    },
  },
  methods: {
    handleFormCancel() {
      this.title = '';
      this.$emit('form-cancel');
    },
    handleFormSubmit() {
      const { title, list } = this;

      eventHub.$emit(`scroll-board-list-${this.list.id}`);
      this.$emit('form-submit', {
        title: title.trim(),
        list,
      });
    },
  },
};
</script>

<template>
  <div class="board-new-issue-form gl-z-index-3 gl-m-3">
    <div class="board-card position-relative gl-p-5 rounded">
      <gl-form @submit.prevent="handleFormSubmit" @reset="handleFormCancel">
        <label :for="inputFieldId" class="gl-font-weight-bold">{{ __('Title') }}</label>
        <gl-form-input
          :id="inputFieldId"
          v-model="title"
          :autofocus="true"
          autocomplete="off"
          type="text"
          name="issue_title"
        />
        <slot></slot>
        <div class="gl-clearfix gl-mt-4">
          <gl-button
            data-testid="create-button"
            :disabled="isCreatingIssueDisabled"
            class="gl-float-left js-no-auto-disable"
            variant="confirm"
            type="submit"
          >
            {{ submitButtonTitle }}
          </gl-button>
          <gl-button class="gl-float-right js-no-auto-disable" type="reset">
            {{ $options.i18n.cancel }}
          </gl-button>
        </div>
      </gl-form>
    </div>
  </div>
</template>