Jelajahi Sumber

update to simpler sorting

Arthur 1 bulan lalu
induk
melakukan
20f52153a4

File diff ditekan karena terlalu besar
+ 0 - 0
netbox/project-static/dist/netbox.js


File diff ditekan karena terlalu besar
+ 0 - 0
netbox/project-static/dist/netbox.js.map


+ 2 - 6
netbox/project-static/src/select/classes/dynamicTomSelect.ts

@@ -102,14 +102,10 @@ export class DynamicTomSelect extends TomSelect {
       .then(apiData => {
       .then(apiData => {
         const results: Dict[] = apiData.results;
         const results: Dict[] = apiData.results;
 
 
-        // Add options and set $order to preserve API response order
-        results.forEach((result, index) => {
+        // Add options (TomSelect automatically preserves insertion order via $order)
+        results.forEach((result) => {
           const option = self.getOptionFromData(result);
           const option = self.getOptionFromData(result);
           self.addOption(option);
           self.addOption(option);
-          const key = option[self.settings.valueField as string] as string;
-          if (self.options[key]) {
-            (self.options[key] as any).$order = index;
-          }
         });
         });
 
 
         if (self.loading > 0) {
         if (self.loading > 0) {

+ 3 - 0
netbox/project-static/src/select/dynamic.ts

@@ -49,6 +49,9 @@ export function initDynamicSelects(): void {
       labelField: LABEL_FIELD,
       labelField: LABEL_FIELD,
       maxOptions: MAX_OPTIONS,
       maxOptions: MAX_OPTIONS,
 
 
+      // Preserve API response order
+      sortField: '$order',
+
       // Disable local search (search is performed on the backend)
       // Disable local search (search is performed on the backend)
       searchField: [],
       searchField: [],
 
 

Beberapa file tidak ditampilkan karena terlalu banyak file yang berubah dalam diff ini