瀏覽代碼

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 9 月之前
父節點
當前提交
fa2d7f6516

文件差異過大導致無法顯示
+ 0 - 0
netbox/project-static/dist/netbox.js


文件差異過大導致無法顯示
+ 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"

部分文件因文件數量過多而無法顯示