mirror of
https://github.com/wekan/wekan.git
synced 2026-11-24 20:45:00 -05:00
Default swimlanes, lists, cards, checklists, checklist items and subtasks to draggable. Share settings UI and policy, update ordinary sortables reactively and enforce the policy for mixed-selection drags while retaining explicit menu moves. Cover persistence, authorization, independent defaults and both checklist handle modes. Thanks to xet7 !
20 lines
1.1 KiB
JavaScript
20 lines
1.1 KiB
JavaScript
'use strict';
|
|
// Board policy, separate from a user's drag-handle preference. Missing fields
|
|
// on existing/imported boards deliberately retain the historical enabled state.
|
|
const DRAG_SETTINGS = [
|
|
{ kind: 'swimlane', field: 'allowsSwimlaneDragging', section: 'swimlane', label: 'swimlane' },
|
|
{ kind: 'list', field: 'allowsListDragging', section: 'list', label: 'list' },
|
|
{ kind: 'card', field: 'allowsCardDragging', section: 'card', label: 'card' },
|
|
{ kind: 'checklist', field: 'allowsChecklistDragging', section: 'card', label: 'checklists' },
|
|
{ kind: 'item', field: 'allowsChecklistItemDragging', section: 'card', label: 'r-item' },
|
|
{ kind: 'subtask', field: 'allowsSubtaskDragging', section: 'card', label: 'subtasks' },
|
|
];
|
|
function canDrag(board, kind) {
|
|
const setting = DRAG_SETTINGS.find(entry => entry.kind === kind);
|
|
return Boolean(board && setting && board[setting.field] !== false);
|
|
}
|
|
function canDragSelection(board, selection) {
|
|
return selection.every(entry => canDrag(board, entry.kind));
|
|
}
|
|
module.exports = { DRAG_SETTINGS, canDrag, canDragSelection };
|