Fix: Cannot reorder subtasks after changing the status

Fixes #4925
This commit is contained in:
Frédéric Guillot
2023-03-28 20:03:38 -07:00
committed by Frédéric Guillot
parent 82ea26f827
commit 3bc4cc8291
3 changed files with 36 additions and 28 deletions

View File

@@ -1,5 +1,4 @@
KB.on('dom.ready', function() {
(function () {
function savePosition(subtaskId, position) {
var url = $(".subtasks-table").data("save-position-url");
@@ -16,29 +15,35 @@ KB.on('dom.ready', function() {
});
}
$(".draggable-row-handle").mouseenter(function() {
$(this).parent().parent().addClass("draggable-item-hover");
}).mouseleave(function() {
$(this).parent().parent().removeClass("draggable-item-hover");
});
function bootstrap() {
$(".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();
}
$(".subtasks-table tbody").sortable({
forcePlaceholderSize: true,
handle: "td:first i",
helper: function(e, ui) {
ui.children().each(function() {
$(this).width($(this).width());
});
KB.on('dom.ready', bootstrap);
KB.on('subtasks.reloaded', bootstrap);
}());
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();
});

View File

@@ -16,6 +16,7 @@ KB.on('dom.ready', function () {
} else {
$(el).closest('.subtask-title').replaceWith(data);
}
KB.trigger('subtasks.reloaded');
}
});
});