Adding search control
This commit is contained in:
@@ -7,6 +7,7 @@ from fasthtml.common import Div, Span
|
||||
from fasthtml.xtend import Script
|
||||
|
||||
from myfasthtml.controls.BaseCommands import BaseCommands
|
||||
from myfasthtml.controls.Search import Search
|
||||
from myfasthtml.controls.VisNetwork import VisNetwork
|
||||
from myfasthtml.controls.helpers import Ids, mk
|
||||
from myfasthtml.core.commands import Command
|
||||
@@ -96,6 +97,7 @@ class TabsManager(MultipleInstance):
|
||||
self._state = TabsManagerState(self)
|
||||
self.commands = Commands(self)
|
||||
self._boundaries = Boundaries()
|
||||
self._search = Search(self._session).set_items(self._get_tabs_labels())
|
||||
logger.debug(f"TabsManager created with id: {self._id}")
|
||||
logger.debug(f" tabs : {self._get_ordered_tabs()}")
|
||||
logger.debug(f" active tab : {self._state.active_tab}")
|
||||
@@ -191,6 +193,7 @@ class TabsManager(MultipleInstance):
|
||||
|
||||
# finally, update the state
|
||||
self._state.update(state)
|
||||
self._search.set_items(self._get_tabs_labels())
|
||||
|
||||
return tab_id
|
||||
|
||||
@@ -248,6 +251,7 @@ class TabsManager(MultipleInstance):
|
||||
|
||||
# Update state
|
||||
self._state.update(state)
|
||||
self._search.set_items(self._get_tabs_labels())
|
||||
|
||||
return self
|
||||
|
||||
@@ -365,9 +369,7 @@ class TabsManager(MultipleInstance):
|
||||
role="button",
|
||||
cls="btn btn-xs"),
|
||||
Div(
|
||||
Div("content"),
|
||||
Div("content"),
|
||||
Div("content"),
|
||||
self._search,
|
||||
tabindex="-1",
|
||||
cls="dropdown-content menu w-52 rounded-box bg-base-300 shadow-xl"
|
||||
),
|
||||
@@ -380,6 +382,9 @@ class TabsManager(MultipleInstance):
|
||||
hx_swap_oob=f"beforeend:#{self._id}-content-wrapper",
|
||||
)
|
||||
|
||||
def _get_tabs_labels(self):
|
||||
return [tab["label"] for tab in self._state.tabs.values()]
|
||||
|
||||
def update_boundaries(self):
|
||||
return Script(f"updateBoundaries('{self._id}');")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user