riktar / jkanban

Vanilla Javascript plugin for manage kanban boards
https://www.riccardotartaglia.it/jkanban/
Apache License 2.0
1.06k stars 296 forks source link

dragItems : false not working #112

Closed drmatrix closed 3 years ago

drmatrix commented 3 years ago

hi im trying to give user permission about draggable items the "dragItems :" even set to false the items still draggable

xscode-auto-reply[bot] commented 3 years ago

Thanks for opening a new issue. The team has been notified and will review it as soon as possible. For urgent issues and priority support, visit https://xscode.com/riktar/jkanban

AEK-BKF commented 3 years ago

Same here ! It doesn't work. @drmatrix please, did you find a solution ? Thanks

marcosrocha85 commented 3 years ago

Are you using the property correctly? Are you using some event? Please uncomment dragItems at my fiddle and see it's actually working. https://jsfiddle.net/marcosrocha85/Lk9t483r/

AEK-BKF commented 3 years ago

@marcosrocha85 Thanks for quick reply, I mean it doesn't work for a given board, not the whole jkanban. So if I have Draft, ToDo, Done, Cancelled boards, is there a way to disable dragItems only for Draft board ? Thanks

marcosrocha85 commented 3 years ago

@AEK-BKF sure it has. Take a look at this fiddle:

var kanban = new jKanban({
    element: '#myboard',
    dropEl: function(el, target, source, sibling) {
        // eg: if (["_todo","_cancel","_done"].indexOf(target.parentElement.dataset.id) == -1)
        if (!yourCoolValidationHere) {
            kanban.drake.cancel(true);
            return;
        }

        // do your logic as save to database or ask user for confirmation (I use it for as to move to Done)
    }
}

I made a table in database where I created the workflow for the boards (columns) and check if the target board is allowed to receive an item from source board. If cannot, I cancel the drake event and the item is not moved, otherwise I save the new column in database and update all cards sort order for target board.

AEK-BKF commented 3 years ago

@marcosrocha85 Thank you so much :))))