From 2c64d45c697455760b9b9c136e7a8b1791ecc140 Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Tue, 11 Aug 2020 16:23:36 -0400 Subject: [PATCH] Drop support for conditional_query_params on APISelect --- netbox/project-static/js/forms.js | 14 -------------- netbox/utilities/forms/widgets.py | 19 ------------------- 2 files changed, 33 deletions(-) diff --git a/netbox/project-static/js/forms.js b/netbox/project-static/js/forms.js index 26c8338c2..9fed76f90 100644 --- a/netbox/project-static/js/forms.js +++ b/netbox/project-static/js/forms.js @@ -178,20 +178,6 @@ $(document).ready(function() { } }); - // Conditional query params - $.each(element.attributes, function(index, attr){ - if (attr.name.includes("data-conditional-query-param-")){ - var conditional = attr.name.split("data-conditional-query-param-")[1].split("__"); - var field = $("#id_" + conditional[0]); - var field_value = conditional[1]; - - if ($('option:selected', field).attr('api-value') === field_value){ - var _val = attr.value.split("="); - parameters[_val[0]] = _val[1]; - } - } - }); - // Additional query params $.each(element.attributes, function(index, attr){ if (attr.name.includes("data-additional-query-param-")){ diff --git a/netbox/utilities/forms/widgets.py b/netbox/utilities/forms/widgets.py index 1c9d654f3..80ff12ac3 100644 --- a/netbox/utilities/forms/widgets.py +++ b/netbox/utilities/forms/widgets.py @@ -145,11 +145,6 @@ class APISelect(SelectWithDisabled): :param disabled_indicator: (Optional) Mark option as disabled if this field equates true. :param filter_for: (Optional) A dict of chained form fields for which this field is a filter. The key is the name of the filter-for field (child field) and the value is the name of the query param filter. - :param conditional_query_params: (Optional) A dict of URL query params to append to the URL if the - condition is met. The condition is the dict key and is specified in the form `__`. - If the provided field value is selected for the given field, the URL query param will be appended to - the rendered URL. The value is the in the from `=`. This is useful in cases where - a particular field value dictates an additional API filter. :param additional_query_params: Optional) A dict of query params to append to the API request. The key is the name of the query param and the value if the query param's value. :param null_option: If true, include the static null option in the selection list. @@ -161,7 +156,6 @@ class APISelect(SelectWithDisabled): value_field=None, disabled_indicator=None, filter_for=None, - conditional_query_params=None, additional_query_params=None, null_option=False, full=False, @@ -185,9 +179,6 @@ class APISelect(SelectWithDisabled): if filter_for: for key, value in filter_for.items(): self.add_filter_for(key, value) - if conditional_query_params: - for key, value in conditional_query_params.items(): - self.add_conditional_query_param(key, value) if additional_query_params: for key, value in additional_query_params.items(): self.add_additional_query_param(key, value) @@ -217,16 +208,6 @@ class APISelect(SelectWithDisabled): self.attrs[key] = json.dumps(values) - def add_conditional_query_param(self, condition, value): - """ - Add details for a URL query strings to append to the URL if the condition is met. - The condition is specified in the form `__`. - - :param condition: The condition for the query param - :param value: The value of the query param - """ - self.attrs['data-conditional-query-param-{}'.format(condition)] = value - class APISelectMultiple(APISelect, forms.SelectMultiple):