Drag handles. In progress.

This commit is contained in:
Lauri Ojansivu 2019-10-03 04:23:33 +03:00
parent 21fa26a1be
commit 5bc355f9a5
9 changed files with 133 additions and 73 deletions

View file

@ -31,24 +31,6 @@ BlazeComponent.extendComponent({
const itemsSelector = '.js-minicard:not(.placeholder, .js-card-composer)';
const $cards = this.$('.js-minicards');
if (Utils.isMiniScreen) {
$('.js-minicards').sortable({
handle: '.handle',
});
}
if (!Utils.isMiniScreen && showDesktopDragHandles) {
$('.js-minicards').sortable({
handle: '.handle',
});
}
if (!Utils.isMiniScreen && !showDesktopDragHandles) {
$('.js-minicards').sortable({
handle: 'list-header',
});
}
$cards.sortable({
connectWith: '.js-minicards:not(.js-list-full)',
tolerance: 'pointer',
@ -138,6 +120,21 @@ BlazeComponent.extendComponent({
// Disable drag-dropping if the current user is not a board member or is comment only
this.autorun(() => {
$cards.sortable('option', 'disabled', !userIsMember());
if (Utils.isMiniScreen()) {
this.$('.js-minicards').sortable({
handle: '.handle',
});
} else {
if (Meteor.user().hasShowDesktopDragHandles()) {
this.$('.js-minicards').sortable({
handle: '.handle',
});
} else {
this.$('.js-minicards').sortable({
handle: '.minicard-title',
});
}
}
});
// We want to re-run this function any time a card is added.
@ -180,3 +177,9 @@ Template.miniList.events({
Session.set('currentList', listId);
},
});
Template.miniList.helpers({
showDesktopDragHandles() {
return Meteor.user().hasShowDesktopDragHandles();
},
});