From 5eee3bbf7083fc9d76e3e8fdd583fcefe8f74b02 Mon Sep 17 00:00:00 2001 From: Michael Chus Date: Fri, 23 Jan 2026 21:47:49 +0300 Subject: [PATCH] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=BE=20=D0=BB=D0=BE=D0=B6=D0=BD=D0=BE=D0=B5=20?= =?UTF-8?q?=D1=81=D1=80=D0=B0=D0=B1=D0=B0=D1=82=D1=8B=D0=B2=D0=B0=D0=BD?= =?UTF-8?q?=D0=B8=D0=B5=20=D1=81=D0=BE=D1=85=D1=80=D0=B0=D0=BD=D0=B5=D0=BD?= =?UTF-8?q?=D0=B8=D1=8F=20=D0=BF=D1=80=D0=B8=20=D0=B2=D1=8B=D0=B1=D0=BE?= =?UTF-8?q?=D1=80=D0=B5=20=D1=82=D0=BE=D0=B3=D0=BE=20=D0=B6=D0=B5=20=D0=B7?= =?UTF-8?q?=D0=BD=D0=B0=D1=87=D0=B5=D0=BD=D0=B8=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Добавлена проверка изменения значения в cellEdited (oldValue vs newValue) - Добавлен обработчик cellEditCancelled для сброса подсветки при отмене - Устранена отправка запросов в БД без реальных изменений Fixes #4 Co-Authored-By: Claude Opus 4.5 --- public/app.js | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/public/app.js b/public/app.js index 6ddc009..cc4491c 100644 --- a/public/app.js +++ b/public/app.js @@ -895,24 +895,39 @@ async function selectTable(schema, tableName) { cell.getRow().getElement().style.backgroundColor = '#fff9e6'; }); + table.on("cellEditCancelled", function(cell) { + console.log('❌ Редактирование отменено:', cell.getField()); + cell.getRow().getElement().style.backgroundColor = ''; + }); + table.on("cellEdited", function(cell) { - console.log('✏️ ИЗМЕНЕНО:', cell.getField(), '→', cell.getValue()); - + const oldValue = cell.getOldValue(); + const newValue = cell.getValue(); + + // Проверяем, действительно ли значение изменилось + if (oldValue === newValue || (oldValue == null && newValue === '') || (oldValue === '' && newValue == null)) { + console.log('⏭️ Значение не изменилось:', cell.getField(), oldValue, '→', newValue); + cell.getRow().getElement().style.backgroundColor = ''; + return; + } + + console.log('✏️ ИЗМЕНЕНО:', cell.getField(), oldValue, '→', newValue); + const row = cell.getRow(); const rowData = row.getData(); const rowPos = row.getPosition(); - + row.getElement().style.backgroundColor = '#fffae6'; - + if (dirtyRows.has(rowPos)) { clearTimeout(dirtyRows.get(rowPos).timeout); } - + const timeout = setTimeout(async () => { console.log('⏰ Автосохранение...'); await saveRow(rowPos, rowData, row); }, 2000); - + dirtyRows.set(rowPos, { data: rowData, element: row, timeout: timeout }); console.log('📝 Несохраненных:', dirtyRows.size); });