Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DragTo when no card moved #15

Closed
marcosrocha85 opened this issue May 28, 2018 · 6 comments
Closed

DragTo when no card moved #15

marcosrocha85 opened this issue May 28, 2018 · 6 comments
Labels

Comments

@marcosrocha85
Copy link
Contributor

I noticed that when I set the dragTo property and start dragging an item, the boards not allowed to drop became brighter. But when I drop the card in the same position it was, intending to cancel move to another board, the entire kanban doesn't repaint those disabled boards. The kanban is set to dragBoards: false

captura de tela de 2018-05-28 13-02-30

@riktar riktar added the bug label May 28, 2018
@marcosrocha85
Copy link
Contributor Author

Tested a alert on dropEl when moving the "Another card" to it's same position and noticed that the alert didn't popped out. Maybe that's a bug from dragula?

@riktar
Copy link
Owner

riktar commented May 28, 2018

@marcosrocha85 When you drag an element in the same position it's not a complete drag but an "undo" move so it's correct that the alert didn't popped out.

@marcosrocha85
Copy link
Contributor Author

marcosrocha85 commented May 28, 2018

@riktar ok, but how we can fix the disabled boards when "undo"? I'm trying to evaluate the code but my browser is saying require is not defined.

@marcosrocha85
Copy link
Contributor Author

marcosrocha85 commented May 28, 2018

Basically the fix was call new function enableAllBoards on Dragula's cancel event. Here it is:

@@ -92,10 +92,13 @@ var dragula = require('dragula');
 
                 //Init Drag Item
                 self.drake = self.dragula(self.boardContainer, function () {
                     revertOnSpill: true
                 })
+                    .on('cancel', function(el, container, source) {
+                        self.enableAllBoards();
+                    })
                     .on('drag', function (el, source) {
                         el.classList.add('is-moving');
                         var boardJSON = __findBoardJSON(source.parentNode.dataset.id);
                         if (boardJSON.dragTo !== undefined) {
                             self.options.boards.map(function (board) {
@@ -113,17 +116,12 @@ var dragula = require('dragula');
                         self.options.dragendEl(el);
                         if (el !== null && typeof(el.dragendfn) === 'function')
                             el.dragendfn(el);
                     })
                     .on('drop', function (el, target, source, sibling) {
+                        self.enableAllBoards();
 
-                        var allB = document.querySelectorAll('.kanban-board');
-                        if (allB.length > 0 && allB !== undefined) {
-                            for (var i = 0; i < allB.length; i++) {
-                                allB[i].classList.remove('disabled-board');
-                            }
-                        }
                         var boardJSON = __findBoardJSON(source.parentNode.dataset.id);
                         if (boardJSON.dragTo !== undefined) {
                             if (boardJSON.dragTo.indexOf(target.parentNode.dataset.id) === -1 && target.parentNode.dataset.id !== source.parentNode.dataset.id) {
                                 self.drake.cancel(true)
                             }
@@ -136,10 +134,19 @@ var dragula = require('dragula');
                         }
                     })
             }
         };
 
+        this.enableAllBoards = function() {
+            var allB = document.querySelectorAll('.kanban-board');
+            if (allB.length > 0 && allB !== undefined) {
+                for (var i = 0; i < allB.length; i++) {
+                    allB[i].classList.remove('disabled-board');
+                }
+            }
+        };
+
         this.addElement = function (boardID, element) {
             var board = self.element.querySelector('[data-id="' + boardID + '"] .kanban-drag');
             var nodeItem = document.createElement('div');
             nodeItem.classList.add('kanban-item');
             if (element.id) {

@marcosrocha85
Copy link
Contributor Author

Pull request #16 created.

@riktar
Copy link
Owner

riktar commented Jun 1, 2018

Resolved in pull request #16

@riktar riktar closed this as completed Jun 1, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants