summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/boards/components/modal/lists_dropdown.vue
blob: fe10e7fb85684bef0fe3080a7ff9972171a4a082 (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
<script>
import { GlLink, GlIcon } from '@gitlab/ui';
import ModalStore from '../../stores/modal_store';
import boardsStore from '../../stores/boards_store';

export default {
  components: {
    GlLink,
    GlIcon,
  },
  data() {
    return {
      modal: ModalStore.store,
      state: boardsStore.state,
    };
  },
  computed: {
    selected() {
      return this.modal.selectedList || this.state.lists[1];
    },
  },
  destroyed() {
    this.modal.selectedList = null;
  },
};
</script>
<template>
  <div class="dropdown inline">
    <button class="dropdown-menu-toggle" type="button" data-toggle="dropdown" aria-expanded="false">
      <span :style="{ backgroundColor: selected.label.color }" class="dropdown-label-box"> </span>
      {{ selected.title }} <gl-icon name="chevron-down" class="dropdown-menu-toggle-icon" />
    </button>
    <div class="dropdown-menu dropdown-menu-selectable dropdown-menu-drop-up">
      <ul>
        <li v-for="(list, i) in state.lists" v-if="list.type == 'label'" :key="i">
          <gl-link
            :class="{ 'is-active': list.id == selected.id }"
            href="#"
            role="button"
            @click.prevent="modal.selectedList = list"
          >
            <span :style="{ backgroundColor: list.label.color }" class="dropdown-label-box"> </span>
            {{ list.title }}
          </gl-link>
        </li>
      </ul>
    </div>
  </div>
</template>