Răsfoiți Sursa

handle selection resets

checktheroads 5 ani în urmă
părinte
comite
a1ac1876ad
1 a modificat fișierele cu 5 adăugiri și 0 ștergeri
  1. 5 0
      netbox/project-static/src/select/api.ts

+ 5 - 0
netbox/project-static/src/select/api.ts

@@ -181,6 +181,9 @@ export function initApiSelect() {
     const groupBy = [] as HTMLSelectElement[];
 
     if (isCustomSelect(select)) {
+      // Store the original URL, so it can be referred back to as filter-by elements change.
+      const originalUrl = JSON.parse(JSON.stringify(select.dataset.url)) as string;
+      // Unpack the original URL with the intent of reassigning it as context updates.
       let { url } = select.dataset;
 
       const placeholder = getPlaceholder(select);
@@ -297,6 +300,8 @@ export function initApiSelect() {
           query[name] = target.value;
           // Create a URL with all relevant query parameters.
           url = queryString.stringifyUrl({ url, query });
+        } else {
+          url = originalUrl;
         }
 
         // Disable the element while data is loading.