Parcourir la source

Fixes #19916: restore Rack device representation behavior

The select list of 'Images and Label', 'Images Only', and 'Label Only'
was broken during recent work while implementing #19823.

This fixes the issue by placing the `rack_elevation` class attribute on
the <div> element that contains the SVG after being loaded by HTMX. In
addition, we needed to slightly modify the selectors in the frontend
code that looked for the elements within the SVG to hide and/or show.
Previously, it was looking inside of a contentDocument embedded in an
<object> element. The simplified version just looks inside of the
SVG containing div.
Jason Novinger il y a 7 mois
Parent
commit
fa2d7f6516

Fichier diff supprimé car celui-ci est trop grand
+ 0 - 0
netbox/project-static/dist/netbox.js


Fichier diff supprimé car celui-ci est trop grand
+ 0 - 0
netbox/project-static/dist/netbox.js.map


+ 2 - 2
netbox/project-static/src/racks.ts

@@ -35,7 +35,7 @@ function showRackElements(
   selector: string,
   elevation: HTMLObjectElement,
 ): void {
-  const elements = elevation.contentDocument?.querySelectorAll(selector) ?? [];
+  const elements = elevation.querySelectorAll(selector) ?? [];
   for (const element of elements) {
     element.classList.remove('hidden');
   }
@@ -45,7 +45,7 @@ function hideRackElements(
   selector: string,
   elevation: HTMLObjectElement,
 ): void {
-  const elements = elevation.contentDocument?.querySelectorAll(selector) ?? [];
+  const elements = elevation.querySelectorAll(selector) ?? [];
   for (const element of elements) {
     element.classList.add('hidden');
   }

+ 1 - 1
netbox/templates/dcim/inc/rack_elevation.html

@@ -1,5 +1,5 @@
 {% load i18n %}
-<div style="margin-left: -30px">
+<div style="margin-left: -30px" class="rack_elevation">
   <div
     hx-get="{% url 'dcim-api:rack-elevation' pk=object.pk %}?face={{ face }}&render=svg{% if extra_params %}&{{ extra_params }}{% endif %}"
     hx-trigger="intersect"

Certains fichiers n'ont pas été affichés car il y a eu trop de fichiers modifiés dans ce diff