mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-24 09:28:38 -06:00
Use display field for all API-backed select options
This commit is contained in:
parent
803f9b6913
commit
5e1156abe2
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.
@ -314,7 +314,7 @@ class APISelect {
|
|||||||
const options = [PLACEHOLDER] as Option[];
|
const options = [PLACEHOLDER] as Option[];
|
||||||
|
|
||||||
for (const result of results) {
|
for (const result of results) {
|
||||||
const text = this.getDisplayName(result);
|
const text = result.display;
|
||||||
const data = {} as Record<string, string>;
|
const data = {} as Record<string, string>;
|
||||||
const value = result.id.toString();
|
const value = result.id.toString();
|
||||||
let style, selected, disabled;
|
let style, selected, disabled;
|
||||||
@ -514,29 +514,6 @@ class APISelect {
|
|||||||
return placeholder;
|
return placeholder;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Find this element's display name.
|
|
||||||
*/
|
|
||||||
private getDisplayName(result: APIObjectBase): string {
|
|
||||||
let displayName = result.display;
|
|
||||||
|
|
||||||
const legacyDisplayProperty = this.base.getAttribute('display-field');
|
|
||||||
|
|
||||||
if (
|
|
||||||
typeof displayName === 'undefined' &&
|
|
||||||
legacyDisplayProperty !== null &&
|
|
||||||
legacyDisplayProperty in result
|
|
||||||
) {
|
|
||||||
displayName = result[legacyDisplayProperty] as string;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!displayName && typeof result.name === 'string') {
|
|
||||||
displayName = result.name;
|
|
||||||
}
|
|
||||||
|
|
||||||
return displayName;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get this element's disabled options by value. The `data-query-param-exclude` attribute will
|
* Get this element's disabled options by value. The `data-query-param-exclude` attribute will
|
||||||
* contain a stringified JSON array of option values.
|
* contain a stringified JSON array of option values.
|
||||||
|
Loading…
Reference in New Issue
Block a user