Просмотр исходного кода

Drop support for conditional_query_params on APISelect

Jeremy Stretch 5 лет назад
Родитель
Сommit
2c64d45c69
2 измененных файлов с 0 добавлено и 33 удалено
  1. 0 14
      netbox/project-static/js/forms.js
  2. 0 19
      netbox/utilities/forms/widgets.py

+ 0 - 14
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-")){

+ 0 - 19
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 `<field_name>__<field_value>`.
-        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 `<param_name>=<param_value>`. 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 `<field_name>__<field_value>`.
-
-        :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):