Giter Club home page Giter Club logo

jkanban's Introduction

jKanban

Javascript plugin for Kanban boards

jKanban allow you to create and manage Kanban Board in your project!

Please try out the live demo!

Install

Clone the repo and use the javascript and the css files in the dist folder.

You have to include

<link rel="stylesheet" href="path/to/jkanban.min.css">

and

<script src="path/to/jkanban.min.js"></script>

in your page and you are done.

Usage

Init jKanban is a piece of cake!

var kanban = new jKanban(options)

Here's an overview of the default values.

var kanban = new jKanban({
    element          : '',                                           // selector of the kanban container
    gutter           : '15px',                                       // gutter of the board
    widthBoard       : '250px',                                      // width of the board
    responsivePercentage: false,                                    // if it is true I use percentage in the width of the boards and it is not necessary gutter and widthBoard
    dragItems        : true,                                         // if false, all items are not draggable
    boards           : [],                                           // json of boards
    dragBoards       : true,                                         // the boards are draggable, if false only item can be dragged
    itemAddOptions: {
        enabled: false,                                              // add a button to board for easy item creation
        content: '+',                                                // text or html content of the board button   
        class: 'kanban-title-button btn btn-default btn-xs',         // default class of the button
        footer: false                                                // position the button on footer
    },    
    itemHandleOptions: {
        enabled             : false,                                 // if board item handle is enabled or not
        handleClass         : "item_handle",                         // css class for your custom item handle
        customCssHandler    : "drag_handler",                        // when customHandler is undefined, jKanban will use this property to set main handler class
        customCssIconHandler: "drag_handler_icon",                   // when customHandler is undefined, jKanban will use this property to set main icon handler class. If you want, you can use font icon libraries here
        customHandler       : "<span class='item_handle'>+</span> %title% "  // your entirely customized handler. Use %title% to position item title 
                                                                             // any key's value included in item collection can be replaced with %key%
    },
    click            : function (el) {},                             // callback when any board's item are clicked
    context          : function (el, event) {},                      // callback when any board's item are right clicked
    dragEl           : function (el, source) {},                     // callback when any board's item are dragged
    dragendEl        : function (el) {},                             // callback when any board's item stop drag
    dropEl           : function (el, target, source, sibling) {},    // callback when any board's item drop in a board
    dragBoard        : function (el, source) {},                     // callback when any board stop drag
    dragendBoard     : function (el) {},                             // callback when any board stop drag
    buttonClick      : function(el, boardId) {},                     // callback when the board's button is clicked
    propagationHandlers: [],                                         // the specified callback does not cancel the browser event. possible values: "click", "context"
})

Now take a look to the boards object

[
    {
        "id"    : "board-id-1",               // id of the board
        "title" : "Board Title",              // title of the board
        "class" : "class1,class2,...",        // css classes to add at the title
        "dragTo": ['another-board-id',...],   // array of ids of boards where items can be dropped (default: [])
        "item"  : [                           // item of this board
            {
                "id"    : "item-id-1",        // id of the item
                "title" : "Item 1"            // title of the item
                "class" : ["myClass",...]     // array of additional classes
            },
            {
                "id"    : "item-id-2",
                "title" : "Item 2"
            }
        ]
    },
    {
        "id"    : "board-id-2",
        "title" : "Board Title 2"
    }
]

WARNING: all ids are unique!

About custom properties

jKanban also support custom properties on items to improve your applications with html data- properties. You can define them at like:

[
    {
        "id"    : "board-id-1",
        "title" : "Board Title",
        "item"  : [
            {
                "id"      : "item-id-1",
                "title"   : "Item 1",
                "username": "username1"
            },
            {
                "id"      : "item-id-2",
                "title"   : "Item 2",
                "username": "username2"
            }
        ]
    }
]

Which jKanban will convert to:

<main class="kanban-drag">
    <div class="kanban-item" data-eid="item-id-1" data-username="username1">Item 1</div>
    <div class="kanban-item" data-eid="item-id-2" data-username="username2">Item 2</div>
</main>

API

jKanban provides the easiest possible API to make your boards awesome!

Method Name Arguments Description
addElement boardID, element, position Add element in the board with ID boardID, element is the standard format. If position is set, inserts at position starting from 0
addForm boardID, formItem Add formItem as html element into the board with ID boardID
addBoards boards Add one or more boards in the kanban, boards are in the standard format
findElement id Find board's item by id
replaceElement id, element Replace item by id with element JSON standard format
getParentBoardID id Get board ID of item id passed
findBoard id Find board by id
getBoardElements id Get all item of a board
removeElement id Remove a board's element by id
removeBoard id Remove a board by id

Example

Clone the repo and look in the example folder

Thanks

jKanban use dragula for drag&drop

Develop

Clone the repo then use npm install for download all the dependencies then launch npm run build for build the project

Pull Requests?

I'd love them!

Comments?

Let's hear them! (The nice ones please!)

Me?

In case you're interested I'm @riktarweb

jkanban's People

Contributors

dependabot[bot] avatar duquevieira avatar edmunds22 avatar fotrino avatar gokaygurcan avatar gonzaloalonsod avatar hoanganhhanoi avatar janhendrik-rust avatar marcosrocha85 avatar mikeproove avatar ngmy avatar riktar avatar rugbymauri avatar teooliver avatar thomani avatar upzone avatar zhangyan612 avatar zmeyqq avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

jkanban's Issues

Cancel drag

I'm trying to cancel a drag event in order to prevent moving cards on a automatic board, but when I call jkanban.drake.cancel(true) the dragula raises an exception saying "el is null" on touchy function.
Do you have any suggestion to implement a "beforeDrag" event in order to validate if a card can be moved? I'm intended to develop that on jKanban.

Restricting which boards to drag items to

First of all, this is an elegant, clean, and minimalist solution and I'm going to start using it in my internal project.

I have one feature request. I'd like to specify for each board the titles/ids of other boards the items can be dragged to.

Maybe even have a default option to only be able to drag items to adjacent boards.

Set class to main element

Hello, how can i change style of main element?
<main class="kanban-drag"></main>
default
I mean i want to set different classes to each main elements.

Allow multiple classes for board header

I'd like to apply multiple classes to the board header but there's support for only one.

class: 'bg-info' works
class: 'bg-info text-center' errors out
class: 'bg-info.text-center' doesn't work
class: ['bg-info', 'text-center'] doesn't work

Get the board order to update in db

Can you please help to get the board orders in the event when a board is dragged around,
dragBoard : function (el, source) {}, I know we can use this listener to detect the movement, but how to get the new order to pass to server

AddForm is dragable

If I run the example page & hit the + button to call the "AddForm" option, the form is dragable

image

Move board programmatically

How can I move a board programmatically?

I want to fix a board in the first position. So I want to move back to the initial position even if another board has been moved to the first one.

I know that I can make a board not draggable, but if you change another card for that position, it will be moved.

Boards Same Height

New Feature:
It would be good to have a parameter so that all boards have the same height (all grow and shrink together).

Use case:
My board is so full that after scrolling down I still want to be able to drag and drop from one board to another.

Not reactive when Bind boards array as vuejs data property

I am trying to bind the boards array as a data property in vuejs, on initial page load, it take all the array item and render boards correctly, however when i do modification to vue array it doesnot affect in UI, looks like kanban board are not reactive,

Do you have any function to refresh or rebuilt the boards from scratch, so when I do any changes to vue data property, I can rebuilt the boards. I tried to run the init function, however it just duplicated all the baords with changes as well, if you have a function to remove all board elements and boards with single function call, then it will be easy to delete and re call the init function to make it like reactive

Item callback "drop" firing event ignoring the "dragTo" board values

When I set the dragTo value to a board, the item callbackdrop is ignoring dragTo possible limitations.
In my project, I'm allowing the items to move through the boards one at once. It's working fine, but when this is done, I have to change the status_id of this item I dragged to the next board. To accomplish this, I created an $.ajax to post the new id to that Item. The problem is: the drop callback is firing this $.ajax dispite of the board limitations (which is visually showing that the dropping are not allowed in certain boards), changing the item ID, which is not the expected behaviour. Can you help me with this? What can I be doing wrong on here?
Sorry if this is not an Issue. Tell me if it's not. Thanks for this amazing work!

Regards,
Jhon

Support for Mobile

Hi guys,

This is an awesome library, just want to ask if the kanban supports Mobile especially Drag and Drop. See the image below (Nevermind the offline support ) Just want to show you below how Mobile kanban works.

MobileOffline2

Add class in items

It would be nice if were possible to add class to items like already have in boards

API for boards array

Hi
Would it be possible to give the API a boards[] level accessor so that we can dump the state out easily (I thought options.boards[] would do this, but ran into similar issues as #45. )
Thanks also for the library,

Edit board elements

Hi, is it possible to edit elements in the board?

Also, can we programatically move elements from one board to another if certain conditions is met?

Thanks!

React wrapper for jKanban

This is an idea issue. This library has some great built-in functionality and given the need to track data across user interactions with the board, incorporating a state management framework like React would be very compelling for more developers to adopt jKanban.

I'll try to personally do some research into common patterns for wrapping libraries with a react interface (some other examples like fullcalendar-react and react-map-gl come to mind), but any community feedback and input is appreciated!

DragTo when no card moved

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

Element is null at remove

I am developing a collaborative Kanban for a couple of users and I have a capability of remove items from a board. In that, I call jkanban.removeElement(elementId) to remove a card from current Kanban in order to add at another Kanban (like "Move" of Trello). The problem is when I call jkanban.remove() when the item is not there, jKanban raises a "el is null" error because of:

        this.removeElement = function (el) {
            if (typeof(el) === 'string')
                el = self.element.querySelector('[data-eid="' + el + '"]');
            el.remove(); //<--- here
            return self;
        };

I suggest to add a validation for removeLike methods to verify if element actually exists:

        this.removeElement = function (el) {
            if (typeof(el) === 'string')
                el = self.element.querySelector('[data-eid="' + el + '"]');
            if (el !== null)
                el.remove();
            return self;
        };

Adding only one button

we want to have only one button for adding new issues, on the first board. Is there a way to do this?

How to make a Board not movable ?

Is there a way to make a board not movable ? Dragable ?

In my case, I am building a Kanban board that has a Backlog and a Finished Boards.... I want to make those statics... not movables....

Is there a way to do this ?

Thank you

get elements from board as JSON

It would be nice to have a function to export the elements to JSON.
Using this it should be easier to send the elements to ajax for example.

Some div in board title

If I put some div in board title, ex.:

<div class="row">
<div class="col-md-9">Board Title</div>
<div class="col-md-3" style="text-align: right">Menu</div>
</div>'

Drag system failed... How I can fix it?

Customize Kanban Item

Hi there,

Is there a way we can create our own kanban custom DOM elements like this?
image

The image above indicates we had four dom elements that needs to be placed on Kanban Item.

Thanks,
Mark

Copy item between boards

Hey there,

How make a copy of item between boards? I need use some extension or adaptation from Dragula or exists some function or option for the item?

Regards.

Custom attributes to items

Wouldn't be nice if we had custom attributes to items of a board with data- like properties? Here's a suggestion:

@@ -14,6 +14,7 @@ var dragula = require('dragula');
 
     this.jKanban = function () {
         var self = this;
+        this._disallowedItemProperties = ['id', 'title', 'click', 'drag', 'dragend', 'drop'];
         this.element = '';
         this.container = '';
         this.boardContainer = [];
@@ -159,6 +160,7 @@ var dragula = require('dragula');
             nodeItem.dragfn = element.drag;
             nodeItem.dragendfn = element.dragend;
             nodeItem.dropfn = element.drop;
+            __appendCustomProperties(nodeItem, element);
             __onclickHandler(nodeItem);
             board.appendChild(nodeItem);
             return self;
@@ -249,6 +251,7 @@ var dragula = require('dragula');
                     nodeItem.dragfn = itemKanban.drag;
                     nodeItem.dragendfn = itemKanban.dragend;
                     nodeItem.dropfn = itemKanban.drop;
+                    __appendCustomProperties(nodeItem, itemKanban);
                     //add click handler of item
                     __onclickHandler(nodeItem);
                     contentBoard.appendChild(nodeItem);
@@ -351,6 +354,15 @@ var dragula = require('dragula');
             return el[0]
         }
 
+        function __appendCustomProperties(element, parentObject) {
+            for (var propertyName in parentObject) {
+                if (self._disallowedItemProperties.indexOf(propertyName) > -1) {
+                    continue;
+                }
+
+                element.setAttribute('data-' + propertyName, parentObject[propertyName]);
+            }
+        }

Usage example:

var jkanban = new jKanban({
    boards:
    [
        {
            "id"    : "_todo",
            "title" : "Todo Tasks",
            "item"  : [
                {
                    "id"      : "1",
                    "title"   : "Card inner content...",
                    "username": "marcosrocha85"
                }
            ]
        }
    ]});

That will produce a result like this:

<div data-id="_todo" class="kanban-board" style="width: 250px; margin-left: 15px; margin-right: 15px;">
    <header class="kanban-board-header">
        <div class="kanban-title-board">
            Todo Tasks
        </div>
    </header>
    <main class="kanban-drag">
        <div class="kanban-item" data-eid="1" data-username="marcosrocha85">
            Card inner content...
        </div>
    </main>
    <footer></footer>
</div>

If it's ok, I can create a pull request.

Get the order of the tabs

How can get the order of the tabs. When move the columns i cant store the order. I mean in the event dropEndl get the order and save the sequence.

Provide an optional URL/endpoint option for each item to validate the drag operation

Another feature request

What I am thinking is that each item has an optional url or endpoint, or validate option where I can slot in the URL for a json endpoint. Upon finishing the drag, this an AJAX call gets triggered to this URL and if the response is true or success, the drag operation persists, otherwise it's reverted.

How this will work for my use case is that I will have a state machine for tasks in my Ruby models and upon dragging, if the state machine verifies the state change for a task is valid and allowed, and persists the change to the database, then the UI reflects it accordingly.

I know there are affordances for adding drag functions where I could make an AJAX call myself but this interface will make this feature a lot more plug-n-play.

Feature Request: Footer option

Like the header, have the ability for a footer with it's own class. So you could total up some of the custom data options.

Change element board

How I can move item to another board by API?

I use
dropEl : function (el, target, source, sibling) {}
then
kanban.addElement(board_id, el);

But element without content
2222

P.S. I found moveElement method, but it also has that issue...

get the ID of source board on dropEl method

Hello Sir,
I am using this jkanban in SharePoint and am trying to change the status of dragged item using dropEI method.
To achieve this, i thinking to invoke a custom method using element ID and board ID.
Am able to get the element ID but i am stuck with board ID.

Please help me with some snippet so that i can proceed with this.

Get the order of elements on a board

I want to save the order state of elements on the board in the backend db. I know we can listen for call back dragendEl or dragEl in order to detect the item reordering inside a board, how can I get the new order when an item is reordered,
I also want to store the order of the Board as well when I enable dragBoards , your help is kindly appreciated

Sort Itens inside a Board

Is it possible to "sort" the itens inside a board ?

Or, is it possible to change the position of a item inside the board using javascript ?

I think that I can remove all itens and add then again in a diferent order... but, before I try this, I wanted to ask you if this is already possible...

THANK YOU !!!!

addElement to position in board

Currently addElement adds to the end. It would be nice to be able to add elements at the start (or before the x'th element)

Add a ScrollBar inside the Board

Add support to a native or at least, to custom Scrollbars (like SlimScroll), right now, the component that holds the items don´t support this, at least not without losing the drag-and-drop functionality.

Thanks.

add changed function

It would be nice to have a function that is called when something changed.
When an element is added, replaced, or a board was added,...

var kanban = new jKanban({
    changed           : function (el) {
        // something changed
        // e.g. add code to save items to server
    }, 

Cancel Drop after async function

Hi,

In our business, our items inside a board have different dragTo boards. In this case, what's the approach to use ?
We've used the dropEl event to validate if user can drop using an async function but in this case, the kanban.drake.cancel(true) will not work in the callback.

Our code:

const mergedConfig = {
           ...new KanbanConfiguration(),
           ...this.configuration,
           dropEl: (el, target, source, sibling) => {
               const currentStatusId = el.getAttribute("data-boardid");
               const targetStatusId = target.parentElement.getAttribute("data-id");
              this.workflowService.getWorkflowStateTransition(currentStatusId,targetStatusId).subscribe(
                   transition => {
                        /// post to server ...............
                   },
                   error => {
                        // tried this to undo   
                       const copy = el.cloneNode(true);
                       this.kanban.addElement(currentStatusId, copy);
                       this.kanban.removeElement(el);
                   }
               );
           }
       };
       this.kanban = new jKanban(mergedConfig);

We tried to undo the drag and drop by removing and adding element to previous board but it does not work.

Thank you.

Every boards duplicate in the board list given as parameter

Hi !

We have to give a list of boards in order to create our jkanban.
I see that this list have 2x more elements after jkanban creation than before.

For instance, if I have 5 elements in the boardJson given as "boards" parameter, after creation of jkanban I have boardJson.lenght = 10.
This is not good for me because I need this list for other purpose. Duplicate boards are boring the handle.

Looking into the code, I see this " self.options.boards.push(board);" in the "addBoards" function.
As boards are already in options, I think that this is unusefull and the root of my trouble.

I comment this line, and everything "seems" to work fine without this line.

Can I have your opinion on this?

Thank you!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.