Skip to content

Commit c88bba3

Browse files
committed
clients view added
1 parent 382aaee commit c88bba3

File tree

2 files changed

+57
-1
lines changed

2 files changed

+57
-1
lines changed

app/Tuttle.py

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,29 @@ def update_content(self):
151151
self.update()
152152

153153

154+
class ClientsPage(AppPage):
155+
def __init__(
156+
self,
157+
app: App,
158+
):
159+
super().__init__(app)
160+
161+
def update(self):
162+
super().update()
163+
164+
def update_content(self):
165+
super().update_content()
166+
self.main_column.controls.clear()
167+
168+
clients = self.app.con.query(Client)
169+
170+
for client in clients:
171+
self.main_column.controls.append(
172+
views.make_client_view(client),
173+
)
174+
self.update()
175+
176+
154177
class ProjectsPage(AppPage):
155178
def __init__(
156179
self,
@@ -381,7 +404,7 @@ def main(page: Page):
381404
icon=icons.HANDSHAKE,
382405
label="Clients",
383406
),
384-
AppPage(app),
407+
ClientsPage(app),
385408
),
386409
(
387410
NavigationRailDestination(

app/views.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
from tuttle.model import (
2020
Contact,
21+
Client,
2122
Contract,
2223
Project,
2324
)
@@ -284,6 +285,38 @@ def make_project_view(project: Project):
284285
)
285286

286287

288+
def make_client_view(client: Client):
289+
return Card(
290+
content=Container(
291+
content=Column(
292+
[
293+
ListTile(
294+
leading=Icon(icons.HANDSHAKE),
295+
title=Text(client.name),
296+
# subtitle=Text(client.company),
297+
trailing=PopupMenuButton(
298+
icon=icons.MORE_VERT,
299+
items=[
300+
PopupMenuItem(
301+
icon=icons.EDIT,
302+
text="Edit",
303+
),
304+
PopupMenuItem(
305+
icon=icons.DELETE,
306+
text="Delete",
307+
),
308+
],
309+
),
310+
),
311+
Column([]),
312+
]
313+
),
314+
# width=400,
315+
padding=10,
316+
)
317+
)
318+
319+
287320
def make_card(content):
288321
"""Make a card with the given content."""
289322
return Card(

0 commit comments

Comments
 (0)