mirror of
https://github.com/netbox-community/netbox.git
synced 2026-01-15 16:22:18 -06:00
update to simpler sorting
This commit is contained in:
2
netbox/project-static/dist/netbox.js
vendored
2
netbox/project-static/dist/netbox.js
vendored
File diff suppressed because one or more lines are too long
6
netbox/project-static/dist/netbox.js.map
vendored
6
netbox/project-static/dist/netbox.js.map
vendored
File diff suppressed because one or more lines are too long
@@ -102,14 +102,10 @@ export class DynamicTomSelect extends TomSelect {
|
||||
.then(apiData => {
|
||||
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);
|
||||
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) {
|
||||
|
||||
@@ -49,6 +49,9 @@ export function initDynamicSelects(): void {
|
||||
labelField: LABEL_FIELD,
|
||||
maxOptions: MAX_OPTIONS,
|
||||
|
||||
// Preserve API response order
|
||||
sortField: '$order',
|
||||
|
||||
// Disable local search (search is performed on the backend)
|
||||
searchField: [],
|
||||
|
||||
|
||||
Reference in New Issue
Block a user