From 9e52490b6c77e29e2ef748de2eea20486d3633c8 Mon Sep 17 00:00:00 2001 From: Ruslan Semak Date: Fri, 18 Apr 2025 18:24:07 +0300 Subject: [PATCH] feat: drag n drop lagged fix --- client/components/admin/admin-pages.vue | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/client/components/admin/admin-pages.vue b/client/components/admin/admin-pages.vue index 96f79d70..9f075c18 100644 --- a/client/components/admin/admin-pages.vue +++ b/client/components/admin/admin-pages.vue @@ -185,7 +185,7 @@ export default { // Используем новую мутацию для массового обновления await this.$apollo.mutate({ - mutation: updatePagesOrderMutation, + mutation: updatePagePriorityMutation, variables: { pages: pagesToUpdate } @@ -253,7 +253,14 @@ export default { // Находим новые индексы с учетом фильтрации и сортировки const draggedIndex = filteredSorted.findIndex(p => p.id === this.draggedItem.id) - const targetIndex = filteredSorted.findIndex(p => p.id === item.id) + let targetIndex = filteredSorted.findIndex(p => p.id === item.id) + + const direction = draggedIndex < targetIndex ? 'down' : 'up' + if (direction === 'down') { + targetIndex -= 1 + } + + console.log(`draggedIndex=${draggedIndex} targetIndex=${targetIndex} direction=${direction}`) if (draggedIndex === -1 || targetIndex === -1) return