WIP: Catering
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
from typing import Literal
|
||||
|
||||
from rio import Component, Rectangle, Column, Spacer, Text, Row, TextInput, FlowContainer
|
||||
from rio.event import on_populate
|
||||
|
||||
from elm.components import ElmButton, CateringItemBox
|
||||
from elm.types.CateringTypes import CateringMenuItem, CateringMenuItemCategory
|
||||
|
||||
ITEM_CATEGORY_BY_DISPLAY_CATEGORY: dict[Literal["Frühstück", "Hauptspeisen", "Snacks & Dessert", "Softdrinks", "Alkohol"], list[CateringMenuItemCategory]] = {
|
||||
"Frühstück": [CateringMenuItemCategory.BREAKFAST],
|
||||
"Hauptspeisen": [CateringMenuItemCategory.MAIN_COURSE],
|
||||
"Snacks & Dessert": [CateringMenuItemCategory.SNACK, CateringMenuItemCategory.DESSERT],
|
||||
"Softdrinks": [CateringMenuItemCategory.BEVERAGE_NON_ALCOHOLIC],
|
||||
"Alkohol": [CateringMenuItemCategory.BEVERAGE_ALCOHOLIC, CateringMenuItemCategory.BEVERAGE_COCKTAIL, CateringMenuItemCategory.BEVERAGE_SHOT]
|
||||
}
|
||||
|
||||
|
||||
class CateringCategoryDisplay(Component):
|
||||
active_category: Literal["Frühstück", "Hauptspeisen", "Snacks & Dessert", "Softdrinks", "Alkohol"]
|
||||
catering_menu_items: list[CateringMenuItem] = []
|
||||
|
||||
@on_populate
|
||||
async def on_populate(self) -> None:
|
||||
self.catering_menu_items = await CateringMenuItem.find(
|
||||
{
|
||||
"category": {
|
||||
"$in": ITEM_CATEGORY_BY_DISPLAY_CATEGORY[self.active_category]
|
||||
}
|
||||
}
|
||||
).to_list()
|
||||
def build(self) -> Component:
|
||||
if len(self.catering_menu_items) <= 0:
|
||||
return Spacer()
|
||||
|
||||
return Rectangle(
|
||||
content=Column(
|
||||
Rectangle(
|
||||
content=Rectangle(
|
||||
content=Text(self.active_category, margin=0.5, selectable=False, overflow="wrap"),
|
||||
fill=self.session.theme.header_box_background_color,
|
||||
margin=0.4
|
||||
),
|
||||
stroke_width=0.1,
|
||||
stroke_color=self.session.theme.box_border_color,
|
||||
),
|
||||
# Items here
|
||||
Column(*[CateringItemBox(i, margin=0.5, grow_y=True) for i in self.catering_menu_items]),
|
||||
Spacer()
|
||||
),
|
||||
fill=self.session.theme.box_color,
|
||||
stroke_width=0.1,
|
||||
stroke_color=self.session.theme.box_border_color
|
||||
)
|
||||
Reference in New Issue
Block a user