mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
Clean up form select widgets
This commit is contained in:
@ -18,7 +18,6 @@ __all__ = (
|
||||
'DateTimePicker',
|
||||
'NumericArrayField',
|
||||
'SelectSpeedWidget',
|
||||
'SelectWithDisabled',
|
||||
'SelectWithPK',
|
||||
'SlugWidget',
|
||||
'SmallTextarea',
|
||||
@ -76,18 +75,12 @@ class BulkEditNullBooleanSelect(forms.NullBooleanSelect):
|
||||
self.attrs['class'] = 'netbox-static-select'
|
||||
|
||||
|
||||
class SelectWithDisabled(forms.Select):
|
||||
"""
|
||||
Modified the stock Select widget to accept choices using a dict() for a label. The dict for each option must include
|
||||
'label' (string) and 'disabled' (boolean).
|
||||
"""
|
||||
option_template_name = 'widgets/selectwithdisabled_option.html'
|
||||
|
||||
|
||||
class StaticSelect(SelectWithDisabled):
|
||||
class StaticSelect(forms.Select):
|
||||
"""
|
||||
A static <select/> form widget which is client-side rendered.
|
||||
"""
|
||||
option_template_name = 'widgets/select_option.html'
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
@ -99,8 +92,6 @@ class StaticSelectMultiple(StaticSelect, forms.SelectMultiple):
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
self.attrs['data-multiple'] = 1
|
||||
|
||||
|
||||
class SelectWithPK(StaticSelect):
|
||||
"""
|
||||
@ -133,13 +124,13 @@ class ClearableFileInput(forms.ClearableFileInput):
|
||||
template_name = 'widgets/clearable_file_input.html'
|
||||
|
||||
|
||||
class APISelect(SelectWithDisabled):
|
||||
class APISelect(forms.Select):
|
||||
"""
|
||||
A select widget populated via an API call
|
||||
|
||||
:param api_url: API endpoint URL. Required if not set automatically by the parent field.
|
||||
"""
|
||||
|
||||
option_template_name = 'widgets/select_option.html'
|
||||
dynamic_params: Dict[str, str]
|
||||
static_params: Dict[str, List[str]]
|
||||
|
||||
|
Reference in New Issue
Block a user