mirror of
				https://github.com/netbox-community/netbox.git
				synced 2024-05-10 07:54:54 +00:00 
			
		
		
		
	Fixes #3809: Filter platform by manufacturer when editing devices
This commit is contained in:
		@@ -1339,7 +1339,8 @@ class DeviceForm(BootstrapMixin, TenancyForm, CustomFieldForm):
 | 
			
		||||
        widget=APISelect(
 | 
			
		||||
            api_url="/api/dcim/manufacturers/",
 | 
			
		||||
            filter_for={
 | 
			
		||||
                'device_type': 'manufacturer_id'
 | 
			
		||||
                'device_type': 'manufacturer_id',
 | 
			
		||||
                'platform': 'manufacturer_id'
 | 
			
		||||
            }
 | 
			
		||||
        )
 | 
			
		||||
    )
 | 
			
		||||
@@ -1408,7 +1409,10 @@ class DeviceForm(BootstrapMixin, TenancyForm, CustomFieldForm):
 | 
			
		||||
            ),
 | 
			
		||||
            'status': StaticSelect2(),
 | 
			
		||||
            'platform': APISelect(
 | 
			
		||||
                api_url="/api/dcim/platforms/"
 | 
			
		||||
                api_url="/api/dcim/platforms/",
 | 
			
		||||
                additional_query_params={
 | 
			
		||||
                    "manufacturer_id": "null"
 | 
			
		||||
                }
 | 
			
		||||
            ),
 | 
			
		||||
            'primary_ip4': StaticSelect2(),
 | 
			
		||||
            'primary_ip6': StaticSelect2(),
 | 
			
		||||
 
 | 
			
		||||
@@ -184,7 +184,15 @@ $(document).ready(function() {
 | 
			
		||||
                $.each(element.attributes, function(index, attr){
 | 
			
		||||
                    if (attr.name.includes("data-additional-query-param-")){
 | 
			
		||||
                        var param_name = attr.name.split("data-additional-query-param-")[1];
 | 
			
		||||
                        parameters[param_name] = attr.value;
 | 
			
		||||
                        if (param_name in parameters) {
 | 
			
		||||
                            if (Array.isArray(parameters[param_name])) {
 | 
			
		||||
                                parameters[param_name].push(attr.value)
 | 
			
		||||
                            } else {
 | 
			
		||||
                                parameters[param_name] = [parameters[param_name], attr.value]
 | 
			
		||||
                            }
 | 
			
		||||
                        } else {
 | 
			
		||||
                            parameters[param_name] = attr.value;
 | 
			
		||||
                        }
 | 
			
		||||
                    }
 | 
			
		||||
                });
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user