2017-01-12 03:49:57 +00:00
|
|
|
/* eslint-disable one-var, quote-props, comma-dangle, space-before-function-paren */
|
2016-12-14 03:01:05 +00:00
|
|
|
/* global Vue */
|
|
|
|
/* global BoardService */
|
|
|
|
|
2016-07-28 11:33:04 +00:00
|
|
|
//= require vue
|
|
|
|
//= require vue-resource
|
|
|
|
//= require Sortable
|
2017-01-24 12:20:49 +00:00
|
|
|
//= require masonry
|
2016-08-01 13:18:30 +00:00
|
|
|
//= require_tree ./models
|
2016-07-28 11:33:04 +00:00
|
|
|
//= require_tree ./stores
|
|
|
|
//= require_tree ./services
|
2016-08-05 15:30:14 +00:00
|
|
|
//= require_tree ./mixins
|
2016-10-05 11:20:59 +00:00
|
|
|
//= require_tree ./filters
|
2016-08-15 09:07:53 +00:00
|
|
|
//= require ./components/board
|
2016-10-04 14:27:02 +00:00
|
|
|
//= require ./components/board_sidebar
|
2016-08-15 09:07:53 +00:00
|
|
|
//= require ./components/new_list_dropdown
|
2017-01-25 16:53:09 +00:00
|
|
|
//= require ./components/modal/index
|
2016-08-16 10:34:32 +00:00
|
|
|
//= require ./vue_resource_interceptor
|
2016-07-28 11:33:04 +00:00
|
|
|
|
2016-08-11 08:51:52 +00:00
|
|
|
$(() => {
|
2017-01-12 03:49:57 +00:00
|
|
|
const $boardApp = document.getElementById('board-app');
|
|
|
|
const Store = gl.issueBoards.BoardsStore;
|
2017-01-25 16:53:09 +00:00
|
|
|
const ModalStore = gl.issueBoards.ModalStore;
|
2016-08-11 08:51:52 +00:00
|
|
|
|
2016-08-15 08:57:01 +00:00
|
|
|
window.gl = window.gl || {};
|
2016-07-28 11:33:04 +00:00
|
|
|
|
2016-08-05 13:00:06 +00:00
|
|
|
if (gl.IssueBoardsApp) {
|
|
|
|
gl.IssueBoardsApp.$destroy(true);
|
|
|
|
}
|
|
|
|
|
2016-11-04 10:24:59 +00:00
|
|
|
Store.create();
|
|
|
|
|
2016-08-05 13:00:06 +00:00
|
|
|
gl.IssueBoardsApp = new Vue({
|
2016-08-16 08:02:45 +00:00
|
|
|
el: $boardApp,
|
2016-08-15 09:07:53 +00:00
|
|
|
components: {
|
2016-10-04 14:27:02 +00:00
|
|
|
'board': gl.issueBoards.Board,
|
2017-01-24 10:27:41 +00:00
|
|
|
'board-sidebar': gl.issueBoards.BoardSidebar,
|
|
|
|
'board-add-issues-modal': gl.issueBoards.IssuesModal,
|
2016-08-15 09:07:53 +00:00
|
|
|
},
|
2016-07-28 11:33:04 +00:00
|
|
|
data: {
|
2016-08-16 08:02:45 +00:00
|
|
|
state: Store.state,
|
2016-08-11 08:51:52 +00:00
|
|
|
loading: true,
|
2016-08-16 08:02:45 +00:00
|
|
|
endpoint: $boardApp.dataset.endpoint,
|
2016-10-11 08:29:47 +00:00
|
|
|
boardId: $boardApp.dataset.boardId,
|
2016-08-16 08:02:45 +00:00
|
|
|
disabled: $boardApp.dataset.disabled === 'true',
|
2016-10-19 21:26:51 +00:00
|
|
|
issueLinkBase: $boardApp.dataset.issueLinkBase,
|
|
|
|
detailIssue: Store.detail
|
2016-07-28 11:33:04 +00:00
|
|
|
},
|
2016-10-19 21:26:51 +00:00
|
|
|
computed: {
|
|
|
|
detailIssueVisible () {
|
|
|
|
return Object.keys(this.detailIssue.issue).length;
|
2016-11-04 10:24:59 +00:00
|
|
|
},
|
2016-10-19 21:26:51 +00:00
|
|
|
},
|
2016-08-11 08:51:52 +00:00
|
|
|
created () {
|
2016-10-11 08:29:47 +00:00
|
|
|
gl.boardService = new BoardService(this.endpoint, this.boardId);
|
2016-08-08 15:15:05 +00:00
|
|
|
},
|
2016-11-03 00:37:33 +00:00
|
|
|
mounted () {
|
2016-08-16 08:02:45 +00:00
|
|
|
Store.disabled = this.disabled;
|
2016-08-05 13:00:06 +00:00
|
|
|
gl.boardService.all()
|
2016-08-19 13:16:07 +00:00
|
|
|
.then((resp) => {
|
2016-08-17 12:57:36 +00:00
|
|
|
resp.json().forEach((board) => {
|
|
|
|
const list = Store.addList(board);
|
2016-08-04 15:16:50 +00:00
|
|
|
|
|
|
|
if (list.type === 'done') {
|
2016-08-11 08:51:52 +00:00
|
|
|
list.position = Infinity;
|
2016-08-04 15:16:50 +00:00
|
|
|
}
|
2016-08-17 12:57:36 +00:00
|
|
|
});
|
2016-08-04 15:16:50 +00:00
|
|
|
|
2016-11-09 09:23:48 +00:00
|
|
|
this.state.lists = _.sortBy(this.state.lists, 'position');
|
|
|
|
|
2016-08-16 08:02:45 +00:00
|
|
|
Store.addBlankState();
|
2016-08-08 15:15:05 +00:00
|
|
|
this.loading = false;
|
2017-01-25 11:33:45 +00:00
|
|
|
|
|
|
|
if (this.state.lists.length > 0) {
|
2017-01-25 16:53:09 +00:00
|
|
|
ModalStore.store.selectedList = this.state.lists[0];
|
2017-01-25 11:33:45 +00:00
|
|
|
}
|
2016-07-28 11:33:04 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
2016-08-30 09:32:19 +00:00
|
|
|
|
|
|
|
gl.IssueBoardsSearch = new Vue({
|
2016-12-29 22:14:45 +00:00
|
|
|
el: '#js-boards-search',
|
2016-08-30 09:32:19 +00:00
|
|
|
data: {
|
|
|
|
filters: Store.state.filters
|
2016-11-04 10:24:59 +00:00
|
|
|
},
|
|
|
|
mounted () {
|
|
|
|
gl.issueBoards.newListDropdownInit();
|
2016-08-30 09:32:19 +00:00
|
|
|
}
|
|
|
|
});
|
2017-01-24 10:27:41 +00:00
|
|
|
|
2017-01-30 15:56:45 +00:00
|
|
|
gl.IssueBoardsModalAddBtn = new Vue({
|
|
|
|
el: '#js-add-issues-btn',
|
|
|
|
data: {
|
|
|
|
modal: ModalStore.store,
|
|
|
|
store: Store.state,
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
disabled() {
|
|
|
|
return Store.shouldAddBlankState();
|
|
|
|
},
|
|
|
|
},
|
|
|
|
template: `
|
|
|
|
<button
|
|
|
|
class="btn btn-create pull-right prepend-left-10 has-tooltip"
|
|
|
|
type="button"
|
|
|
|
:disabled="disabled"
|
|
|
|
@click="modal.showAddIssuesModal = true">
|
|
|
|
Add issues
|
|
|
|
</button>
|
|
|
|
`,
|
|
|
|
});
|
2016-07-28 11:33:04 +00:00
|
|
|
});
|