Explorar el Código

Use 'brief=true' query parameter on API calls from API-backed select elements

checktheroads hace 4 años
padre
commit
dd58ef1de5

La diferencia del archivo ha sido suprimido porque es demasiado grande
+ 0 - 0
netbox/project-static/dist/netbox.js


La diferencia del archivo ha sido suprimido porque es demasiado grande
+ 0 - 0
netbox/project-static/dist/netbox.js.map


+ 2 - 2
netbox/project-static/src/global.d.ts

@@ -30,8 +30,8 @@ type APIError = {
 
 
 type APIObjectBase = {
 type APIObjectBase = {
   id: number;
   id: number;
-  display?: string;
-  name: string;
+  display: string;
+  name?: Nullable<string>;
   url: string;
   url: string;
   [k: string]: JSONAble;
   [k: string]: JSONAble;
 };
 };

+ 4 - 3
netbox/project-static/src/select/api.ts

@@ -15,7 +15,7 @@ import {
 
 
 import type { Option } from 'slim-select/dist/data';
 import type { Option } from 'slim-select/dist/data';
 
 
-type QueryFilter = Map<string, string | number>;
+type QueryFilter = Map<string, string | number | boolean>;
 
 
 // Various one-off patterns to replace in query param keys.
 // Various one-off patterns to replace in query param keys.
 const REPLACE_PATTERNS = [
 const REPLACE_PATTERNS = [
@@ -161,6 +161,7 @@ class APISelect {
       this.updatePathValues(filter);
       this.updatePathValues(filter);
     }
     }
 
 
+    this.queryParams.set('brief', true);
     this.queryParams.set('limit', 0);
     this.queryParams.set('limit', 0);
     this.updateQueryUrl();
     this.updateQueryUrl();
 
 
@@ -414,7 +415,7 @@ class APISelect {
   private updateQueryUrl(): void {
   private updateQueryUrl(): void {
     // Create new URL query parameters based on the current state of `queryParams` and create an
     // Create new URL query parameters based on the current state of `queryParams` and create an
     // updated API query URL.
     // updated API query URL.
-    const query = {} as Record<string, string | number>;
+    const query = {} as Dict<string | number | boolean>;
     for (const [key, value] of this.queryParams.entries()) {
     for (const [key, value] of this.queryParams.entries()) {
       query[key] = value;
       query[key] = value;
     }
     }
@@ -529,7 +530,7 @@ class APISelect {
       displayName = result[legacyDisplayProperty] as string;
       displayName = result[legacyDisplayProperty] as string;
     }
     }
 
 
-    if (!displayName) {
+    if (!displayName && typeof result.name === 'string') {
       displayName = result.name;
       displayName = result.name;
     }
     }
 
 

Algunos archivos no se mostraron porque demasiados archivos cambiaron en este cambio