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

65 lines
1.5 KiB
JavaScript
Raw Normal View History

2016-07-28 11:33:04 +00:00
//= require vue
//= require vue-resource
//= require Sortable
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
2016-07-28 11:33:04 +00:00
//= require_tree ./components
$(() => {
const $boardApp = $('#board-app');
if (!window.gl) {
window.gl = {};
}
2016-07-28 11:33:04 +00:00
if (gl.IssueBoardsApp) {
gl.IssueBoardsApp.$destroy(true);
}
gl.IssueBoardsApp = new Vue({
el: $boardApp.get(0),
2016-07-28 11:33:04 +00:00
data: {
2016-08-08 15:15:05 +00:00
state: BoardsStore.state,
loading: true,
endpoint: $boardApp.data('endpoint'),
disabled: $boardApp.data('disabled'),
issueLinkBase: $boardApp.data('issue-link-base')
2016-07-28 11:33:04 +00:00
},
init () {
BoardsStore.create();
},
created () {
2016-08-08 15:15:05 +00:00
this.loading = true;
gl.boardService = new BoardService(this.endpoint);
$boardApp
.removeAttr('data-endpoint')
.removeAttr('data-disabled')
.removeAttr('data-issue-link-base');
2016-08-08 15:15:05 +00:00
},
ready () {
BoardsStore.disabled = this.disabled;
gl.boardService.all()
2016-07-28 11:33:04 +00:00
.then((resp) => {
2016-08-02 08:58:09 +00:00
const boards = resp.json();
for (let i = 0, boardsLength = boards.length; i < boardsLength; i++) {
const board = boards[i],
list = BoardsStore.addList(board);
if (list.type === 'done') {
list.position = Infinity;
2016-08-05 16:01:34 +00:00
} else if (list.type === 'backlog') {
list.position = -1;
}
}
BoardsStore.addBlankState();
2016-08-08 15:15:05 +00:00
this.loading = false;
2016-07-28 11:33:04 +00:00
});
}
});
});