summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/work_items/components/item_state.vue
blob: 2a0913e380a47f4dbb48ea89f621be18fa324aa6 (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
<script>
import { GlFormGroup, GlFormSelect } from '@gitlab/ui';
import { __ } from '~/locale';
import { STATE_OPEN, STATE_CLOSED } from '../constants';

export default {
  i18n: {
    status: __('Status'),
  },
  states: [
    {
      value: STATE_OPEN,
      text: __('Open'),
    },
    {
      value: STATE_CLOSED,
      text: __('Closed'),
    },
  ],
  components: {
    GlFormGroup,
    GlFormSelect,
  },
  props: {
    state: {
      type: String,
      required: true,
    },
    disabled: {
      type: Boolean,
      required: false,
      default: false,
    },
  },
  computed: {
    currentState() {
      return this.$options.states[this.state];
    },
  },
  methods: {
    setState(newState) {
      if (newState !== this.state) {
        this.$emit('changed', newState);
      }
    },
  },
  labelId: 'work-item-state-select',
};
</script>

<template>
  <gl-form-group
    :label="$options.i18n.status"
    :label-for="$options.labelId"
    label-cols="3"
    label-cols-lg="2"
    label-class="gl-pb-0! gl-overflow-wrap-break"
    class="gl-align-items-center"
  >
    <gl-form-select
      :id="$options.labelId"
      :value="state"
      :options="$options.states"
      :disabled="disabled"
      class="gl-w-auto hide-select-decoration gl-pl-3"
      :class="{ 'gl-bg-transparent! gl-cursor-text!': disabled }"
      @change="setState"
    />
  </gl-form-group>
</template>

<style>
.hide-select-decoration:not(:focus, :hover),
.hide-select-decoration:disabled {
  background-image: none;
  box-shadow: none;
}
</style>