Sith/counter/widgets/select.py

54 lines
1.5 KiB
Python
Raw Permalink Normal View History

from pydantic import TypeAdapter
from core.views.widgets.select import AutoCompleteSelect, AutoCompleteSelectMultiple
from counter.models import Counter, Product, ProductType
from counter.schemas import (
ProductTypeSchema,
SimpleProductSchema,
SimplifiedCounterSchema,
)
2024-10-20 18:55:05 +00:00
_js = ["bundled/counter/components/ajax-select-index.ts"]
2024-10-20 18:55:05 +00:00
class AutoCompleteSelectCounter(AutoCompleteSelect):
2024-10-20 18:55:05 +00:00
component_name = "counter-ajax-select"
model = Counter
adapter = TypeAdapter(list[SimplifiedCounterSchema])
js = _js
2024-10-20 18:55:05 +00:00
class AutoCompleteSelectMultipleCounter(AutoCompleteSelectMultiple):
2024-10-20 18:55:05 +00:00
component_name = "counter-ajax-select"
model = Counter
adapter = TypeAdapter(list[SimplifiedCounterSchema])
js = _js
2024-10-20 18:55:05 +00:00
class AutoCompleteSelectProduct(AutoCompleteSelect):
2024-10-20 18:55:05 +00:00
component_name = "product-ajax-select"
model = Product
adapter = TypeAdapter(list[SimpleProductSchema])
js = _js
2024-10-20 18:55:05 +00:00
class AutoCompleteSelectMultipleProduct(AutoCompleteSelectMultiple):
2024-10-20 18:55:05 +00:00
component_name = "product-ajax-select"
model = Product
adapter = TypeAdapter(list[SimpleProductSchema])
js = _js
class AutoCompleteSelectProductType(AutoCompleteSelect):
component_name = "product-type-ajax-select"
model = ProductType
adapter = TypeAdapter(list[ProductTypeSchema])
js = _js
class AutoCompleteSelectMultipleProductType(AutoCompleteSelectMultiple):
component_name = "product-type-ajax-select"
model = ProductType
adapter = TypeAdapter(list[ProductTypeSchema])
js = _js