mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-14 01:41:22 -06:00
Fixes #6326: Enable filtering assigned VLANs by group in interface edit form
This commit is contained in:
parent
0b0ab9277c
commit
8497965cf7
@ -13,6 +13,7 @@
|
||||
### Bug Fixes
|
||||
|
||||
* [#5968](https://github.com/netbox-community/netbox/issues/5968) - Model forms should save empty custom field values as null
|
||||
* [#6326](https://github.com/netbox-community/netbox/issues/6326) - Enable filtering assigned VLANs by group in interface edit form
|
||||
* [#6686](https://github.com/netbox-community/netbox/issues/6686) - Force assignment of null custom field values to objects
|
||||
* [#6776](https://github.com/netbox-community/netbox/issues/6776) - Fix erroneous webhook dispatch on failure to save objects
|
||||
* [#6974](https://github.com/netbox-community/netbox/issues/6974) - Show contextual label for IP address role
|
||||
|
@ -18,7 +18,7 @@ from extras.forms import (
|
||||
)
|
||||
from extras.models import Tag
|
||||
from ipam.constants import BGP_ASN_MAX, BGP_ASN_MIN
|
||||
from ipam.models import IPAddress, VLAN
|
||||
from ipam.models import IPAddress, VLAN, VLANGroup
|
||||
from tenancy.forms import TenancyFilterForm, TenancyForm
|
||||
from tenancy.models import Tenant
|
||||
from utilities.forms import (
|
||||
@ -3109,15 +3109,26 @@ class InterfaceForm(BootstrapMixin, InterfaceCommonForm, CustomFieldModelForm):
|
||||
'type': 'lag',
|
||||
}
|
||||
)
|
||||
vlan_group = DynamicModelChoiceField(
|
||||
queryset=VLANGroup.objects.all(),
|
||||
required=False,
|
||||
label='VLAN group'
|
||||
)
|
||||
untagged_vlan = DynamicModelChoiceField(
|
||||
queryset=VLAN.objects.all(),
|
||||
required=False,
|
||||
label='Untagged VLAN'
|
||||
label='Untagged VLAN',
|
||||
query_params={
|
||||
'group_id': '$vlan_group',
|
||||
}
|
||||
)
|
||||
tagged_vlans = DynamicModelMultipleChoiceField(
|
||||
queryset=VLAN.objects.all(),
|
||||
required=False,
|
||||
label='Tagged VLANs'
|
||||
label='Tagged VLANs',
|
||||
query_params={
|
||||
'group_id': '$vlan_group',
|
||||
}
|
||||
)
|
||||
tags = DynamicModelMultipleChoiceField(
|
||||
queryset=Tag.objects.all(),
|
||||
|
@ -337,22 +337,26 @@ $(document).ready(function() {
|
||||
$('select#id_untagged_vlan').trigger('change');
|
||||
$('select#id_tagged_vlans').val([]);
|
||||
$('select#id_tagged_vlans').trigger('change');
|
||||
$('select#id_vlan_group').parent().parent().hide();
|
||||
$('select#id_untagged_vlan').parent().parent().hide();
|
||||
$('select#id_tagged_vlans').parent().parent().hide();
|
||||
}
|
||||
else if ($(this).val() == 'access') {
|
||||
$('select#id_tagged_vlans').val([]);
|
||||
$('select#id_tagged_vlans').trigger('change');
|
||||
$('select#id_vlan_group').parent().parent().show();
|
||||
$('select#id_untagged_vlan').parent().parent().show();
|
||||
$('select#id_tagged_vlans').parent().parent().hide();
|
||||
}
|
||||
else if ($(this).val() == 'tagged') {
|
||||
$('select#id_vlan_group').parent().parent().show();
|
||||
$('select#id_untagged_vlan').parent().parent().show();
|
||||
$('select#id_tagged_vlans').parent().parent().show();
|
||||
}
|
||||
else if ($(this).val() == 'tagged-all') {
|
||||
$('select#id_tagged_vlans').val([]);
|
||||
$('select#id_tagged_vlans').trigger('change');
|
||||
$('select#id_vlan_group').parent().parent().show();
|
||||
$('select#id_untagged_vlan').parent().parent().show();
|
||||
$('select#id_tagged_vlans').parent().parent().hide();
|
||||
}
|
||||
|
@ -33,6 +33,7 @@
|
||||
<div class="panel-heading"><strong>802.1Q Switching</strong></div>
|
||||
<div class="panel-body">
|
||||
{% render_field form.mode %}
|
||||
{% render_field form.vlan_group %}
|
||||
{% render_field form.untagged_vlan %}
|
||||
{% render_field form.tagged_vlans %}
|
||||
</div>
|
||||
|
@ -28,6 +28,7 @@
|
||||
<div class="panel-heading"><strong>802.1Q Switching</strong></div>
|
||||
<div class="panel-body">
|
||||
{% render_field form.mode %}
|
||||
{% render_field form.vlan_group %}
|
||||
{% render_field form.untagged_vlan %}
|
||||
{% render_field form.tagged_vlans %}
|
||||
</div>
|
||||
|
@ -12,7 +12,7 @@ from extras.forms import (
|
||||
CustomFieldFilterForm,
|
||||
)
|
||||
from extras.models import Tag
|
||||
from ipam.models import IPAddress, VLAN
|
||||
from ipam.models import IPAddress, VLAN, VLANGroup
|
||||
from tenancy.forms import TenancyFilterForm, TenancyForm
|
||||
from tenancy.models import Tenant
|
||||
from utilities.forms import (
|
||||
@ -616,15 +616,26 @@ class VMInterfaceForm(BootstrapMixin, InterfaceCommonForm, CustomFieldModelForm)
|
||||
required=False,
|
||||
label='Parent interface'
|
||||
)
|
||||
vlan_group = DynamicModelChoiceField(
|
||||
queryset=VLANGroup.objects.all(),
|
||||
required=False,
|
||||
label='VLAN group'
|
||||
)
|
||||
untagged_vlan = DynamicModelChoiceField(
|
||||
queryset=VLAN.objects.all(),
|
||||
required=False,
|
||||
label='Untagged VLAN'
|
||||
label='Untagged VLAN',
|
||||
query_params={
|
||||
'group_id': '$vlan_group',
|
||||
}
|
||||
)
|
||||
tagged_vlans = DynamicModelMultipleChoiceField(
|
||||
queryset=VLAN.objects.all(),
|
||||
required=False,
|
||||
label='Tagged VLANs'
|
||||
label='Tagged VLANs',
|
||||
query_params={
|
||||
'group_id': '$vlan_group',
|
||||
}
|
||||
)
|
||||
tags = DynamicModelMultipleChoiceField(
|
||||
queryset=Tag.objects.all(),
|
||||
|
Loading…
Reference in New Issue
Block a user