mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-25 01:48:38 -06:00
Fixes #16721: Fix errant API request after deselecting a rack in device edit form
This commit is contained in:
parent
9ab7960a66
commit
e02796a64e
BIN
netbox/project-static/dist/netbox.js
vendored
BIN
netbox/project-static/dist/netbox.js
vendored
Binary file not shown.
BIN
netbox/project-static/dist/netbox.js.map
vendored
BIN
netbox/project-static/dist/netbox.js.map
vendored
Binary file not shown.
@ -74,20 +74,25 @@ export class DynamicTomSelect extends TomSelect {
|
|||||||
|
|
||||||
load(value: string) {
|
load(value: string) {
|
||||||
const self = this;
|
const self = this;
|
||||||
const url = self.getRequestUrl(value);
|
|
||||||
|
|
||||||
// Automatically clear any cached options. (Only options included
|
// Automatically clear any cached options. (Only options included
|
||||||
// in the API response should be present.)
|
// in the API response should be present.)
|
||||||
self.clearOptions();
|
self.clearOptions();
|
||||||
|
|
||||||
addClasses(self.wrapper, self.settings.loadingClass);
|
|
||||||
self.loading++;
|
|
||||||
|
|
||||||
// Populate the null option (if any) if not searching
|
// Populate the null option (if any) if not searching
|
||||||
if (self.nullOption && !value) {
|
if (self.nullOption && !value) {
|
||||||
self.addOption(self.nullOption);
|
self.addOption(self.nullOption);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get the API request URL. If none is provided, abort as no request can be made.
|
||||||
|
const url = self.getRequestUrl(value);
|
||||||
|
if (!url) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
addClasses(self.wrapper, self.settings.loadingClass);
|
||||||
|
self.loading++;
|
||||||
|
|
||||||
// Make the API request
|
// Make the API request
|
||||||
fetch(url)
|
fetch(url)
|
||||||
.then(response => response.json())
|
.then(response => response.json())
|
||||||
@ -129,6 +134,9 @@ export class DynamicTomSelect extends TomSelect {
|
|||||||
for (const result of this.api_url.matchAll(new RegExp(`({{${key}}})`, 'g'))) {
|
for (const result of this.api_url.matchAll(new RegExp(`({{${key}}})`, 'g'))) {
|
||||||
if (value) {
|
if (value) {
|
||||||
url = replaceAll(url, result[1], value.toString());
|
url = replaceAll(url, result[1], value.toString());
|
||||||
|
} else {
|
||||||
|
// No value is available to replace the token; abort.
|
||||||
|
return '';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user