Improve subtask toggle
|
Before Width: | Height: | Size: 3.7 KiB After Width: | Height: | Size: 6.9 KiB |
|
Before Width: | Height: | Size: 3.7 KiB After Width: | Height: | Size: 6.9 KiB |
|
Before Width: | Height: | Size: 3.7 KiB After Width: | Height: | Size: 4.6 KiB |
|
Before Width: | Height: | Size: 3.7 KiB After Width: | Height: | Size: 6.9 KiB |
|
Before Width: | Height: | Size: 3.7 KiB After Width: | Height: | Size: 4.6 KiB |
|
Before Width: | Height: | Size: 3.7 KiB After Width: | Height: | Size: 6.3 KiB |
6
assets/css/vendor.min.css
vendored
4
assets/js/app.min.js
vendored
44
assets/js/components/subtask-drag-and-drop.js
Normal file
@@ -0,0 +1,44 @@
|
||||
KB.on('dom.ready', function() {
|
||||
|
||||
function savePosition(subtaskId, position) {
|
||||
var url = $(".subtasks-table").data("save-position-url");
|
||||
|
||||
$.ajax({
|
||||
cache: false,
|
||||
url: url,
|
||||
contentType: "application/json",
|
||||
type: "POST",
|
||||
processData: false,
|
||||
data: JSON.stringify({
|
||||
"subtask_id": subtaskId,
|
||||
"position": position
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
$(".draggable-row-handle").mouseenter(function() {
|
||||
$(this).parent().parent().addClass("draggable-item-hover");
|
||||
}).mouseleave(function() {
|
||||
$(this).parent().parent().removeClass("draggable-item-hover");
|
||||
});
|
||||
|
||||
$(".subtasks-table tbody").sortable({
|
||||
forcePlaceholderSize: true,
|
||||
handle: "td:first i",
|
||||
helper: function(e, ui) {
|
||||
ui.children().each(function() {
|
||||
$(this).width($(this).width());
|
||||
});
|
||||
|
||||
return ui;
|
||||
},
|
||||
stop: function(event, ui) {
|
||||
var subtask = ui.item;
|
||||
subtask.removeClass("draggable-item-selected");
|
||||
savePosition(subtask.data("subtask-id"), subtask.index() + 1);
|
||||
},
|
||||
start: function(event, ui) {
|
||||
ui.item.addClass("draggable-item-selected");
|
||||
}
|
||||
}).disableSelection();
|
||||
});
|
||||
35
assets/js/components/subtask-toggle-status.js
Normal file
@@ -0,0 +1,35 @@
|
||||
KB.on('dom.ready', function () {
|
||||
$(document).on('click', '.js-subtask-toggle-status', function(e) {
|
||||
var el = $(this);
|
||||
var url = el.attr('href');
|
||||
|
||||
e.preventDefault();
|
||||
|
||||
$.ajax({
|
||||
cache: false,
|
||||
url: url,
|
||||
success: function(data) {
|
||||
if (url.indexOf('fragment=table') != -1) {
|
||||
$('.subtasks-table').replaceWith(data);
|
||||
} else if (url.indexOf('fragment=rows') != -1) {
|
||||
$(el).closest('.task-list-subtasks').replaceWith(data);
|
||||
} else {
|
||||
$(el).closest('.subtask-title').replaceWith(data);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$(document).on('click', '.js-subtask-toggle-timer', function(e) {
|
||||
var el = $(this);
|
||||
e.preventDefault();
|
||||
|
||||
$.ajax({
|
||||
cache: false,
|
||||
url: el.attr('href'),
|
||||
success: function(data) {
|
||||
$(el).closest('.subtask-time-tracking').replaceWith(data);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -1,86 +0,0 @@
|
||||
Kanboard.Subtask = function(app) {
|
||||
this.app = app;
|
||||
};
|
||||
|
||||
Kanboard.Subtask.prototype.listen = function() {
|
||||
var self = this;
|
||||
this.dragAndDrop();
|
||||
|
||||
$(document).on("click", ".js-subtask-toggle-status", function(e) {
|
||||
var el = $(this);
|
||||
e.preventDefault();
|
||||
|
||||
$.ajax({
|
||||
cache: false,
|
||||
url: el.attr("href"),
|
||||
success: function(data) {
|
||||
$(el).closest('.subtask-title').replaceWith(data);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$(document).on("click", ".js-subtask-toggle-timer", function(e) {
|
||||
var el = $(this);
|
||||
e.preventDefault();
|
||||
|
||||
$.ajax({
|
||||
cache: false,
|
||||
url: el.attr("href"),
|
||||
success: function(data) {
|
||||
$(el).closest('.subtask-time-tracking').replaceWith(data);
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
Kanboard.Subtask.prototype.dragAndDrop = function() {
|
||||
var self = this;
|
||||
|
||||
$(".draggable-row-handle").mouseenter(function() {
|
||||
$(this).parent().parent().addClass("draggable-item-hover");
|
||||
}).mouseleave(function() {
|
||||
$(this).parent().parent().removeClass("draggable-item-hover");
|
||||
});
|
||||
|
||||
$(".subtasks-table tbody").sortable({
|
||||
forcePlaceholderSize: true,
|
||||
handle: "td:first i",
|
||||
helper: function(e, ui) {
|
||||
ui.children().each(function() {
|
||||
$(this).width($(this).width());
|
||||
});
|
||||
|
||||
return ui;
|
||||
},
|
||||
stop: function(event, ui) {
|
||||
var subtask = ui.item;
|
||||
subtask.removeClass("draggable-item-selected");
|
||||
self.savePosition(subtask.data("subtask-id"), subtask.index() + 1);
|
||||
},
|
||||
start: function(event, ui) {
|
||||
ui.item.addClass("draggable-item-selected");
|
||||
}
|
||||
}).disableSelection();
|
||||
};
|
||||
|
||||
Kanboard.Subtask.prototype.savePosition = function(subtaskId, position) {
|
||||
var url = $(".subtasks-table").data("save-position-url");
|
||||
var self = this;
|
||||
|
||||
this.app.showLoadingIcon();
|
||||
|
||||
$.ajax({
|
||||
cache: false,
|
||||
url: url,
|
||||
contentType: "application/json",
|
||||
type: "POST",
|
||||
processData: false,
|
||||
data: JSON.stringify({
|
||||
"subtask_id": subtaskId,
|
||||
"position": position
|
||||
}),
|
||||
complete: function() {
|
||||
self.app.hideLoadingIcon();
|
||||
}
|
||||
});
|
||||
};
|
||||