2016-12-13 22:01:05 -05:00
|
|
|
/* eslint-disable one-var, indent, quote-props, comma-dangle, space-before-function-paren */
|
|
|
|
/* global Vue */
|
|
|
|
/* global BoardService */
|
|
|
|
|
2016-07-28 07:33:04 -04:00
|
|
|
//= require vue
|
|
|
|
//= require vue-resource
|
|
|
|
//= require Sortable
|
2016-08-01 09:18:30 -04:00
|
|
|
//= require_tree ./models
|
2016-07-28 07:33:04 -04:00
|
|
|
//= require_tree ./stores
|
|
|
|
//= require_tree ./services
|
2016-08-05 11:30:14 -04:00
|
|
|
//= require_tree ./mixins
|
2016-10-05 07:20:59 -04:00
|
|
|
//= require_tree ./filters
|
2016-08-15 05:07:53 -04:00
|
|
|
//= require ./components/board
|
2016-10-04 10:27:02 -04:00
|
|
|
//= require ./components/board_sidebar
|
2016-08-15 05:07:53 -04:00
|
|
|
//= require ./components/new_list_dropdown
|
2016-08-16 06:34:32 -04:00
|
|
|
//= require ./vue_resource_interceptor
|
2016-07-28 07:33:04 -04:00
|
|
|
|
2016-08-11 04:51:52 -04:00
|
|
|
$(() => {
|
2016-08-16 04:02:45 -04:00
|
|
|
const $boardApp = document.getElementById('board-app'),
|
|
|
|
Store = gl.issueBoards.BoardsStore;
|
2016-08-11 04:51:52 -04:00
|
|
|
|
2016-08-15 04:57:01 -04:00
|
|
|
window.gl = window.gl || {};
|
2016-07-28 07:33:04 -04:00
|
|
|
|
2016-08-05 09:00:06 -04:00
|
|
|
if (gl.IssueBoardsApp) {
|
|
|
|
gl.IssueBoardsApp.$destroy(true);
|
|
|
|
}
|
|
|
|
|
2016-11-04 06:24:59 -04:00
|
|
|
Store.create();
|
|
|
|
|
2016-08-05 09:00:06 -04:00
|
|
|
gl.IssueBoardsApp = new Vue({
|
2016-08-16 04:02:45 -04:00
|
|
|
el: $boardApp,
|
2016-08-15 05:07:53 -04:00
|
|
|
components: {
|
2016-10-04 10:27:02 -04:00
|
|
|
'board': gl.issueBoards.Board,
|
|
|
|
'board-sidebar': gl.issueBoards.BoardSidebar
|
2016-08-15 05:07:53 -04:00
|
|
|
},
|
2016-07-28 07:33:04 -04:00
|
|
|
data: {
|
2016-08-16 04:02:45 -04:00
|
|
|
state: Store.state,
|
2016-08-11 04:51:52 -04:00
|
|
|
loading: true,
|
2016-08-16 04:02:45 -04:00
|
|
|
endpoint: $boardApp.dataset.endpoint,
|
2016-10-11 04:29:47 -04:00
|
|
|
boardId: $boardApp.dataset.boardId,
|
2016-08-16 04:02:45 -04:00
|
|
|
disabled: $boardApp.dataset.disabled === 'true',
|
2016-10-19 17:26:51 -04:00
|
|
|
issueLinkBase: $boardApp.dataset.issueLinkBase,
|
|
|
|
detailIssue: Store.detail
|
2016-07-28 07:33:04 -04:00
|
|
|
},
|
2016-10-19 17:26:51 -04:00
|
|
|
computed: {
|
|
|
|
detailIssueVisible () {
|
|
|
|
return Object.keys(this.detailIssue.issue).length;
|
2016-11-04 06:24:59 -04:00
|
|
|
},
|
2016-10-19 17:26:51 -04:00
|
|
|
},
|
2016-08-11 04:51:52 -04:00
|
|
|
created () {
|
2016-10-11 04:29:47 -04:00
|
|
|
gl.boardService = new BoardService(this.endpoint, this.boardId);
|
2016-08-08 11:15:05 -04:00
|
|
|
},
|
2016-11-02 20:37:33 -04:00
|
|
|
mounted () {
|
2016-08-16 04:02:45 -04:00
|
|
|
Store.disabled = this.disabled;
|
2016-08-05 09:00:06 -04:00
|
|
|
gl.boardService.all()
|
2016-08-19 09:16:07 -04:00
|
|
|
.then((resp) => {
|
2016-08-17 08:57:36 -04:00
|
|
|
resp.json().forEach((board) => {
|
|
|
|
const list = Store.addList(board);
|
2016-08-04 11:16:50 -04:00
|
|
|
|
|
|
|
if (list.type === 'done') {
|
2016-08-11 04:51:52 -04:00
|
|
|
list.position = Infinity;
|
2016-08-05 12:01:34 -04:00
|
|
|
} else if (list.type === 'backlog') {
|
|
|
|
list.position = -1;
|
2016-08-04 11:16:50 -04:00
|
|
|
}
|
2016-08-17 08:57:36 -04:00
|
|
|
});
|
2016-08-04 11:16:50 -04:00
|
|
|
|
2016-11-09 04:23:48 -05:00
|
|
|
this.state.lists = _.sortBy(this.state.lists, 'position');
|
|
|
|
|
2016-08-16 04:02:45 -04:00
|
|
|
Store.addBlankState();
|
2016-08-08 11:15:05 -04:00
|
|
|
this.loading = false;
|
2016-07-28 07:33:04 -04:00
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
2016-08-30 05:32:19 -04:00
|
|
|
|
|
|
|
gl.IssueBoardsSearch = new Vue({
|
|
|
|
el: '#js-boards-seach',
|
|
|
|
data: {
|
|
|
|
filters: Store.state.filters
|
2016-11-04 06:24:59 -04:00
|
|
|
},
|
|
|
|
mounted () {
|
|
|
|
gl.issueBoards.newListDropdownInit();
|
2016-08-30 05:32:19 -04:00
|
|
|
}
|
|
|
|
});
|
2016-07-28 07:33:04 -04:00
|
|
|
});
|