Added menu management
This commit is contained in:
@@ -7,10 +7,12 @@ from fasthtml.components import Div
|
||||
from fasthtml.xtend import Script
|
||||
|
||||
from myfasthtml.controls.BaseCommands import BaseCommands
|
||||
from myfasthtml.controls.Menu import Menu, MenuConf
|
||||
from myfasthtml.controls.Query import Query, QueryConf
|
||||
from myfasthtml.core.commands import Command
|
||||
from myfasthtml.core.dbmanager import DbObject
|
||||
from myfasthtml.core.instances import MultipleInstance
|
||||
from myfasthtml.icons.fluent import arrow_reset20_regular
|
||||
|
||||
logger = logging.getLogger("HierarchicalCanvasGraph")
|
||||
|
||||
@@ -91,10 +93,11 @@ class Commands(BaseCommands):
|
||||
This command can be used to fix stuck/frozen canvas by resetting zoom/pan state.
|
||||
"""
|
||||
return Command(
|
||||
"ResetTransform",
|
||||
"ResetView",
|
||||
"Reset view transform",
|
||||
self._owner,
|
||||
self._owner.handle_reset_view
|
||||
self._owner.handle_reset_view,
|
||||
icon=arrow_reset20_regular
|
||||
).htmx(target=f"#{self._id}")
|
||||
|
||||
|
||||
@@ -136,6 +139,9 @@ class HierarchicalCanvasGraph(MultipleInstance):
|
||||
self._query.bind_command("QueryChanged", self.commands.apply_filter())
|
||||
self._query.bind_command("CancelQuery", self.commands.apply_filter())
|
||||
|
||||
# Add Menu
|
||||
self._menu = Menu(self, conf=MenuConf(["ResetView"]))
|
||||
|
||||
logger.debug(f"HierarchicalCanvasGraph created with id={self._id}, "
|
||||
f"nodes={len(conf.nodes)}, edges={len(conf.edges)}")
|
||||
|
||||
@@ -341,8 +347,11 @@ class HierarchicalCanvasGraph(MultipleInstance):
|
||||
options_json = json.dumps(options, indent=2)
|
||||
|
||||
return Div(
|
||||
# Query filter bar
|
||||
self._query,
|
||||
Div(
|
||||
self._query,
|
||||
self._menu,
|
||||
cls="flex justify-between m-2"
|
||||
),
|
||||
|
||||
# Canvas element (sized by JS to fill container)
|
||||
Div(
|
||||
|
||||
Reference in New Issue
Block a user