Sith/counter/widgets/select.py

36 lines
1.0 KiB
Python
Raw Normal View History

2024-10-20 18:55:05 +00:00
from django.forms import Select, SelectMultiple
from core.views.widgets.select import AutoCompleteSelectMixin
from counter.models import Counter, Product
from counter.schemas import ProductSchema, SimplifiedCounterSchema
class CounterAutoCompleteSelectMixin(AutoCompleteSelectMixin):
js = [
"webpack/counter/components/ajax-select-index.ts",
]
class AutoCompleteSelectCounter(CounterAutoCompleteSelectMixin, Select):
component_name = "counter-ajax-select"
model = Counter
schema = SimplifiedCounterSchema
class AutoCompleteSelectMultipleCounter(CounterAutoCompleteSelectMixin, SelectMultiple):
component_name = "counter-ajax-select"
model = Counter
schema = SimplifiedCounterSchema
class AutoCompleteSelectProduct(CounterAutoCompleteSelectMixin, Select):
component_name = "product-ajax-select"
model = Product
schema = ProductSchema
class AutoCompleteSelectMultipleProduct(CounterAutoCompleteSelectMixin, SelectMultiple):
component_name = "product-ajax-select"
model = Product
schema = ProductSchema