|
|
@ -5,6 +5,7 @@ define([
|
|
|
|
'/common/sframe-app-framework.js',
|
|
|
|
'/common/sframe-app-framework.js',
|
|
|
|
'/common/common-util.js',
|
|
|
|
'/common/common-util.js',
|
|
|
|
'/common/common-hash.js',
|
|
|
|
'/common/common-hash.js',
|
|
|
|
|
|
|
|
'/common/common-interface.js',
|
|
|
|
'/common/modes.js',
|
|
|
|
'/common/modes.js',
|
|
|
|
'/customize/messages.js',
|
|
|
|
'/customize/messages.js',
|
|
|
|
'/kanban/jkanban.js',
|
|
|
|
'/kanban/jkanban.js',
|
|
|
@ -16,13 +17,15 @@ define([
|
|
|
|
Framework,
|
|
|
|
Framework,
|
|
|
|
Util,
|
|
|
|
Util,
|
|
|
|
Hash,
|
|
|
|
Hash,
|
|
|
|
|
|
|
|
UI,
|
|
|
|
Modes,
|
|
|
|
Modes,
|
|
|
|
Messages) {
|
|
|
|
Messages)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
console.log(Messages);
|
|
|
|
|
|
|
|
|
|
|
|
// Kanban code
|
|
|
|
// Kanban code
|
|
|
|
var initKanban = function (framework, boards) {
|
|
|
|
var initKanban = function (framework, boards) {
|
|
|
|
var defaultBoards = [
|
|
|
|
var defaultBoards = [{ // XXX
|
|
|
|
{
|
|
|
|
|
|
|
|
"id": "todo",
|
|
|
|
"id": "todo",
|
|
|
|
"title": "To Do",
|
|
|
|
"title": "To Do",
|
|
|
|
"color": "blue",
|
|
|
|
"color": "blue",
|
|
|
@ -34,35 +37,27 @@ define([
|
|
|
|
"title": "Item 2"
|
|
|
|
"title": "Item 2"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
]
|
|
|
|
},
|
|
|
|
}, {
|
|
|
|
{
|
|
|
|
|
|
|
|
"id": "working",
|
|
|
|
"id": "working",
|
|
|
|
"title": "Working",
|
|
|
|
"title": "Working",
|
|
|
|
"color": "orange",
|
|
|
|
"color": "orange",
|
|
|
|
"item": [
|
|
|
|
"item": [{
|
|
|
|
{
|
|
|
|
|
|
|
|
"title": "Item 3",
|
|
|
|
"title": "Item 3",
|
|
|
|
},
|
|
|
|
}, {
|
|
|
|
{
|
|
|
|
|
|
|
|
"title": "Item 4",
|
|
|
|
"title": "Item 4",
|
|
|
|
}
|
|
|
|
}]
|
|
|
|
]
|
|
|
|
}, {
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
"id": "done",
|
|
|
|
"id": "done",
|
|
|
|
"title": "Done",
|
|
|
|
"title": "Done",
|
|
|
|
"color": "green",
|
|
|
|
"color": "green",
|
|
|
|
"item": [
|
|
|
|
"item": [{
|
|
|
|
{
|
|
|
|
|
|
|
|
"title": "Item 5",
|
|
|
|
"title": "Item 5",
|
|
|
|
},
|
|
|
|
}, {
|
|
|
|
{
|
|
|
|
|
|
|
|
"title": "Item 6",
|
|
|
|
"title": "Item 6",
|
|
|
|
}
|
|
|
|
}]
|
|
|
|
]
|
|
|
|
|
|
|
|
}];
|
|
|
|
}];
|
|
|
|
|
|
|
|
|
|
|
|
if (boards == null) {
|
|
|
|
if (!boards) {
|
|
|
|
console.log("Initializing with default boards content");
|
|
|
|
console.log("Initializing with default boards content");
|
|
|
|
boards = defaultBoards;
|
|
|
|
boards = defaultBoards;
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
@ -72,7 +67,7 @@ define([
|
|
|
|
// Remove any existing elements
|
|
|
|
// Remove any existing elements
|
|
|
|
$(".kanban-container-outer").remove();
|
|
|
|
$(".kanban-container-outer").remove();
|
|
|
|
|
|
|
|
|
|
|
|
var kanban = new jKanban({
|
|
|
|
var kanban = new window.jKanban({
|
|
|
|
element: '#cp-app-kanban-content',
|
|
|
|
element: '#cp-app-kanban-content',
|
|
|
|
gutter: '15px',
|
|
|
|
gutter: '15px',
|
|
|
|
widthBoard: '300px',
|
|
|
|
widthBoard: '300px',
|
|
|
@ -139,18 +134,17 @@ define([
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
},
|
|
|
|
colorClick: function (el, boardId) {
|
|
|
|
colorClick: function (el) {
|
|
|
|
console.log("in color click");
|
|
|
|
console.log("in color click");
|
|
|
|
var board = $(el.parentNode).attr("data-id");
|
|
|
|
var board = $(el.parentNode).attr("data-id");
|
|
|
|
var boardJSON = kanban.getBoardJSON(board);
|
|
|
|
var boardJSON = kanban.getBoardJSON(board);
|
|
|
|
var currentColor = boardJSON.color;
|
|
|
|
var currentColor = boardJSON.color;
|
|
|
|
console.log("Current color " + currentColor);
|
|
|
|
console.log("Current color " + currentColor);
|
|
|
|
var index = kanban.options.colors.findIndex(function (element) {
|
|
|
|
var index = kanban.options.colors.findIndex(function (element) {
|
|
|
|
return (element == currentColor)
|
|
|
|
return (element === currentColor);
|
|
|
|
}) + 1;
|
|
|
|
}) + 1;
|
|
|
|
console.log("Next index " + index);
|
|
|
|
console.log("Next index " + index);
|
|
|
|
if (index >= kanban.options.colors.length)
|
|
|
|
if (index >= kanban.options.colors.length) { index = 0; }
|
|
|
|
index = 0;
|
|
|
|
|
|
|
|
var nextColor = kanban.options.colors[index];
|
|
|
|
var nextColor = kanban.options.colors[index];
|
|
|
|
console.log("Next color " + nextColor);
|
|
|
|
console.log("Next color " + nextColor);
|
|
|
|
boardJSON.color = nextColor;
|
|
|
|
boardJSON.color = nextColor;
|
|
|
@ -160,11 +154,14 @@ define([
|
|
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
},
|
|
|
|
removeClick: function (el, boardId) {
|
|
|
|
removeClick: function (el, boardId) {
|
|
|
|
if (confirm("Do you want to delete this board?")) {
|
|
|
|
// XXX
|
|
|
|
|
|
|
|
UI.confirm("Do you want to delete this board?", function (yes) {
|
|
|
|
|
|
|
|
if (!yes) { return; }
|
|
|
|
console.log("Delete board");
|
|
|
|
console.log("Delete board");
|
|
|
|
var boardName = $(el.parentNode.parentNode).attr("data-id");
|
|
|
|
var boardName = $(el.parentNode.parentNode).attr("data-id");
|
|
|
|
for (index in kanban.options.boards) {
|
|
|
|
console.log(boardName, boardId); // TODO
|
|
|
|
if (kanban.options.boards[index].id == boardName) {
|
|
|
|
for (var index in kanban.options.boards) {
|
|
|
|
|
|
|
|
if (kanban.options.boards[index].id === boardName) {
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
index++;
|
|
|
|
index++;
|
|
|
@ -172,7 +169,7 @@ define([
|
|
|
|
kanban.options.boards.splice(index, 1);
|
|
|
|
kanban.options.boards.splice(index, 1);
|
|
|
|
kanban.removeBoard(boardName);
|
|
|
|
kanban.removeBoard(boardName);
|
|
|
|
kanban.onChange();
|
|
|
|
kanban.onChange();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
},
|
|
|
|
buttonClick: function (el, boardId) {
|
|
|
|
buttonClick: function (el, boardId) {
|
|
|
|
console.log(el);
|
|
|
|
console.log(el);
|
|
|
@ -180,20 +177,20 @@ define([
|
|
|
|
// create a form to enter element
|
|
|
|
// create a form to enter element
|
|
|
|
var formItem = document.createElement('form');
|
|
|
|
var formItem = document.createElement('form');
|
|
|
|
formItem.setAttribute("class", "itemform");
|
|
|
|
formItem.setAttribute("class", "itemform");
|
|
|
|
formItem.innerHTML = '<div class="form-group"><textarea class="form-control" rows="2" autofocus></textarea></div><div class="form-group"><button type="submit" class="btn btn-primary btn-xs">Submit</button><button type="button" id="CancelBtn" class="btn btn-default btn-xs pull-right">Cancel</button></div>'
|
|
|
|
formItem.innerHTML = '<div class="form-group"><textarea class="form-control" rows="2" autofocus></textarea></div><div class="form-group"><button type="submit" class="btn btn-primary btn-xs">Submit</button><button type="button" id="CancelBtn" class="btn btn-default btn-xs pull-right">Cancel</button></div>';
|
|
|
|
|
|
|
|
|
|
|
|
kanban.addForm(boardId, formItem);
|
|
|
|
kanban.addForm(boardId, formItem);
|
|
|
|
formItem.addEventListener("submit", function (e) {
|
|
|
|
formItem.addEventListener("submit", function (e) {
|
|
|
|
e.preventDefault();
|
|
|
|
e.preventDefault();
|
|
|
|
var text = e.target[0].value
|
|
|
|
var text = e.target[0].value;
|
|
|
|
kanban.addElement(boardId, {
|
|
|
|
kanban.addElement(boardId, {
|
|
|
|
"title": text,
|
|
|
|
"title": text,
|
|
|
|
})
|
|
|
|
});
|
|
|
|
formItem.parentNode.removeChild(formItem);
|
|
|
|
formItem.parentNode.removeChild(formItem);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
document.getElementById('CancelBtn').onclick = function () {
|
|
|
|
document.getElementById('CancelBtn').onclick = function () {
|
|
|
|
formItem.parentNode.removeChild(formItem)
|
|
|
|
formItem.parentNode.removeChild(formItem);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
},
|
|
|
|
},
|
|
|
|
addItemButton: true,
|
|
|
|
addItemButton: true,
|
|
|
|
boards: boards
|
|
|
|
boards: boards
|
|
|
@ -202,29 +199,21 @@ define([
|
|
|
|
var addBoardDefault = document.getElementById('kanban-addboard');
|
|
|
|
var addBoardDefault = document.getElementById('kanban-addboard');
|
|
|
|
addBoardDefault.addEventListener('click', function () {
|
|
|
|
addBoardDefault.addEventListener('click', function () {
|
|
|
|
var counter = 1;
|
|
|
|
var counter = 1;
|
|
|
|
found = false;
|
|
|
|
|
|
|
|
while (found) {
|
|
|
|
// Get the new board id
|
|
|
|
for (var board in kanban.options.boards) {
|
|
|
|
while (kanban.options.boards.indexOf("board" + counter) !== -1) {
|
|
|
|
if (board.id == "board" + counter) {
|
|
|
|
|
|
|
|
counter++;
|
|
|
|
counter++;
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
found = true;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
kanban.addBoards(
|
|
|
|
// XXX
|
|
|
|
[{
|
|
|
|
kanban.addBoards([{
|
|
|
|
"id": "board" + counter,
|
|
|
|
"id": "board" + counter,
|
|
|
|
"title": "New Board",
|
|
|
|
"title": "New Board",
|
|
|
|
"color": "yellow",
|
|
|
|
"color": "yellow",
|
|
|
|
"item": [
|
|
|
|
"item": [{
|
|
|
|
{
|
|
|
|
|
|
|
|
"title": "Item 1",
|
|
|
|
"title": "Item 1",
|
|
|
|
}
|
|
|
|
|
|
|
|
]
|
|
|
|
|
|
|
|
}]
|
|
|
|
}]
|
|
|
|
)
|
|
|
|
}]);
|
|
|
|
kanban.onChange();
|
|
|
|
kanban.onChange();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
@ -258,7 +247,7 @@ define([
|
|
|
|
};
|
|
|
|
};
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
framework.onReady(function (newPad) {
|
|
|
|
framework.onReady(function () {
|
|
|
|
$("#cp-app-kanban-content").focus();
|
|
|
|
$("#cp-app-kanban-content").focus();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
@ -273,8 +262,7 @@ define([
|
|
|
|
Framework.create({
|
|
|
|
Framework.create({
|
|
|
|
toolbarContainer: '#cme_toolbox',
|
|
|
|
toolbarContainer: '#cme_toolbox',
|
|
|
|
contentContainer: '#cp-app-kanban-editor',
|
|
|
|
contentContainer: '#cp-app-kanban-editor',
|
|
|
|
}, waitFor(function (fw) {
|
|
|
|
}, waitFor(function (framework) {
|
|
|
|
framework = fw;
|
|
|
|
|
|
|
|
andThen2(framework);
|
|
|
|
andThen2(framework);
|
|
|
|
}));
|
|
|
|
}));
|
|
|
|
});
|
|
|
|
});
|
|
|
|