fix(ui): separate permanent and recoverable deletion

main
AlexsandrSnytkin 17 hours ago
parent 512de06903
commit 637ae5ce87

@ -82,6 +82,7 @@ class UIServerTests(unittest.TestCase):
self.assertIn('focusConfigBlock', HTML)
self.assertIn('startConfigBlockDrag', HTML)
self.assertIn('configDragBlocked', HTML)
self.assertIn('removeConfigBlockForever', HTML)
self.assertIn('positionNewConfigBlock', HTML)
self.assertIn('finishConfigDrag', HTML)
self.assertIn('fpv-config-layout-v1', HTML)

@ -2081,10 +2081,11 @@ HTML = """<!doctype html>
if (block.dataset.custom === 'true' && !state && !deleted) {
const remove = document.createElement('button');
remove.type = 'button';
remove.textContent = 'удалить';
remove.textContent = 'удалить навсегда';
remove.title = 'Удалить блок без возможности восстановления';
remove.addEventListener('click', event => {
event.stopPropagation();
setConfigBlockState(block, 'deleted');
removeConfigBlockForever(block);
});
actions.appendChild(remove);
}
@ -2123,6 +2124,17 @@ HTML = """<!doctype html>
setText('configLayoutState', `${visible} блоков · ${hidden.length} скрыто · ${deleted.length} в корзине`);
if (configCanvas) applyStoredConfigLayout();
}
function removeConfigBlockForever(block) {
if (!block || block.dataset.custom !== 'true') return;
if (block.contains(document.activeElement)) document.activeElement.blur();
const key = block.dataset.section;
block.remove();
configBlocks = configBlocks.filter(item => item !== block);
if (key) delete configLayout[key];
saveConfigLayout();
renderConfigRestorePanel();
setText('configLayoutState', 'блок удалён навсегда');
}
function nextCustomConfigKey() {
let index = 1;
while (configBlocks.some(block => block.dataset.section === `custom-${index}`)) index += 1;

Loading…
Cancel
Save