gitlab-org--gitlab-foss/app/assets/javascripts/boards/boards_bundle.js.es6

103 lines
2.6 KiB
JavaScript
Raw Normal View History

2017-01-12 03:49:57 +00:00
/* eslint-disable one-var, quote-props, comma-dangle, space-before-function-paren */
/* global Vue */
/* global BoardService */
2016-07-28 11:33:04 +00:00
//= require vue
//= require vue-resource
//= require Sortable
//= 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
//= require_tree ./mixins
//= require_tree ./filters
//= require ./components/board
2016-10-04 14:27:02 +00:00
//= require ./components/board_sidebar
//= require ./components/new_list_dropdown
2017-01-24 10:49:39 +00:00
//= require ./components/modal/modal
2016-08-16 10:34:32 +00:00
//= require ./vue_resource_interceptor
2016-07-28 11:33:04 +00:00
$(() => {
2017-01-12 03:49:57 +00:00
const $boardApp = document.getElementById('board-app');
const Store = gl.issueBoards.BoardsStore;
window.gl = window.gl || {};
2016-07-28 11:33:04 +00:00
if (gl.IssueBoardsApp) {
gl.IssueBoardsApp.$destroy(true);
}
Store.create();
gl.IssueBoardsApp = new Vue({
el: $boardApp,
components: {
2016-10-04 14:27:02 +00:00
'board': gl.issueBoards.Board,
'board-sidebar': gl.issueBoards.BoardSidebar,
'board-add-issues-modal': gl.issueBoards.IssuesModal,
},
2016-07-28 11:33:04 +00:00
data: {
state: Store.state,
loading: true,
endpoint: $boardApp.dataset.endpoint,
boardId: $boardApp.dataset.boardId,
disabled: $boardApp.dataset.disabled === 'true',
issueLinkBase: $boardApp.dataset.issueLinkBase,
detailIssue: Store.detail
2016-07-28 11:33:04 +00:00
},
computed: {
detailIssueVisible () {
return Object.keys(this.detailIssue.issue).length;
},
},
created () {
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 () {
Store.disabled = this.disabled;
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) => {
if (board.list_type === 'backlog') return;
2016-08-17 12:57:36 +00:00
const list = Store.addList(board);
if (list.type === 'done') {
list.position = Infinity;
}
2016-08-17 12:57:36 +00:00
});
2016-11-09 09:23:48 +00:00
this.state.lists = _.sortBy(this.state.lists, 'position');
Store.addBlankState();
2016-08-08 15:15:05 +00:00
this.loading = false;
if (this.state.lists.length > 0) {
Store.modal.selectedList = this.state.lists[0];
}
Store.modal.showAddIssuesModal = true;
2016-07-28 11:33:04 +00:00
});
}
});
gl.IssueBoardsSearch = new Vue({
2016-12-29 22:14:45 +00:00
el: '#js-boards-search',
data: {
filters: Store.state.filters
},
mounted () {
gl.issueBoards.newListDropdownInit();
}
});
// This element is outside the Vue app
$(document)
.off('click', '.js-show-add-issues')
.on('click', '.js-show-add-issues', (e) => {
e.preventDefault();
Store.modal.showAddIssuesModal = true;
});
2016-07-28 11:33:04 +00:00
});