|
|
|
@ -1,4 +1,5 @@ |
|
|
|
|
const subManager = new SubsManager(); |
|
|
|
|
const { calculateIndexData } = Utils; |
|
|
|
|
|
|
|
|
|
BlazeComponent.extendComponent({ |
|
|
|
|
mixins() { |
|
|
|
@ -66,6 +67,51 @@ BlazeComponent.extendComponent({ |
|
|
|
|
|
|
|
|
|
onRendered() { |
|
|
|
|
if (!Utils.isMiniScreen()) this.scrollParentContainer(); |
|
|
|
|
const $checklistsDom = this.$('.card-checklist-items'); |
|
|
|
|
|
|
|
|
|
$checklistsDom.sortable({ |
|
|
|
|
tolerance: 'pointer', |
|
|
|
|
helper: 'clone', |
|
|
|
|
handle: '.checklist-title', |
|
|
|
|
items: '.js-checklist', |
|
|
|
|
placeholder: 'js-checklist placeholder', |
|
|
|
|
distance: 7, |
|
|
|
|
start(evt, ui) { |
|
|
|
|
ui.placeholder.height(ui.helper.height()); |
|
|
|
|
EscapeActions.executeUpTo('popup-close'); |
|
|
|
|
}, |
|
|
|
|
stop(evt, ui) { |
|
|
|
|
let prevChecklist = ui.item.prev('.js-checklist').get(0); |
|
|
|
|
if (prevChecklist) { |
|
|
|
|
prevChecklist = Blaze.getData(prevChecklist).checklist; |
|
|
|
|
} |
|
|
|
|
let nextChecklist = ui.item.next('.js-checklist').get(0); |
|
|
|
|
if (nextChecklist) { |
|
|
|
|
nextChecklist = Blaze.getData(nextChecklist).checklist; |
|
|
|
|
} |
|
|
|
|
const sortIndex = calculateIndexData(prevChecklist, nextChecklist, 1); |
|
|
|
|
|
|
|
|
|
$checklistsDom.sortable('cancel'); |
|
|
|
|
const checklist = Blaze.getData(ui.item.get(0)).checklist; |
|
|
|
|
|
|
|
|
|
Checklists.update(checklist._id, { |
|
|
|
|
$set: { |
|
|
|
|
sort: sortIndex.base, |
|
|
|
|
}, |
|
|
|
|
}); |
|
|
|
|
}, |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
function userIsMember() { |
|
|
|
|
return Meteor.user() && Meteor.user().isBoardMember(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Disable sorting if the current user is not a board member
|
|
|
|
|
this.autorun(() => { |
|
|
|
|
if ($checklistsDom.data('sortable')) { |
|
|
|
|
$checklistsDom.sortable('option', 'disabled', !userIsMember()); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
onDestroyed() { |
|
|
|
|