BigW Consortium Gitlab

boards_bundle.js.es6 2.09 KB
Newer Older
1 2 3 4
/* eslint-disable one-var, indent, quote-props, comma-dangle, space-before-function-paren */
/* global Vue */
/* global BoardService */

Phil Hughes committed
5 6 7
//= require vue
//= require vue-resource
//= require Sortable
8
//= require_tree ./models
Phil Hughes committed
9 10
//= require_tree ./stores
//= require_tree ./services
11
//= require_tree ./mixins
12
//= require_tree ./filters
13
//= require ./components/board
Phil Hughes committed
14
//= require ./components/board_sidebar
15
//= require ./components/new_list_dropdown
16
//= require ./vue_resource_interceptor
Phil Hughes committed
17

18
$(() => {
19 20
  const $boardApp = document.getElementById('board-app'),
        Store = gl.issueBoards.BoardsStore;
21

22
  window.gl = window.gl || {};
Phil Hughes committed
23

24 25 26 27
  if (gl.IssueBoardsApp) {
    gl.IssueBoardsApp.$destroy(true);
  }

28 29
  Store.create();

30
  gl.IssueBoardsApp = new Vue({
31
    el: $boardApp,
32
    components: {
Phil Hughes committed
33 34
      'board': gl.issueBoards.Board,
      'board-sidebar': gl.issueBoards.BoardSidebar
35
    },
Phil Hughes committed
36
    data: {
37
      state: Store.state,
38
      loading: true,
39
      endpoint: $boardApp.dataset.endpoint,
40
      boardId: $boardApp.dataset.boardId,
41
      disabled: $boardApp.dataset.disabled === 'true',
42 43
      issueLinkBase: $boardApp.dataset.issueLinkBase,
      detailIssue: Store.detail
Phil Hughes committed
44
    },
45 46 47
    computed: {
      detailIssueVisible () {
        return Object.keys(this.detailIssue.issue).length;
48
      },
49
    },
50
    created () {
51
      gl.boardService = new BoardService(this.endpoint, this.boardId);
52
    },
Fatih Acet committed
53
    mounted () {
54
      Store.disabled = this.disabled;
55
      gl.boardService.all()
56
        .then((resp) => {
Phil Hughes committed
57 58
          resp.json().forEach((board) => {
            const list = Store.addList(board);
59 60

            if (list.type === 'done') {
61
              list.position = Infinity;
Phil Hughes committed
62 63
            } else if (list.type === 'backlog') {
              list.position = -1;
64
            }
Phil Hughes committed
65
          });
66

67 68
          this.state.lists = _.sortBy(this.state.lists, 'position');

69
          Store.addBlankState();
70
          this.loading = false;
Phil Hughes committed
71 72 73
        });
    }
  });
74 75 76 77 78

  gl.IssueBoardsSearch = new Vue({
    el: '#js-boards-seach',
    data: {
      filters: Store.state.filters
79 80 81
    },
    mounted () {
      gl.issueBoards.newListDropdownInit();
82 83
    }
  });
Phil Hughes committed
84
});