add seating plan v2 (missing booking)

This commit is contained in:
David Rodenkirchen
2024-09-05 01:07:51 +02:00
parent acf458d629
commit c7c7cc7964
5 changed files with 136 additions and 50 deletions
+35 -4
View File
@@ -1,21 +1,52 @@
from rio import Text, Column, TextStyle, Component, event
from typing import Optional
from src.ez_lan_manager import ConfigurationService
from from_root import from_root
from rio import Text, Column, TextStyle, Component, event, PressEvent, ProgressCircle, Row, Image, Button, Spacer
from src.ez_lan_manager import ConfigurationService, SeatingService, TicketingService
from src.ez_lan_manager.components.MainViewContentBox import MainViewContentBox
from src.ez_lan_manager.components.SeatingPlan import SeatingPlan
from src.ez_lan_manager.components.SeatingPlanInfoBox import SeatingPlanInfoBox
from src.ez_lan_manager.pages import BasePage
from src.ez_lan_manager.types.Seat import Seat
class SeatingPlanPage(Component):
seating_info: Optional[list[Seat]] = None
current_seat_id: Optional[str] = None
current_seat_occupant: Optional[str] = None
current_seat_price: int = 0
current_seat_is_blocked: bool = False
@event.on_populate
async def on_populate(self) -> None:
await self.session.set_title(f"{self.session[ConfigurationService].get_lan_info().name} - Sitzplan")
self.seating_info = await self.session[SeatingService].get_seating()
async def on_seat_clicked(self, seat_id: str, _: PressEvent) -> None:
seat = next(filter(lambda s: s.seat_id == seat_id, self.seating_info), None)
if not seat:
return
self.current_seat_is_blocked = seat.is_blocked
self.current_seat_id = seat.seat_id
ticket_info = self.session[TicketingService].get_ticket_info_by_category(seat.category)
price = 0 if not ticket_info else ticket_info.price
self.current_seat_price = price
if seat.user:
self.current_seat_occupant = seat.user.user_name
else:
self.current_seat_occupant = None
def build(self) -> Component:
return BasePage(
content=Column(
MainViewContentBox(Text("Sitzplatz Infobox", margin=1, style=TextStyle(fill=self.session.theme.neutral_color))),
MainViewContentBox(
SeatingPlan()
SeatingPlan(seat_clicked_cb=self.on_seat_clicked, seating_info=self.seating_info) if self.seating_info else
Column(ProgressCircle(color=self.session.theme.secondary_color, margin=3), Text("Sitzplan wird geladen", style=TextStyle(fill=self.session.theme.neutral_color), align_x=0.5, margin=1))
),
MainViewContentBox(
SeatingPlanInfoBox(seat_id=self.current_seat_id, seat_occupant=self.current_seat_occupant, seat_price=self.current_seat_price,
is_blocked=self.current_seat_is_blocked)
),
align_y=0
),