mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-22 12:06:53 -06:00
Form widgets & style cleanup
This commit is contained in:
parent
ea961ba8f2
commit
662cafe416
@ -7,8 +7,8 @@ from extras.models import *
|
|||||||
from extras.utils import FeatureQuery
|
from extras.utils import FeatureQuery
|
||||||
from tenancy.models import Tenant, TenantGroup
|
from tenancy.models import Tenant, TenantGroup
|
||||||
from utilities.forms import (
|
from utilities.forms import (
|
||||||
add_blank_choice, BootstrapMixin, CommentField, ContentTypeChoiceField,
|
add_blank_choice, BootstrapMixin, CommentField, ContentTypeChoiceField, ContentTypeMultipleChoiceField,
|
||||||
ContentTypeMultipleChoiceField, DynamicModelMultipleChoiceField, JSONField, SlugField, StaticSelect,
|
DynamicModelMultipleChoiceField, JSONField, SlugField, StaticSelect,
|
||||||
)
|
)
|
||||||
from virtualization.models import Cluster, ClusterGroup
|
from virtualization.models import Cluster, ClusterGroup
|
||||||
|
|
||||||
@ -41,6 +41,10 @@ class CustomFieldForm(BootstrapMixin, forms.ModelForm):
|
|||||||
('Values', ('default', 'choices')),
|
('Values', ('default', 'choices')),
|
||||||
('Validation', ('validation_minimum', 'validation_maximum', 'validation_regex')),
|
('Validation', ('validation_minimum', 'validation_maximum', 'validation_regex')),
|
||||||
)
|
)
|
||||||
|
widgets = {
|
||||||
|
'type': StaticSelect(),
|
||||||
|
'filter_logic': StaticSelect(),
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
class CustomLinkForm(BootstrapMixin, forms.ModelForm):
|
class CustomLinkForm(BootstrapMixin, forms.ModelForm):
|
||||||
@ -57,6 +61,7 @@ class CustomLinkForm(BootstrapMixin, forms.ModelForm):
|
|||||||
('Templates', ('link_text', 'link_url')),
|
('Templates', ('link_text', 'link_url')),
|
||||||
)
|
)
|
||||||
widgets = {
|
widgets = {
|
||||||
|
'button_class': StaticSelect(),
|
||||||
'link_text': forms.Textarea(attrs={'class': 'font-monospace'}),
|
'link_text': forms.Textarea(attrs={'class': 'font-monospace'}),
|
||||||
'link_url': forms.Textarea(attrs={'class': 'font-monospace'}),
|
'link_url': forms.Textarea(attrs={'class': 'font-monospace'}),
|
||||||
}
|
}
|
||||||
@ -96,8 +101,7 @@ class WebhookForm(BootstrapMixin, forms.ModelForm):
|
|||||||
model = Webhook
|
model = Webhook
|
||||||
fields = '__all__'
|
fields = '__all__'
|
||||||
fieldsets = (
|
fieldsets = (
|
||||||
('Webhook', ('name', 'enabled')),
|
('Webhook', ('name', 'content_types', 'enabled')),
|
||||||
('Assigned Models', ('content_types',)),
|
|
||||||
('Events', ('type_create', 'type_update', 'type_delete')),
|
('Events', ('type_create', 'type_update', 'type_delete')),
|
||||||
('HTTP Request', (
|
('HTTP Request', (
|
||||||
'payload_url', 'http_method', 'http_content_type', 'additional_headers', 'body_template', 'secret',
|
'payload_url', 'http_method', 'http_content_type', 'additional_headers', 'body_template', 'secret',
|
||||||
@ -105,7 +109,13 @@ class WebhookForm(BootstrapMixin, forms.ModelForm):
|
|||||||
('Conditions', ('conditions',)),
|
('Conditions', ('conditions',)),
|
||||||
('SSL', ('ssl_verification', 'ca_file_path')),
|
('SSL', ('ssl_verification', 'ca_file_path')),
|
||||||
)
|
)
|
||||||
|
labels = {
|
||||||
|
'type_create': 'Creations',
|
||||||
|
'type_update': 'Updates',
|
||||||
|
'type_delete': 'Deletions',
|
||||||
|
}
|
||||||
widgets = {
|
widgets = {
|
||||||
|
'http_method': StaticSelect(),
|
||||||
'additional_headers': forms.Textarea(attrs={'class': 'font-monospace'}),
|
'additional_headers': forms.Textarea(attrs={'class': 'font-monospace'}),
|
||||||
'body_template': forms.Textarea(attrs={'class': 'font-monospace'}),
|
'body_template': forms.Textarea(attrs={'class': 'font-monospace'}),
|
||||||
}
|
}
|
||||||
|
@ -628,8 +628,7 @@ class FHRPGroupAssignmentForm(BootstrapMixin, forms.ModelForm):
|
|||||||
class VLANGroupForm(CustomFieldModelForm):
|
class VLANGroupForm(CustomFieldModelForm):
|
||||||
scope_type = ContentTypeChoiceField(
|
scope_type = ContentTypeChoiceField(
|
||||||
queryset=ContentType.objects.filter(model__in=VLANGROUP_SCOPE_TYPES),
|
queryset=ContentType.objects.filter(model__in=VLANGROUP_SCOPE_TYPES),
|
||||||
required=False,
|
required=False
|
||||||
widget=StaticSelect
|
|
||||||
)
|
)
|
||||||
region = DynamicModelChoiceField(
|
region = DynamicModelChoiceField(
|
||||||
queryset=Region.objects.all(),
|
queryset=Region.objects.all(),
|
||||||
|
BIN
netbox/project-static/dist/netbox-light.css
vendored
BIN
netbox/project-static/dist/netbox-light.css
vendored
Binary file not shown.
BIN
netbox/project-static/dist/netbox-print.css
vendored
BIN
netbox/project-static/dist/netbox-print.css
vendored
Binary file not shown.
@ -2,8 +2,6 @@
|
|||||||
|
|
||||||
@import './theme-base.scss';
|
@import './theme-base.scss';
|
||||||
|
|
||||||
$input-border-color: $gray-200;
|
|
||||||
|
|
||||||
$theme-colors: map-merge(
|
$theme-colors: map-merge(
|
||||||
$theme-colors,
|
$theme-colors,
|
||||||
(
|
(
|
||||||
|
@ -168,11 +168,11 @@ class ContentTypeChoiceMixin:
|
|||||||
|
|
||||||
|
|
||||||
class ContentTypeChoiceField(ContentTypeChoiceMixin, forms.ModelChoiceField):
|
class ContentTypeChoiceField(ContentTypeChoiceMixin, forms.ModelChoiceField):
|
||||||
pass
|
widget = widgets.StaticSelect
|
||||||
|
|
||||||
|
|
||||||
class ContentTypeMultipleChoiceField(ContentTypeChoiceMixin, forms.ModelMultipleChoiceField):
|
class ContentTypeMultipleChoiceField(ContentTypeChoiceMixin, forms.ModelMultipleChoiceField):
|
||||||
pass
|
widget = widgets.StaticSelectMultiple
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
|
@ -14,7 +14,6 @@ __all__ = (
|
|||||||
'BulkEditNullBooleanSelect',
|
'BulkEditNullBooleanSelect',
|
||||||
'ClearableFileInput',
|
'ClearableFileInput',
|
||||||
'ColorSelect',
|
'ColorSelect',
|
||||||
'ContentTypeSelect',
|
|
||||||
'DatePicker',
|
'DatePicker',
|
||||||
'DateTimePicker',
|
'DateTimePicker',
|
||||||
'NumericArrayField',
|
'NumericArrayField',
|
||||||
@ -110,15 +109,6 @@ class SelectWithPK(StaticSelect):
|
|||||||
option_template_name = 'widgets/select_option_with_pk.html'
|
option_template_name = 'widgets/select_option_with_pk.html'
|
||||||
|
|
||||||
|
|
||||||
class ContentTypeSelect(StaticSelect):
|
|
||||||
"""
|
|
||||||
Appends an `api-value` attribute equal to the slugified model name for each ContentType. For example:
|
|
||||||
<option value="37" api-value="console-server-port">console server port</option>
|
|
||||||
This attribute can be used to reference the relevant API endpoint for a particular ContentType.
|
|
||||||
"""
|
|
||||||
option_template_name = 'widgets/select_contenttype.html'
|
|
||||||
|
|
||||||
|
|
||||||
class SelectSpeedWidget(forms.NumberInput):
|
class SelectSpeedWidget(forms.NumberInput):
|
||||||
"""
|
"""
|
||||||
Speed field with dropdown selections for convenience.
|
Speed field with dropdown selections for convenience.
|
||||||
|
@ -1 +0,0 @@
|
|||||||
<option value="{{ widget.value }}"{% include "django/forms/widgets/attrs.html" %}{% if widget.value %} api-value="{{ widget.label|slugify }}"{% endif %}>{{ widget.label.label|default:widget.label|capfirst }}</option>
|
|
Loading…
Reference in New Issue
Block a user