Many fixes

This commit is contained in:
root
2026-01-16 21:58:12 +03:00
parent b810a17649
commit 77f76c8c28
45 changed files with 3392 additions and 1243 deletions
+42 -2
View File
@@ -131,20 +131,42 @@ function handleDrop(e) {
if (itemId && newColumnId) {
if (moveUrl) {
// AJAX перемещение
console.log('Moving deal:', itemId, 'to stage:', newColumnId);
// Находим перетаскиваемую карточку
const draggedCard = document.querySelector(`.kanban-card[data-item-id="${itemId}"]`);
const sourceColumn = draggedCard ? draggedCard.closest('.kanban-cards-container') : null;
// AJAX перемещение - base.js автоматически добавит CSRF заголовок
fetch(moveUrl, {
method: 'POST',
credentials: 'same-origin',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
'X-Requested-With': 'XMLHttpRequest'
},
body: 'item_id=' + itemId + '&column_id=' + newColumnId
body: 'deal_id=' + itemId + '&stage_id=' + newColumnId
})
.then(response => response.json())
.then(data => {
if (data.success) {
if (onMove) {
window[onMove](itemId, newColumnId, data);
} else if (draggedCard && sourceColumn) {
// Перемещаем карточку в новую колонку
const targetContainer = this;
targetContainer.appendChild(draggedCard);
// Обновляем счётчики колонок
updateColumnCounters(sourceColumn);
updateColumnCounters(targetContainer);
// Анимация успешного перемещения
draggedCard.style.transition = 'all 0.2s ease';
draggedCard.style.transform = 'scale(1.02)';
setTimeout(() => {
draggedCard.style.transform = '';
}, 200);
} else {
location.reload();
}
@@ -162,4 +184,22 @@ function handleDrop(e) {
}
}
}
/**
* Обновление счётчиков колонки (количество карточек и сумма)
*/
function updateColumnCounters(container) {
const columnId = container.dataset.columnId;
const cards = container.querySelectorAll('.kanban-card');
const count = cards.length;
// Находим badge в заголовке колонки
const column = container.closest('.kanban-column');
if (column) {
const badge = column.querySelector('.badge');
if (badge) {
badge.textContent = count;
}
}
}
</script>