fix drag
parent
6a904b76f0
commit
564f056b05
|
|
@ -519,15 +519,20 @@
|
|||
|
||||
// Drag-and-drop для записей
|
||||
$('#installs-list').on('dragstart', '.install-item', function (e) {
|
||||
console.log('Drag start:', $(this).data('id'));
|
||||
e.originalEvent.dataTransfer.setData('text/plain', $(this).data('id'));
|
||||
});
|
||||
|
||||
$('#folder-tree').on('dragover', function (e) {
|
||||
e.preventDefault();
|
||||
console.log('Drag over');
|
||||
}).on('drop', function (e) {
|
||||
e.preventDefault();
|
||||
console.log('Drop event triggered');
|
||||
const installId = e.originalEvent.dataTransfer.getData('text');
|
||||
console.log('Dropped installId:', installId);
|
||||
let targetFolderId = $(e.target).closest('.jstree-node').attr('id');
|
||||
console.log('Target folderId:', targetFolderId);
|
||||
if (installId && targetFolderId) {
|
||||
targetFolderId = targetFolderId === "root" ? null : targetFolderId;
|
||||
moveInstallToFolder(installId, targetFolderId);
|
||||
|
|
@ -787,24 +792,27 @@
|
|||
}
|
||||
|
||||
function moveInstallToFolder(installId, folderId) {
|
||||
const install = allInstalls.find(i => i.id === installId);
|
||||
if (install) {
|
||||
$.ajax({
|
||||
url: `${API_URL}/install/${installId}`,
|
||||
type: 'PUT',
|
||||
contentType: 'application/json',
|
||||
data: JSON.stringify({
|
||||
folder_id: folderId,
|
||||
protocol: install.protocol
|
||||
}),
|
||||
success: function () {
|
||||
loadInstalls(selectedFolderId);
|
||||
},
|
||||
error: function (xhr, status, error) {
|
||||
console.error("Ошибка переноса:", status, error);
|
||||
console.log('Moving installId:', installId, 'to folderId:', folderId);
|
||||
$.ajax({
|
||||
url: `${API_URL}/install/${installId}`,
|
||||
type: 'PUT',
|
||||
contentType: 'application/json',
|
||||
data: JSON.stringify({
|
||||
folder_id: folderId
|
||||
}),
|
||||
success: function () {
|
||||
console.log('Move successful');
|
||||
loadInstalls(selectedFolderId);
|
||||
},
|
||||
error: function (xhr, status, error) {
|
||||
console.error("Ошибка переноса:", status, error);
|
||||
if (xhr.status === 404) {
|
||||
alert("Запись не найдена");
|
||||
} else {
|
||||
alert("Ошибка при перемещении записи");
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function exportCSV() {
|
||||
|
|
|
|||
Loading…
Reference in New Issue