Complex form

This commit is contained in:
Eden Kirin
2024-04-06 22:04:57 +02:00
parent ad14f2fe12
commit 5e1989a60f
9 changed files with 211 additions and 107 deletions

View File

@ -0,0 +1,67 @@
from dataclasses import dataclass
@dataclass
class CheckboxState:
checked: bool = False
visible: bool = True
enabled: bool = True
@dataclass
class SelectState:
value: str = None
visible: bool = True
enabled: bool = True
@dataclass
class RouteModuleState:
enabled: CheckboxState
smart_routing: CheckboxState
predictive_pickup: CheckboxState
automatic_planning: CheckboxState
geo_routing: CheckboxState
packing_model: SelectState
prekitting_to_box: CheckboxState
prekitting_to_pallet: CheckboxState
real_time_stock: CheckboxState
warehouse: CheckboxState
end_warehouse_tracking: CheckboxState
custom_forms_in_routing: CheckboxState
@staticmethod
def from_form(values: dict[str, str]) -> "RouteModuleState":
return RouteModuleState(
enabled=CheckboxState(checked=values.get("route_module") == "on"),
smart_routing=CheckboxState(checked=values.get("smart_routing") == "on"),
predictive_pickup=CheckboxState(
checked=values.get("predictive_pickup") == "on"
),
automatic_planning=CheckboxState(
checked=values.get("automatic_planning") == "on"
),
geo_routing=CheckboxState(checked=values.get("geo_routing") == "on"),
packing_model=SelectState(value=values.get("packing_model")),
prekitting_to_box=CheckboxState(
checked=values.get("prekitting_to_box") == "on"
),
prekitting_to_pallet=CheckboxState(
checked=values.get("prekitting_to_pallet") == "on"
),
real_time_stock=CheckboxState(
checked=values.get("real_time_stock") == "on"
),
warehouse=CheckboxState(checked=values.get("warehouse") == "on"),
end_warehouse_tracking=CheckboxState(
checked=values.get("end_warehouse_tracking") == "on"
),
custom_forms_in_routing=CheckboxState(
checked=values.get("custom_forms_in_routing") == "on"
),
)
@dataclass
class FormState:
route_module: RouteModuleState