BigW Consortium Gitlab

header.js 1.76 KB
Newer Older
1
import Vue from 'vue';
2
import modalFilters from './filters';
3
import './tabs';
Phil Hughes committed
4

5
const ModalStore = gl.issueBoards.ModalStore;
6

7 8 9 10 11 12
gl.issueBoards.ModalHeader = Vue.extend({
  mixins: [gl.issueBoards.ModalMixins],
  props: {
    projectId: {
      type: Number,
      required: true,
Phil Hughes committed
13
    },
14 15 16
    milestonePath: {
      type: String,
      required: true,
17
    },
18 19 20
    labelPath: {
      type: String,
      required: true,
Phil Hughes committed
21
    },
22 23 24 25 26 27 28 29 30
  },
  data() {
    return ModalStore.store;
  },
  computed: {
    selectAllText() {
      if (ModalStore.selectedCount() !== this.issues.length || this.issues.length === 0) {
        return 'Select all';
      }
Phil Hughes committed
31

32 33 34 35
      return 'Deselect all';
    },
    showSearch() {
      return this.activeTab === 'all' && !this.loading && this.issuesCount > 0;
Phil Hughes committed
36
    },
37 38 39 40 41 42
  },
  methods: {
    toggleAll() {
      this.$refs.selectAllBtn.blur();

      ModalStore.toggleAll();
43
    },
44 45 46 47 48 49 50 51 52 53
  },
  components: {
    'modal-tabs': gl.issueBoards.ModalTabs,
    modalFilters,
  },
  template: `
    <div>
      <header class="add-issues-header form-actions">
        <h2>
          Add issues
Phil Hughes committed
54 55
          <button
            type="button"
56 57 58 59 60
            class="close"
            data-dismiss="modal"
            aria-label="Close"
            @click="toggleModal(false)">
            <span aria-hidden="true">×</span>
Phil Hughes committed
61
          </button>
62 63 64 65 66 67 68 69 70 71 72 73 74 75
        </h2>
      </header>
      <modal-tabs v-if="!loading && issuesCount > 0"></modal-tabs>
      <div
        class="add-issues-search append-bottom-10"
        v-if="showSearch">
        <modal-filters :store="filter" />
        <button
          type="button"
          class="btn btn-success btn-inverted prepend-left-10"
          ref="selectAllBtn"
          @click="toggleAll">
          {{ selectAllText }}
        </button>
76
      </div>
77 78 79
    </div>
  `,
});