From 6f24a938d9be7edaca410e94ff548652f508be9f Mon Sep 17 00:00:00 2001 From: jeremystretch Date: Thu, 16 Sep 2021 11:08:05 -0400 Subject: [PATCH] Fixes #7273: Disable automatic sorting of select options fetched via API --- netbox/dcim/forms.py | 4 +-- netbox/project-static/dist/netbox.js | Bin 322940 -> 322742 bytes netbox/project-static/dist/netbox.js.map | Bin 311224 -> 311063 bytes .../src/select/api/apiSelect.ts | 24 +----------------- 4 files changed, 2 insertions(+), 26 deletions(-) diff --git a/netbox/dcim/forms.py b/netbox/dcim/forms.py index c1f8eccf8..61e07c0bb 100644 --- a/netbox/dcim/forms.py +++ b/netbox/dcim/forms.py @@ -2202,9 +2202,7 @@ class DeviceForm(BootstrapMixin, TenancyForm, CustomFieldModelForm): api_url='/api/dcim/racks/{{rack}}/elevation/', attrs={ 'disabled-indicator': 'device', - 'data-query-param-face': "[\"$face\"]", - # The UI will not sort this element's options. - 'pre-sorted': '' + 'data-query-param-face': "[\"$face\"]" } ) ) diff --git a/netbox/project-static/dist/netbox.js b/netbox/project-static/dist/netbox.js index 33d004108f7a2d8bbc864171bef2575120e8ae90..0b93ac20f577abe745b0007fbc1c7c9e549acf64 100644 GIT binary patch delta 40 wcmex!OL*H&;f5B*7N!>FEiCL+)8(pILbtD}VtK;0{ZS)J9_RLwZWfLt09ry1;{X5v delta 230 zcmdmXQ~1v<;f5B*7N!>FEiCL+yah$6!TCicsVPc2iiXqwRFEiBII!bToNPCAi}j*&X9j*gX1I?j$|)5FqP4k~(AIq6h7 zIXY%K>v%ePXF2Pb06F;}j=!O^j=Q7Bbk__P)$J29SZY}qeW&x~vV<}fIB(yX%c9E8 qQs$!LzWq-L%RC;gj0&eJXB}V1%!=(x8d<#AnX)Xmf9zm6ZUz8k5G_{# delta 301 zcmbRKPiV(~p@tU57N!>FEiBII!r7ihPCAi}j*&X9j*gX1I?j%k)5FqP4(j<=IqBp& zIXV_P>3BMN0~J*QIhoENPL{Kd36PTy;)EMI>$p1xOt;8jQB?&R;jNSC=$NRJ4wTP! z((!e4E^!8uK;cl39iEQvY1?BmSn6091E=54VF?Y>chd0&NryW+2LTNNY6Th+4iR&9 zbaV!B-GTa?feL|4SBOlqqhmT&z9&%Lv&3b)Q7(%ryIhV7#BQ+R$gXhB1M1!$UBWVt ehpVL0sS4!A(#q}3jV#{mOl8{J13Flan*jhf5LTi9 diff --git a/netbox/project-static/src/select/api/apiSelect.ts b/netbox/project-static/src/select/api/apiSelect.ts index 6d83daaac..032fc83fa 100644 --- a/netbox/project-static/src/select/api/apiSelect.ts +++ b/netbox/project-static/src/select/api/apiSelect.ts @@ -149,13 +149,6 @@ export class APISelect { */ private more: Nullable = null; - /** - * This element's options come from the server pre-sorted and should not be sorted client-side. - * Determined by the existence of the `pre-sorted` attribute on the base `` element, - * the options will *not* be sorted. + * Apply new options to both the SlimSelect instance and this manager's state. */ private set options(optionsIn: Option[]) { let newOptions = optionsIn; @@ -304,12 +291,6 @@ export class APISelect { if (this.nullOption !== null) { newOptions = [this.nullOption, ...newOptions]; } - // Sort options unless this element is pre-sorted. - if (!this.preSorted) { - newOptions = newOptions.sort((a, b) => - a.text.toLowerCase() > b.text.toLowerCase() ? 1 : -1, - ); - } // Deduplicate options each time they're set. const deduplicated = uniqueByProperty(newOptions, 'value'); // Determine if the new options have a placeholder. @@ -471,9 +452,6 @@ export class APISelect { if (typeof result._depth === 'number' && result._depth > 0) { // If the object has a `_depth` property, indent its display text. - if (!this.preSorted) { - this.preSorted = true; - } text = `${'─'.repeat(result._depth)} ${text}`; } const data = {} as Record;