2017-01-27 20:33:58 -05:00
|
|
|
/* eslint-disable one-var, quote-props, comma-dangle, space-before-function-paren, import/newline-after-import, no-multi-spaces, max-len */
|
2016-12-13 22:01:05 -05:00
|
|
|
/* global Vue */
|
|
|
|
/* global BoardService */
|
|
|
|
|
2016-11-03 17:38:54 -04:00
|
|
|
function requireAll(context) { return context.keys().map(context); }
|
|
|
|
|
|
|
|
window.Vue = require('vue');
|
|
|
|
window.Vue.use(require('vue-resource'));
|
|
|
|
window.Sortable = require('vendor/Sortable');
|
|
|
|
requireAll(require.context('./models', true, /^\.\/.*\.(js|es6)$/));
|
|
|
|
requireAll(require.context('./stores', true, /^\.\/.*\.(js|es6)$/));
|
|
|
|
requireAll(require.context('./services', true, /^\.\/.*\.(js|es6)$/));
|
|
|
|
requireAll(require.context('./mixins', true, /^\.\/.*\.(js|es6)$/));
|
|
|
|
requireAll(require.context('./filters', true, /^\.\/.*\.(js|es6)$/));
|
|
|
|
require('./components/board');
|
|
|
|
require('./components/board_sidebar');
|
|
|
|
require('./components/new_list_dropdown');
|
2017-02-03 14:17:03 -05:00
|
|
|
require('./components/modal/index');
|
2016-11-03 17:38:54 -04:00
|
|
|
require('./vue_resource_interceptor');
|
2016-07-28 07:33:04 -04:00
|
|
|
|
2016-08-11 04:51:52 -04:00
|
|
|
$(() => {
|
2017-01-11 22:49:57 -05:00
|
|
|
const $boardApp = document.getElementById('board-app');
|
|
|
|
const Store = gl.issueBoards.BoardsStore;
|
2017-01-25 11:53:09 -05:00
|
|
|
const ModalStore = gl.issueBoards.ModalStore;
|
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,
|
2017-01-24 05:27:41 -05:00
|
|
|
'board-sidebar': gl.issueBoards.BoardSidebar,
|
|
|
|
'board-add-issues-modal': gl.issueBoards.IssuesModal,
|
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,
|
2017-01-31 05:39:44 -05:00
|
|
|
rootPath: $boardApp.dataset.rootPath,
|
2017-01-31 09:35:53 -05:00
|
|
|
bulkUpdatePath: $boardApp.dataset.bulkUpdatePath,
|
2016-10-19 17:26:51 -04:00
|
|
|
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 () {
|
2017-01-31 09:35:53 -05:00
|
|
|
gl.boardService = new BoardService(this.endpoint, this.bulkUpdatePath, 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-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({
|
2016-12-29 17:14:45 -05:00
|
|
|
el: '#js-boards-search',
|
2016-08-30 05:32:19 -04:00
|
|
|
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
|
|
|
}
|
|
|
|
});
|
2017-01-24 05:27:41 -05:00
|
|
|
|
2017-01-30 10:56:45 -05:00
|
|
|
gl.IssueBoardsModalAddBtn = new Vue({
|
2017-01-31 11:46:57 -05:00
|
|
|
mixins: [gl.issueBoards.ModalMixins],
|
2017-01-30 10:56:45 -05:00
|
|
|
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"
|
2017-01-31 11:46:57 -05:00
|
|
|
@click="toggleModal(true)">
|
2017-01-30 10:56:45 -05:00
|
|
|
Add issues
|
|
|
|
</button>
|
|
|
|
`,
|
|
|
|
});
|
2016-07-28 07:33:04 -04:00
|
|
|
});
|