Merge pull request #3341 from mfilser/drag_handle_checklist

Drag handles for checklist #3240
This commit is contained in:
Lauri Ojansivu 2020-11-11 13:39:18 +02:00 committed by GitHub
commit ba2c280d56
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 32 additions and 1 deletions

View file

@ -250,12 +250,15 @@ BlazeComponent.extendComponent({
// Disable sorting if the current user is not a board member
this.autorun(() => {
const disabled = !userIsMember() || Utils.isMiniScreen();
const disabled = !userIsMember();
if (
$checklistsDom.data('uiSortable') ||
$checklistsDom.data('sortable')
) {
$checklistsDom.sortable('option', 'disabled', disabled);
if (Utils.isMiniScreenOrShowDesktopDragHandles()) {
$checklistsDom.sortable({ handle: '.checklist-handle'});
}
}
if ($subtasksDom.data('uiSortable') || $subtasksDom.data('sortable')) {
$subtasksDom.sortable('option', 'disabled', disabled);

View file

@ -41,6 +41,8 @@ template(name="checklistDetail")
if canModifyCard
h2.title.js-open-inlined-form.is-editable
if isMiniScreenOrShowDesktopDragHandles
span.fa.checklist-handle(class="fa-arrows" title="{{_ 'dragChecklist'}}")
+viewer
= checklist.title
else

View file

@ -42,6 +42,11 @@ textarea.js-add-checklist-item, textarea.js-edit-checklist-item
.js-delete-checklist
@extends .delete-text
span.fa.checklist-handle
padding-right: 20px
padding-top: 6px
float: right
.js-confirm-checklist-delete
background-color: darken(white, 3%)

View file

@ -30,3 +30,7 @@ Blaze.registerHelper('getUser', userId => Users.findOne(userId));
Blaze.registerHelper('concat', (...args) => args.slice(0, -1).join(''));
Blaze.registerHelper('isMiniScreen', () => Utils.isMiniScreen());
Blaze.registerHelper('isShowDesktopDragHandles', () => Utils.isShowDesktopDragHandles());
Blaze.registerHelper('isMiniScreenOrShowDesktopDragHandles', () => Utils.isMiniScreenOrShowDesktopDragHandles());

View file

@ -190,6 +190,23 @@ Utils = {
//return false;
},
// returns if desktop drag handles are enabled
isShowDesktopDragHandles() {
let currentUser = Meteor.user();
if (currentUser) {
return (currentUser.profile || {}).showDesktopDragHandles;
} else if (cookies.has('showDesktopDragHandles')) {
return true;
} else {
return false;
}
},
// returns if mini screen or desktop drag handles
isMiniScreenOrShowDesktopDragHandles() {
return this.isMiniScreen() || this.isShowDesktopDragHandles()
},
calculateIndexData(prevData, nextData, nItems = 1) {
let base, increment;
// If we drop the card to an empty column