|
|
@ -21,7 +21,6 @@ define([
|
|
|
|
Modes,
|
|
|
|
Modes,
|
|
|
|
Messages)
|
|
|
|
Messages)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
console.log(Messages);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Kanban code
|
|
|
|
// Kanban code
|
|
|
|
var initKanban = function (framework, boards) {
|
|
|
|
var initKanban = function (framework, boards) {
|
|
|
@ -64,6 +63,14 @@ define([
|
|
|
|
// Remove any existing elements
|
|
|
|
// Remove any existing elements
|
|
|
|
$(".kanban-container-outer").remove();
|
|
|
|
$(".kanban-container-outer").remove();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var getInput = function () {
|
|
|
|
|
|
|
|
return $('<input>', {
|
|
|
|
|
|
|
|
'type': 'text',
|
|
|
|
|
|
|
|
'id': 'kanban-edit',
|
|
|
|
|
|
|
|
'size': '30'
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
var kanban = new window.jKanban({
|
|
|
|
var kanban = new window.jKanban({
|
|
|
|
element: '#cp-app-kanban-content',
|
|
|
|
element: '#cp-app-kanban-content',
|
|
|
|
gutter: '15px',
|
|
|
|
gutter: '15px',
|
|
|
@ -80,30 +87,41 @@ define([
|
|
|
|
kanban.inEditMode = true;
|
|
|
|
kanban.inEditMode = true;
|
|
|
|
var name = $(el).text();
|
|
|
|
var name = $(el).text();
|
|
|
|
$(el).html('');
|
|
|
|
$(el).html('');
|
|
|
|
$('<input></input>')
|
|
|
|
var $input = getInput().val(name).appendTo(el).focus();
|
|
|
|
.attr({
|
|
|
|
$input[0].select();
|
|
|
|
'type': 'text',
|
|
|
|
var save = function () {
|
|
|
|
'name': 'text',
|
|
|
|
// Store the value
|
|
|
|
'id': 'kanban_edit',
|
|
|
|
var name = $input.val();
|
|
|
|
'size': '30',
|
|
|
|
// Remove the input
|
|
|
|
'value': name
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
.appendTo(el);
|
|
|
|
|
|
|
|
$('#kanban_edit').focus();
|
|
|
|
|
|
|
|
$('#kanban_edit').blur(function () {
|
|
|
|
|
|
|
|
var name = $('#kanban_edit').val();
|
|
|
|
|
|
|
|
$(el).text(name);
|
|
|
|
$(el).text(name);
|
|
|
|
|
|
|
|
// Save the value for the correct board
|
|
|
|
var board = $(el.parentNode.parentNode).attr("data-id");
|
|
|
|
var board = $(el.parentNode.parentNode).attr("data-id");
|
|
|
|
var pos = kanban.findElementPosition(el);
|
|
|
|
var pos = kanban.findElementPosition(el);
|
|
|
|
console.log(pos);
|
|
|
|
|
|
|
|
console.log(board);
|
|
|
|
|
|
|
|
kanban.getBoardJSON(board).item[pos].title = name;
|
|
|
|
kanban.getBoardJSON(board).item[pos].title = name;
|
|
|
|
kanban.onChange();
|
|
|
|
kanban.onChange();
|
|
|
|
|
|
|
|
// Unlock edit mode
|
|
|
|
kanban.inEditMode = false;
|
|
|
|
kanban.inEditMode = false;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
$input.blur(save);
|
|
|
|
|
|
|
|
$input.keydown(function (e) {
|
|
|
|
|
|
|
|
if (e.which === 13) {
|
|
|
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
|
|
|
e.stopPropagation();
|
|
|
|
|
|
|
|
save();
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (e.which === 27) {
|
|
|
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
|
|
|
e.stopPropagation();
|
|
|
|
|
|
|
|
$(el).text(name);
|
|
|
|
|
|
|
|
kanban.inEditMode = false;
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
},
|
|
|
|
boardTitleClick: function (el) {
|
|
|
|
boardTitleClick: function (el, e) {
|
|
|
|
|
|
|
|
e.stopPropagation();
|
|
|
|
if (kanban.inEditMode) {
|
|
|
|
if (kanban.inEditMode) {
|
|
|
|
console.log("An edit is already active");
|
|
|
|
console.log("An edit is already active");
|
|
|
|
return;
|
|
|
|
return;
|
|
|
@ -111,25 +129,36 @@ define([
|
|
|
|
kanban.inEditMode = true;
|
|
|
|
kanban.inEditMode = true;
|
|
|
|
var name = $(el).text();
|
|
|
|
var name = $(el).text();
|
|
|
|
$(el).html('');
|
|
|
|
$(el).html('');
|
|
|
|
$('<input></input>')
|
|
|
|
var $input = getInput().val(name).appendTo(el).focus();
|
|
|
|
.attr({
|
|
|
|
$input[0].select();
|
|
|
|
'type': 'text',
|
|
|
|
var save = function () {
|
|
|
|
'name': 'text',
|
|
|
|
// Store the value
|
|
|
|
'id': 'kanban_edit',
|
|
|
|
var name = $input.val();
|
|
|
|
'size': '30',
|
|
|
|
// Remove the input
|
|
|
|
'value': name
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
.appendTo(el);
|
|
|
|
|
|
|
|
$('#kanban_edit').focus();
|
|
|
|
|
|
|
|
$('#kanban_edit').blur(function () {
|
|
|
|
|
|
|
|
var name = $('#kanban_edit').val();
|
|
|
|
|
|
|
|
$(el).text(name);
|
|
|
|
$(el).text(name);
|
|
|
|
|
|
|
|
// Save the value for the correct board
|
|
|
|
var board = $(el.parentNode.parentNode).attr("data-id");
|
|
|
|
var board = $(el.parentNode.parentNode).attr("data-id");
|
|
|
|
kanban.getBoardJSON(board).title = name;
|
|
|
|
kanban.getBoardJSON(board).title = name;
|
|
|
|
kanban.onChange();
|
|
|
|
kanban.onChange();
|
|
|
|
|
|
|
|
// Unlock edit mode
|
|
|
|
kanban.inEditMode = false;
|
|
|
|
kanban.inEditMode = false;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
$input.blur(save);
|
|
|
|
|
|
|
|
$input.keydown(function (e) {
|
|
|
|
|
|
|
|
if (e.which === 13) {
|
|
|
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
|
|
|
e.stopPropagation();
|
|
|
|
|
|
|
|
save();
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (e.which === 27) {
|
|
|
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
|
|
|
e.stopPropagation();
|
|
|
|
|
|
|
|
$(el).text(name);
|
|
|
|
|
|
|
|
kanban.inEditMode = false;
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
},
|
|
|
|
colorClick: function (el) {
|
|
|
|
colorClick: function (el) {
|
|
|
|
console.log("in color click");
|
|
|
|
console.log("in color click");
|
|
|
@ -150,7 +179,7 @@ define([
|
|
|
|
kanban.onChange();
|
|
|
|
kanban.onChange();
|
|
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
},
|
|
|
|
removeClick: function (el, boardId) {
|
|
|
|
removeClick: function (el) {
|
|
|
|
UI.confirm(Messages.kanban_deleteBoard, function (yes) {
|
|
|
|
UI.confirm(Messages.kanban_deleteBoard, function (yes) {
|
|
|
|
if (!yes) { return; }
|
|
|
|
if (!yes) { return; }
|
|
|
|
console.log("Delete board");
|
|
|
|
console.log("Delete board");
|
|
|
@ -166,26 +195,41 @@ define([
|
|
|
|
kanban.onChange();
|
|
|
|
kanban.onChange();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
},
|
|
|
|
},
|
|
|
|
buttonClick: function (el, boardId) {
|
|
|
|
buttonClick: function (el, boardId, e) {
|
|
|
|
console.log(el);
|
|
|
|
e.stopPropagation();
|
|
|
|
console.log(boardId);
|
|
|
|
if (kanban.inEditMode) {
|
|
|
|
|
|
|
|
console.log("An edit is already active");
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
kanban.inEditMode = true;
|
|
|
|
// create a form to enter element
|
|
|
|
// create a form to enter element
|
|
|
|
var formItem = document.createElement('form');
|
|
|
|
var $item = $('<div>', {'class': 'kanban-item'});
|
|
|
|
formItem.setAttribute("class", "itemform");
|
|
|
|
var $input = getInput().val(name).appendTo($item);
|
|
|
|
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, $item[0]);
|
|
|
|
|
|
|
|
$input.focus();
|
|
|
|
kanban.addForm(boardId, formItem);
|
|
|
|
var save = function () {
|
|
|
|
formItem.addEventListener("submit", function (e) {
|
|
|
|
$item.remove();
|
|
|
|
e.preventDefault();
|
|
|
|
|
|
|
|
var text = e.target[0].value;
|
|
|
|
|
|
|
|
kanban.addElement(boardId, {
|
|
|
|
kanban.addElement(boardId, {
|
|
|
|
"title": text,
|
|
|
|
"title": $input.val(),
|
|
|
|
});
|
|
|
|
});
|
|
|
|
formItem.parentNode.removeChild(formItem);
|
|
|
|
kanban.inEditMode = false;
|
|
|
|
});
|
|
|
|
|
|
|
|
document.getElementById('CancelBtn').onclick = function () {
|
|
|
|
|
|
|
|
formItem.parentNode.removeChild(formItem);
|
|
|
|
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
$input.blur(save);
|
|
|
|
|
|
|
|
$input.keydown(function (e) {
|
|
|
|
|
|
|
|
if (e.which === 13) {
|
|
|
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
|
|
|
e.stopPropagation();
|
|
|
|
|
|
|
|
save();
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (e.which === 27) {
|
|
|
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
|
|
|
e.stopPropagation();
|
|
|
|
|
|
|
|
$(el).text(name);
|
|
|
|
|
|
|
|
kanban.inEditMode = false;
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
},
|
|
|
|
},
|
|
|
|
addItemButton: true,
|
|
|
|
addItemButton: true,
|
|
|
|
boards: boards,
|
|
|
|
boards: boards,
|
|
|
|