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); });