BigW Consortium Gitlab

boards_bundle.js.es6 1.51 KB
Newer Older
Phil Hughes committed
1 2 3
//= require vue
//= require vue-resource
//= require Sortable
4
//= require_tree ./models
Phil Hughes committed
5 6
//= require_tree ./stores
//= require_tree ./services
7
//= require_tree ./mixins
8 9
//= require ./components/board
//= require ./components/new_list_dropdown
10
//= require ./vue_resource_interceptor
Phil Hughes committed
11

12
$(() => {
13 14
  const $boardApp = document.getElementById('board-app'),
        Store = gl.issueBoards.BoardsStore;
15

16
  window.gl = window.gl || {};
Phil Hughes committed
17

18 19 20 21 22
  if (gl.IssueBoardsApp) {
    gl.IssueBoardsApp.$destroy(true);
  }

  gl.IssueBoardsApp = new Vue({
23
    el: $boardApp,
24 25 26
    components: {
      'board': gl.issueBoards.Board
    },
Phil Hughes committed
27
    data: {
28
      state: Store.state,
29
      loading: true,
30 31 32
      endpoint: $boardApp.dataset.endpoint,
      disabled: $boardApp.dataset.disabled === 'true',
      issueLinkBase: $boardApp.dataset.issueLinkBase
Phil Hughes committed
33
    },
Phil Hughes committed
34
    init: Store.create.bind(Store),
35
    created () {
36 37
      gl.boardService = new BoardService(this.endpoint);
    },
38
    ready () {
39
      Store.disabled = this.disabled;
40
      gl.boardService.all()
41
        .then((resp) => {
Phil Hughes committed
42 43
          resp.json().forEach((board) => {
            const list = Store.addList(board);
44 45

            if (list.type === 'done') {
46
              list.position = Infinity;
Phil Hughes committed
47 48
            } else if (list.type === 'backlog') {
              list.position = -1;
49
            }
Phil Hughes committed
50
          });
51

52
          Store.addBlankState();
53
          this.loading = false;
Phil Hughes committed
54 55 56
        });
    }
  });
57 58 59 60 61 62 63

  gl.IssueBoardsSearch = new Vue({
    el: '#js-boards-seach',
    data: {
      filters: Store.state.filters
    }
  });
Phil Hughes committed
64
});