summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/boards/components/modal/header.js
blob: 70c088f905414d195cf9f7be4521cc5ff143ddfd (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
/* global Vue */
require('./tabs');
const modalFilters = require('./filters');

(() => {
  const ModalStore = gl.issueBoards.ModalStore;

  gl.issueBoards.ModalHeader = Vue.extend({
    mixins: [gl.issueBoards.ModalMixins],
    props: {
      projectId: {
        type: Number,
        required: true,
      },
      milestonePath: {
        type: String,
        required: true,
      },
      labelPath: {
        type: String,
        required: true,
      },
    },
    data() {
      return ModalStore.store;
    },
    computed: {
      selectAllText() {
        if (ModalStore.selectedCount() !== this.issues.length || this.issues.length === 0) {
          return 'Select all';
        }

        return 'Deselect all';
      },
      showSearch() {
        return this.activeTab === 'all' && !this.loading && this.issuesCount > 0;
      },
    },
    methods: {
      toggleAll() {
        this.$refs.selectAllBtn.blur();

        ModalStore.toggleAll();
      },
    },
    components: {
      'modal-tabs': gl.issueBoards.ModalTabs,
      modalFilters,
    },
    template: `
      <div>
        <header class="add-issues-header form-actions">
          <h2>
            Add issues
            <button
              type="button"
              class="close"
              data-dismiss="modal"
              aria-label="Close"
              @click="toggleModal(false)">
              <span aria-hidden="true">×</span>
            </button>
          </h2>
        </header>
        <modal-tabs v-if="!loading && issuesCount > 0"></modal-tabs>
        <div
          class="add-issues-search append-bottom-10"
          v-if="showSearch">
          <modal-filters
            :project-id="projectId"
            :milestone-path="milestonePath"
            :label-path="labelPath">
          </modal-filters>
          <input
            placeholder="Search issues..."
            class="form-control"
            type="search"
            v-model="searchTerm" />
          <button
            type="button"
            class="btn btn-success btn-inverted prepend-left-10"
            ref="selectAllBtn"
            @click="toggleAll">
            {{ selectAllText }}
          </button>
        </div>
      </div>
    `,
  });
})();