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