Преглед на файлове

Fixes #16721: Fix errant API request after deselecting a rack in device edit form

Jeremy Stretch преди 1 година
родител
ревизия
e02796a64e
променени са 3 файла, в които са добавени 12 реда и са изтрити 4 реда
  1. 0 0
      netbox/project-static/dist/netbox.js
  2. 0 0
      netbox/project-static/dist/netbox.js.map
  3. 12 4
      netbox/project-static/src/select/classes/dynamicTomSelect.ts

Файловите разлики са ограничени, защото са твърде много
+ 0 - 0
netbox/project-static/dist/netbox.js


Файловите разлики са ограничени, защото са твърде много
+ 0 - 0
netbox/project-static/dist/netbox.js.map


+ 12 - 4
netbox/project-static/src/select/classes/dynamicTomSelect.ts

@@ -74,20 +74,25 @@ export class DynamicTomSelect extends TomSelect {
 
   load(value: string) {
     const self = this;
-    const url = self.getRequestUrl(value);
 
     // Automatically clear any cached options. (Only options included
     // in the API response should be present.)
     self.clearOptions();
 
-    addClasses(self.wrapper, self.settings.loadingClass);
-    self.loading++;
-
     // Populate the null option (if any) if not searching
     if (self.nullOption && !value) {
       self.addOption(self.nullOption);
     }
 
+    // Get the API request URL. If none is provided, abort as no request can be made.
+    const url = self.getRequestUrl(value);
+    if (!url) {
+      return;
+    }
+
+    addClasses(self.wrapper, self.settings.loadingClass);
+    self.loading++;
+
     // Make the API request
     fetch(url)
       .then(response => response.json())
@@ -129,6 +134,9 @@ export class DynamicTomSelect extends TomSelect {
       for (const result of this.api_url.matchAll(new RegExp(`({{${key}}})`, 'g'))) {
         if (value) {
           url = replaceAll(url, result[1], value.toString());
+        } else {
+          // No value is available to replace the token; abort.
+          return '';
         }
       }
     }

Някои файлове не бяха показани, защото твърде много файлове са промени