riktar / jkanban

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

Every boards duplicate in the board list given as parameter #45

Closed Adioud closed 5 years ago

Adioud commented 5 years ago

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!

marcosrocha85 commented 5 years ago

I never saw that behavior. I have a client with 5 boards and a huge amount of 100+ items per board doing it's job with ajax requests at every interaction. Btw, I guess that is not a DOM problem, but just that boardJson property.

Just in time: I never used that property before. 😳

mkooo commented 5 years ago

Why do I get double the object data after creating jkanban?

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <title>Title</title>
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/riktar/jkanban/dist/jkanban.min.css">

</head>
<body>
<div id="myKanban"></div>

<script src="https://cdn.jsdelivr.net/gh/riktar/jkanban/dist/jkanban.min.js"></script>
<script>
  var defaultBoards = [
          { id: '1',title: 'task', item: [{id:'1-1',title:'add something1'}]},
          { id: '1',title: 'working', item: [{id:'1-1',title:'add something2'}]},
          { id: '1',title: 'done', item: [{id:'1-1',title:'add something3'}]}
      ];

  var KanbanTest = new jKanban({
      element: '#myKanban',
      gutter: '10px',
      widthBoard: '450px',
      boards: defaultBoards
  });

    console.log(defaultBoards);
</script>
</body>
</html>

The contents of [defaultBoards] are doubled.

riktar commented 5 years ago

Hi @mkooo, all ids of the boards must be unique, in your code all the boards have id:'1'

mkooo commented 5 years ago

Hi, @riktar Thank you for your comment. I tried to fix the source code. However, the problem could not be solved yet.

My object data is only 3 elements, but the result of [console.log] is 6 elements.

Sorry to trouble you, but could you give me some advice?

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <title>Title</title>
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/riktar/jkanban/dist/jkanban.min.css">

</head>
<body>
<div id="myKanban"></div>

<script src="https://cdn.jsdelivr.net/gh/riktar/jkanban/dist/jkanban.min.js"></script>
<script>
  var defaultBoards = [
          { id: '1',title: 'task', item: [{id:'1-1',title:'add something1'}]},
          { id: '2',title: 'working', item: [{id:'1-2',title:'add something2'}]},
          { id: '3',title: 'done', item: [{id:'1-3',title:'add something3'}]}
      ];

  var KanbanTest = new jKanban({
      element: '#myKanban',
      gutter: '10px',
      widthBoard: '450px',
      boards: defaultBoards
  });

    console.log(defaultBoards);
</script>
</body>
</html>

---- result of console.log ----

[{ id: '1',title: 'task', item: [{id:'1-1',title:'add something1'}]},
{ id: '2',title: 'working', item: [{id:'1-2',title:'add something2'}]},
{ id: '3',title: 'done', item: [{id:'1-3',title:'add something3'}]},
{ id: '1',title: 'task', item: [{id:'1-1',title:'add something1'}]},
{ id: '2',title: 'working', item: [{id:'1-2',title:'add something2'}]},
{ id: '3',title: 'done', item: [{id:'1-3',title:'add something3'}]}]
riktar commented 5 years ago

@mkooo defaultBoards must be used only for configuration, if you want the boards or elemnet inside jKanban you must use the API https://github.com/riktar/jkanban#api

riktar commented 5 years ago

fixed in 1d3f2bf90420b291e0531d96d672cbb4c83a648e