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

status_select.vue « components « issuable_bulk_update_sidebar « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 9509399e91dd69701baee570d7a9d7ffc1c33c8d (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
<script>
import { GlDropdown, GlDropdownItem } from '@gitlab/ui';
import { __ } from '~/locale';
import { ISSUE_STATUS_SELECT_OPTIONS } from '../constants';

export default {
  name: 'StatusSelect',
  components: {
    GlDropdown,
    GlDropdownItem,
  },
  data() {
    return {
      status: null,
    };
  },
  computed: {
    dropdownText() {
      return this.status?.text ?? this.$options.i18n.defaultDropdownText;
    },
    selectedValue() {
      return this.status?.value;
    },
  },
  methods: {
    onDropdownItemClick(statusOption) {
      // clear status if the currently checked status is clicked again
      if (this.status?.value === statusOption.value) {
        this.status = null;
      } else {
        this.status = statusOption;
      }
    },
  },
  i18n: {
    dropdownTitle: __('Change status'),
    defaultDropdownText: __('Select status'),
  },
  ISSUE_STATUS_SELECT_OPTIONS,
};
</script>
<template>
  <div>
    <input type="hidden" name="update[state_event]" :value="selectedValue" />
    <gl-dropdown :text="dropdownText" :title="$options.i18n.dropdownTitle" class="gl-w-full">
      <gl-dropdown-item
        v-for="statusOption in $options.ISSUE_STATUS_SELECT_OPTIONS"
        :key="statusOption.value"
        :is-checked="selectedValue === statusOption.value"
        is-check-item
        :title="statusOption.text"
        @click="onDropdownItemClick(statusOption)"
      >
        {{ statusOption.text }}
      </gl-dropdown-item>
    </gl-dropdown>
  </div>
</template>