Исправлено ложное срабатывание сохранения при выборе того же значения

- Добавлена проверка изменения значения в cellEdited (oldValue vs newValue)
- Добавлен обработчик cellEditCancelled для сброса подсветки при отмене
- Устранена отправка запросов в БД без реальных изменений

Fixes #4

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-01-23 21:47:49 +03:00
parent 9da765de77
commit 5eee3bbf70

View File

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