summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/boards/components/sidebar/remove_issue.js.es6
blob: 124baaae42ad6ead6594ace3dd960c93ee88290e (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
/* global Vue */
(() => {
  const Store = gl.issueBoards.BoardsStore;

  window.gl = window.gl || {};
  window.gl.issueBoards = window.gl.issueBoards || {};

  gl.issueBoards.RemoveIssueBtn = Vue.extend({
    props: {
      issue: {
        type: Object,
        required: true,
      },
      list: {
        type: Object,
        required: true,
      },
    },
    methods: {
      removeIssue() {
        const lists = this.issue.getLists();
        const labelIds = lists.map(list => list.label.id);

        // Post the remove data
        gl.boardService.bulkUpdate([this.issue.globalId], {
          remove_label_ids: labelIds,
        });

        // Remove from the frontend store
        lists.forEach((list) => {
          list.removeIssue(this.issue);
        });

        Store.detail.issue = {};
      },
    },
    template: `
      <div
        class="block list"
        v-if="list.type !== 'done'">
        <button
          class="btn btn-default btn-block"
          type="button"
          @click="removeIssue">
          Remove from board
        </button>
      </div>
    `,
  });
})();