boards_bundle.js.es6 1.24 KB
Newer Older
Phil Hughes's avatar
Phil Hughes committed
1 2 3
//= require vue
//= require vue-resource
//= require Sortable
4
//= require_tree ./models
Phil Hughes's avatar
Phil Hughes committed
5 6
//= require_tree ./stores
//= require_tree ./services
7
//= require_tree ./mixins
Phil Hughes's avatar
Phil Hughes committed
8 9 10
//= require_tree ./components

$(function () {
11 12 13
  if (!window.gl) {
    window.gl = {};
  }
Phil Hughes's avatar
Phil Hughes committed
14

15 16 17 18 19
  if (gl.IssueBoardsApp) {
    gl.IssueBoardsApp.$destroy(true);
  }

  gl.IssueBoardsApp = new Vue({
Phil Hughes's avatar
Phil Hughes committed
20
    el: '#board-app',
21
    props: {
22
      disabled: Boolean,
23 24
      endpoint: String,
      issueLinkBase: String
25
    },
Phil Hughes's avatar
Phil Hughes committed
26
    data: {
27 28
      state: BoardsStore.state,
      loading: true
Phil Hughes's avatar
Phil Hughes committed
29
    },
30 31 32
    init: function () {
      BoardsStore.create();
    },
33 34 35 36
    created: function () {
      this.loading = true;
      gl.boardService = new BoardService(this.endpoint);
    },
Phil Hughes's avatar
Phil Hughes committed
37
    ready: function () {
38
      BoardsStore.disabled = this.disabled;
39
      gl.boardService.all()
Phil Hughes's avatar
Phil Hughes committed
40
        .then((resp) => {
Phil Hughes's avatar
Phil Hughes committed
41 42 43
          const boards = resp.json();

          boards.forEach((board) => {
Phil Hughes's avatar
Phil Hughes committed
44
            const list = BoardsStore.addList(board);
45 46 47

            if (list.type === 'done') {
              list.position = 9999999;
Phil Hughes's avatar
Phil Hughes committed
48 49
            } else if (list.type === 'backlog') {
              list.position = -1;
50
            }
Phil Hughes's avatar
Phil Hughes committed
51
          });
52 53

          BoardsStore.addBlankState();
54
          this.loading = false;
Phil Hughes's avatar
Phil Hughes committed
55 56 57 58
        });
    }
  });
});