Created default sortable options to be shared between the lists & the cards

Added full vue.js source
This commit is contained in:
Phil Hughes 2016-08-05 16:30:14 +01:00
parent a3831192d9
commit f1242c17a5
5 changed files with 10098 additions and 31 deletions

View File

@ -4,6 +4,7 @@
//= require_tree ./models
//= require_tree ./stores
//= require_tree ./services
//= require_tree ./mixins
//= require_tree ./components
$(function () {

View File

@ -30,7 +30,7 @@
getFilterData: function () {
const queryData = this.board.canSearch() ? { search: this.query } : {};
return _.extend(this.filters, queryData);
return _.extend(queryData, this.filters);
}
},
computed: {
@ -39,27 +39,17 @@
}
},
ready: function () {
Sortable.create(this.$el.parentNode, {
const options = _.extend({
group: 'boards',
animation: 150,
draggable: '.is-draggable',
handle: '.js-board-handle',
filter: '.board-delete',
forceFallback: true,
fallbackClass: 'is-dragging',
ghostClass: 'is-ghost',
scrollSensitivity: 150,
scrollSpeed: 50,
onUpdate: function (e) {
BoardsStore.moveList(e.oldIndex, e.newIndex);
},
onStart: function () {
document.body.classList.add('is-dragging');
},
onEnd: function () {
document.body.classList.remove('is-dragging');
}
});
}, gl.boardSortableDefaultOptions);
Sortable.create(this.$el.parentNode, options);
}
});

View File

@ -35,29 +35,20 @@
},
},
ready: function () {
Sortable.create(this.$els.list, {
const options = _.extend({
sort: false,
group: 'issues',
disabled: this.disabled,
scrollSensitivity: 150,
scrollSpeed: 50,
forceFallback: true,
fallbackClass: 'is-dragging',
ghostClass: 'is-ghost',
onAdd: function (e) {
const fromListId = parseInt(e.from.getAttribute('data-board')),
toListId = parseInt(e.to.getAttribute('data-board')),
issueId = parseInt(e.item.getAttribute('data-issue'));
BoardsStore.moveCardToList(fromListId, toListId, issueId);
},
onStart: function () {
document.body.classList.add('is-dragging');
},
onEnd: function () {
document.body.classList.remove('is-dragging');
}
});
}, gl.boardSortableDefaultOptions);
Sortable.create(this.$els.list, options);
// Scroll event on list to load more
this.$els.list.onscroll = () => {

View File

@ -0,0 +1,20 @@
(function (w) {
if (!window.gl) {
window.gl = {};
}
gl.boardSortableDefaultOptions = {
animation: 150,
forceFallback: true,
fallbackClass: 'is-dragging',
ghostClass: 'is-ghost',
scrollSensitivity: 150,
scrollSpeed: 50,
onStart: function () {
document.body.classList.add('is-dragging');
},
onEnd: function () {
document.body.classList.remove('is-dragging');
}
};
})(window);

File diff suppressed because one or more lines are too long