mirror of
https://github.com/netbox-community/netbox.git
synced 2025-08-17 13:08:16 -06:00
Add support for annotating a numeric count on dropdown options
This commit is contained in:
parent
f155e3c3d5
commit
7da211e67a
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.
@ -35,9 +35,10 @@ export class DynamicTomSelect extends TomSelect {
|
|||||||
this.valueField = this.input.getAttribute('ts-value-field') || this.settings.valueField;
|
this.valueField = this.input.getAttribute('ts-value-field') || this.settings.valueField;
|
||||||
this.labelField = this.input.getAttribute('ts-label-field') || this.settings.labelField;
|
this.labelField = this.input.getAttribute('ts-label-field') || this.settings.labelField;
|
||||||
this.disabledField = this.input.getAttribute('ts-disabled-field') || this.settings.disabledField;
|
this.disabledField = this.input.getAttribute('ts-disabled-field') || this.settings.disabledField;
|
||||||
this.parentField = this.input.getAttribute('ts-parent-field') || null;
|
|
||||||
this.depthField = this.input.getAttribute('ts-depth-field') || '_depth';
|
|
||||||
this.descriptionField = this.input.getAttribute('ts-description-field') || 'description';
|
this.descriptionField = this.input.getAttribute('ts-description-field') || 'description';
|
||||||
|
this.depthField = this.input.getAttribute('ts-depth-field') || '_depth';
|
||||||
|
this.parentField = this.input.getAttribute('ts-parent-field') || null;
|
||||||
|
this.countField = this.input.getAttribute('ts-count-field') || null;
|
||||||
|
|
||||||
// Set the null option (if any)
|
// Set the null option (if any)
|
||||||
const nullOption = this.input.getAttribute('data-null-option');
|
const nullOption = this.input.getAttribute('data-null-option');
|
||||||
@ -156,6 +157,9 @@ export class DynamicTomSelect extends TomSelect {
|
|||||||
let parent: Dict = data[this.parentField] as Dict;
|
let parent: Dict = data[this.parentField] as Dict;
|
||||||
option['parent'] = parent[this.labelField];
|
option['parent'] = parent[this.labelField];
|
||||||
}
|
}
|
||||||
|
if (data[this.countField]) {
|
||||||
|
option['count'] = data[this.countField];
|
||||||
|
}
|
||||||
if (data[this.disabledField]) {
|
if (data[this.disabledField]) {
|
||||||
option['disabled'] = data[this.disabledField];
|
option['disabled'] = data[this.disabledField];
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,9 @@ function renderOption(data: TomOption, escape: typeof escape_html) {
|
|||||||
if (data['parent']) {
|
if (data['parent']) {
|
||||||
html = `${html} <span class="text-secondary">${escape(data['parent'])}</span>`;
|
html = `${html} <span class="text-secondary">${escape(data['parent'])}</span>`;
|
||||||
}
|
}
|
||||||
|
if (data['count']) {
|
||||||
|
html = `${html} <span class="badge">${escape(data['count'])}</span>`;
|
||||||
|
}
|
||||||
if (data['description']) {
|
if (data['description']) {
|
||||||
html = `${html}<br /><small class="text-secondary">${escape(data['description'])}</small>`;
|
html = `${html}<br /><small class="text-secondary">${escape(data['description'])}</small>`;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user