Finish grid deletion

This commit is contained in:
2026-02-21 22:03:16 +01:00
parent d447220eae
commit 9a25591edf
3 changed files with 31 additions and 15 deletions

View File

@@ -72,7 +72,7 @@ class Commands(BaseCommands):
self._owner,
self._owner.select_document,
key="SelectNode")
def delete_grid(self):
return Command("DeleteGrid",
"Delete grid",
@@ -248,7 +248,7 @@ class DataGridsManager(SingleInstance, DatagridMetadataProvider):
except StopIteration:
# the selected node is not a document (it's a folder)
return None
def delete_grid(self, node_id):
"""
Delete a grid and all its associated resources.
@@ -266,37 +266,37 @@ class DataGridsManager(SingleInstance, DatagridMetadataProvider):
if document_id is None:
# Node is a folder, not a document - nothing to clean up
return None
res = []
try:
# Find the document
document = next(filter(lambda x: x.document_id == document_id, self._state.elements))
# Get the DataGrid instance
dg = DataGrid(self, _id=document.datagrid_id)
# Close the tab
self._tabs_manager.close_tab(document.tab_id)
close_tab_res = self._tabs_manager.close_tab(document.tab_id)
res.append(close_tab_res)
# Remove from registry
self._registry.remove(document.datagrid_id)
# Clean up DataGrid (delete DBEngine entries)
dg.delete()
# Remove from InstancesManager
InstancesManager.remove(self._session, document.datagrid_id)
# Remove DocumentDefinition from state
self._state.elements = [d for d in self._state.elements if d.document_id != document_id]
self._state.save()
except StopIteration:
# Document not found - already deleted or invalid state
pass
# Note: We do NOT call tree._delete_node() here because TreeView will do it
# automatically after this "before" bound command completes
return None
return res
def create_tab_content(self, tab_id):
"""