mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-17 04:32:51 -06:00
Fixes #11753: Avoid re-initializing SlimSelects
This commit is contained in:
parent
64291f731b
commit
e4e4d0c0ec
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.
@ -13,6 +13,12 @@ async function saveDashboardLayout(
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function initDashboard(): void {
|
export function initDashboard(): void {
|
||||||
|
// Exit if this page does not contain a dashboard
|
||||||
|
const dashboard = document.getElementById('dashboard') as Nullable<HTMLDivElement>;
|
||||||
|
if (dashboard == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Initialize the grid
|
// Initialize the grid
|
||||||
let grid = GridStack.init({
|
let grid = GridStack.init({
|
||||||
cellHeight: 100,
|
cellHeight: 100,
|
||||||
|
@ -3,7 +3,6 @@ import { initButtons } from './buttons';
|
|||||||
import { initSelect } from './select';
|
import { initSelect } from './select';
|
||||||
|
|
||||||
function initDepedencies(): void {
|
function initDepedencies(): void {
|
||||||
console.log('initDepedencies()');
|
|
||||||
for (const init of [initButtons, initSelect]) {
|
for (const init of [initButtons, initSelect]) {
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@ import { getElements } from '../../util';
|
|||||||
import { APISelect } from './apiSelect';
|
import { APISelect } from './apiSelect';
|
||||||
|
|
||||||
export function initApiSelect(): void {
|
export function initApiSelect(): void {
|
||||||
for (const select of getElements<HTMLSelectElement>('.netbox-api-select')) {
|
for (const select of getElements<HTMLSelectElement>('.netbox-api-select:not([data-ssid])')) {
|
||||||
new APISelect(select);
|
new APISelect(select);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -40,7 +40,9 @@ function styleContainer(
|
|||||||
* the selected option.
|
* the selected option.
|
||||||
*/
|
*/
|
||||||
export function initColorSelect(): void {
|
export function initColorSelect(): void {
|
||||||
for (const select of getElements<HTMLSelectElement>('select.netbox-color-select')) {
|
for (const select of getElements<HTMLSelectElement>(
|
||||||
|
'select.netbox-color-select:not([data-ssid])',
|
||||||
|
)) {
|
||||||
for (const option of select.options) {
|
for (const option of select.options) {
|
||||||
if (canChangeColor(option)) {
|
if (canChangeColor(option)) {
|
||||||
// Get the background color from the option's value.
|
// Get the background color from the option's value.
|
||||||
|
@ -2,7 +2,7 @@ import SlimSelect from 'slim-select';
|
|||||||
import { getElements } from '../util';
|
import { getElements } from '../util';
|
||||||
|
|
||||||
export function initStaticSelect(): void {
|
export function initStaticSelect(): void {
|
||||||
for (const select of getElements<HTMLSelectElement>('.netbox-static-select')) {
|
for (const select of getElements<HTMLSelectElement>('.netbox-static-select:not([data-ssid])')) {
|
||||||
if (select !== null) {
|
if (select !== null) {
|
||||||
const label = document.querySelector(`label[for="${select.id}"]`) as HTMLLabelElement;
|
const label = document.querySelector(`label[for="${select.id}"]`) as HTMLLabelElement;
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
|
|
||||||
{% block content-wrapper %}
|
{% block content-wrapper %}
|
||||||
{# Render the user's customized dashboard #}
|
{# Render the user's customized dashboard #}
|
||||||
<div class="grid-stack">
|
<div class="grid-stack" id="dashboard">
|
||||||
{% for widget in dashboard %}
|
{% for widget in dashboard %}
|
||||||
{% include 'extras/dashboard/widget.html' %}
|
{% include 'extras/dashboard/widget.html' %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
Loading…
Reference in New Issue
Block a user