mirror of
https://github.com/ae-utbm/sith.git
synced 2025-07-10 03:49:24 +00:00
Create select widget based on tomselect on django backend
Replace make_ajax in elections by the new widget
This commit is contained in:
@ -36,9 +36,11 @@ from django.forms import (
|
||||
CheckboxSelectMultiple,
|
||||
DateInput,
|
||||
DateTimeInput,
|
||||
SelectMultiple,
|
||||
Textarea,
|
||||
TextInput,
|
||||
)
|
||||
from django.forms.widgets import Select
|
||||
from django.utils.translation import gettext
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from phonenumber_field.widgets import RegionalPhoneNumberWidget
|
||||
@ -72,12 +74,37 @@ class MarkdownInput(Textarea):
|
||||
context = super().get_context(name, value, attrs)
|
||||
|
||||
context["statics"] = {
|
||||
"js": staticfiles_storage.url("webpack/easymde-index.ts"),
|
||||
"css": staticfiles_storage.url("webpack/easymde-index.css"),
|
||||
"js": staticfiles_storage.url("webpack/core/components/easymde-index.ts"),
|
||||
"css": staticfiles_storage.url("webpack/core/components/easymde-index.css"),
|
||||
}
|
||||
return context
|
||||
|
||||
|
||||
class AutoCompleteSelectMixin:
|
||||
template_name = "core/widgets/autocomplete_select.jinja"
|
||||
|
||||
def get_context(self, name, value, attrs):
|
||||
context = super().get_context(name, value, attrs)
|
||||
context["statics"] = {
|
||||
"js": staticfiles_storage.url(
|
||||
"webpack/core/components/ajax-select-index.ts"
|
||||
),
|
||||
"csss": [
|
||||
staticfiles_storage.url(
|
||||
"webpack/core/components/ajax-select-index.css"
|
||||
),
|
||||
staticfiles_storage.url("core/components/ajax-select.scss"),
|
||||
],
|
||||
}
|
||||
return context
|
||||
|
||||
|
||||
class AutoCompleteSelect(AutoCompleteSelectMixin, Select): ...
|
||||
|
||||
|
||||
class AutoCompleteSelectMultiple(AutoCompleteSelectMixin, SelectMultiple): ...
|
||||
|
||||
|
||||
class NFCTextInput(TextInput):
|
||||
template_name = "core/widgets/nfc.jinja"
|
||||
|
||||
|
Reference in New Issue
Block a user