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

@@ -267,6 +267,7 @@ class DataGridsManager(SingleInstance, DatagridMetadataProvider):
# Node is a folder, not a document - nothing to clean up # Node is a folder, not a document - nothing to clean up
return None return None
res = []
try: try:
# Find the document # Find the document
document = next(filter(lambda x: x.document_id == document_id, self._state.elements)) document = next(filter(lambda x: x.document_id == document_id, self._state.elements))
@@ -275,7 +276,8 @@ class DataGridsManager(SingleInstance, DatagridMetadataProvider):
dg = DataGrid(self, _id=document.datagrid_id) dg = DataGrid(self, _id=document.datagrid_id)
# Close the tab # 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 # Remove from registry
self._registry.remove(document.datagrid_id) self._registry.remove(document.datagrid_id)
@@ -294,9 +296,7 @@ class DataGridsManager(SingleInstance, DatagridMetadataProvider):
# Document not found - already deleted or invalid state # Document not found - already deleted or invalid state
pass pass
# Note: We do NOT call tree._delete_node() here because TreeView will do it return res
# automatically after this "before" bound command completes
return None
def create_tab_content(self, tab_id): def create_tab_content(self, tab_id):
""" """

View File

@@ -23,6 +23,9 @@ class DbManager(SingleInstance):
def load(self, entry): def load(self, entry):
return self.db.load(self.get_tenant(), entry) return self.db.load(self.get_tenant(), entry)
def delete(self, entry):
self.db.delete(self.get_tenant(), self.get_user(), entry)
def exists_entry(self, entry): def exists_entry(self, entry):
return self.db.exists(self.get_tenant(), entry) return self.db.exists(self.get_tenant(), entry)
@@ -171,6 +174,9 @@ class DbObject:
def save(self): def save(self):
self._save_self() self._save_self()
def delete(self):
self._db_manager.delete(self._name)
def reload(self): def reload(self):
self._reload_self() self._reload_self()

View File

@@ -260,6 +260,16 @@ class InstancesManager:
logger.debug(f"Creating new component {component_id} of type {real_component_type}") logger.debug(f"Creating new component {component_id} of type {real_component_type}")
return cls(parent, _id=component_id) return cls(parent, _id=component_id)
@staticmethod
def remove(session, component_id: str):
session_id = InstancesManager.get_session_id(session)
key = (session_id, component_id)
if key not in InstancesManager.instances:
return False
del InstancesManager.instances[key]
return True
@staticmethod @staticmethod
def get_session_id(session): def get_session_id(session):
if isinstance(session, str): if isinstance(session, str):