mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
* Fix left padding of login button in top menu * Relocate "add" buttons for embedded object tables * Remove unused data template block & getNetboxData() utility function * Remove bottom margin from last <p> element in rendered Markdown inside a table cell * Prevent TomSelect from initializing on <select> elements with a size * Fix styling of dropdown menu button for circuit commit rate * Change .color-block to display: inline-block * Delete unused static asset * Improve contrast between menu group headings & items * Remove custom color for attr-table row headings * Fix border color of copy-to-clipboard button * Fix toast text color in dark mode * Fix rack elevation label/image toggles * Increase border radius for small buttons * Fix object selector
36 lines
872 B
TypeScript
36 lines
872 B
TypeScript
import { getElements } from './util';
|
|
|
|
function handleSelection(link: HTMLAnchorElement): void {
|
|
const selector_results = document.getElementById('selector_results');
|
|
if (selector_results == null) {
|
|
return
|
|
}
|
|
const target_id = selector_results.getAttribute('data-selector-target');
|
|
if (target_id == null) {
|
|
return
|
|
}
|
|
const target = document.getElementById(target_id);
|
|
if (target == null) {
|
|
return
|
|
}
|
|
|
|
const label = link.getAttribute('data-label');
|
|
const value = link.getAttribute('data-value');
|
|
|
|
//@ts-ignore
|
|
target.tomselect.addOption({
|
|
id: value,
|
|
display: label,
|
|
});
|
|
//@ts-ignore
|
|
target.tomselect.addItem(value);
|
|
|
|
}
|
|
|
|
|
|
export function initObjectSelector(): void {
|
|
for (const element of getElements<HTMLAnchorElement>('#selector_results a')) {
|
|
element.addEventListener('click', () => handleSelection(element));
|
|
}
|
|
}
|