diff --git a/src/teilchensammler_cli/models.py b/src/teilchensammler_cli/models.py index 17bd9a5..1cc6633 100644 --- a/src/teilchensammler_cli/models.py +++ b/src/teilchensammler_cli/models.py @@ -55,3 +55,14 @@ async def make_teilchen_input(text: str) -> TeilchenCreate | None: tags=" ".join(natsorted(tags)), text=text, ) + + +async def load_initial_data() -> list[TeilchenDatum]: + return [ + (0, "Name0", "Description0", "9000", "#tag0 #tag00 #tag000"), + (1, "Name1", "Description1", "9001", "#tag1 #tag11 #tag111"), + (2, "Name2", "Description2", "9002", "#tag2 #tag22 #tag222"), + (3, "Name3", "Description3", "9003", "#tag3 #tag33 #tag333"), + (4, "Name4", "Description4", "9004", "#tag4 #tag44 #tag444"), + (5, "Name5", "Description5", "9005", "#tag5 #tag55 #tag555"), + ] diff --git a/src/teilchensammler_cli/tui.py b/src/teilchensammler_cli/tui.py index 4a5c50d..99f32e7 100644 --- a/src/teilchensammler_cli/tui.py +++ b/src/teilchensammler_cli/tui.py @@ -4,6 +4,11 @@ from textual.screen import Screen from textual.widget import Widget from textual.widgets import DataTable, Footer, Header, Static, Input, Button +from .models import load_initial_data + + +FAKE_DATA_HEADER = "pk Name Description Number Tags" + class SearchBar(Static): DEFAULT_CSS = """ @@ -36,34 +41,14 @@ class SearchBar(Static): ) -TeilchenHeader = tuple[ - Literal["pk"], - Literal["Name"], - Literal["Description"], - Literal["Number"], - Literal["Tags"], -] - - -FAKE_DATA: list[TeilchenHeader | TeilchenDatum] = [ - ("pk", "Name", "Description", "Number", "Tags"), - (0, "Name0", "Description0", "9000", "#tag0 #tag00 #tag000"), - (1, "Name1", "Description1", "9001", "#tag1 #tag11 #tag111"), - (2, "Name2", "Description2", "9002", "#tag2 #tag22 #tag222"), - (3, "Name3", "Description3", "9003", "#tag3 #tag33 #tag333"), - (4, "Name4", "Description4", "9004", "#tag4 #tag44 #tag444"), - (5, "Name5", "Description5", "9005", "#tag5 #tag55 #tag555"), -] - - class SearchResults(Widget): def compose(self) -> ComposeResult: yield DataTable(id="table-search-result", cursor_type="row", zebra_stripes=True) async def on_mount(self) -> None: table: DataTable[None] = self.query_one(DataTable[None]) - _ = table.add_columns(*FAKE_DATA[0]) # pyright: ignore[reportArgumentType] - _ = table.add_rows(FAKE_DATA[1:]) # pyright: ignore[reportArgumentType] + _ = table.add_columns(FAKE_DATA_HEADER) + _ = table.add_rows(await load_initial_data()) # ty:ignore[invalid-argument-type] class AddInventoryScreen(Screen[None]):