Просмотр исходного кода

Fixed up device & device type tab navigation

Jeremy Stretch 5 лет назад
Родитель
Сommit
f82e2a8d20

+ 4 - 3
netbox/templates/dcim/device.html

@@ -66,7 +66,7 @@
                         <li><a href="{% url 'dcim:devicebay_add' %}?device={{ device.pk }}&return_url={{ device.get_absolute_url }}%23tab_devicebays">Device Bays</a></li>
                     {% endif %}
                     {% if perms.dcim.add_inventoryitem %}
-                        <li><a href="{% url 'dcim:inventoryitem_add' %}?device={{ device.pk }}&return_url={{ device.get_absolute_url }}">Inventory Items</a></li>
+                        <li><a href="{% url 'dcim:inventoryitem_add' %}?device={{ device.pk }}&return_url={{ device.get_absolute_url }}%23tab_inventoryitems">Inventory Items</a></li>
                     {% endif %}
                 </ul>
             </div>
@@ -731,6 +731,7 @@
                                         </a>
                                     </div>
                                 {% endif %}
+                                <div class="clearfix"></div>
                             </div>
                         </div>
                     </form>
@@ -842,7 +843,7 @@
                                 {% endif %}
                                 {% if perms.dcim.add_inventoryitem %}
                                     <div class="pull-right">
-                                        <a href="{% url 'dcim:inventoryitem_add' %}?device={{ device.pk }}&return_url={{ device.get_absolute_url }}" class="btn btn-primary btn-xs">
+                                        <a href="{% url 'dcim:inventoryitem_add' %}?device={{ device.pk }}&return_url={{ device.get_absolute_url }}%23tab_inventoryitems" class="btn btn-primary btn-xs">
                                             <span class="fa fa-plus" aria-hidden="true"></span> Add Inventory Item
                                         </a>
                                     </div>
@@ -873,7 +874,7 @@
 var hash = document.location.hash;
 var prefix = "tab_";
 if (hash) {
-    $('.nav-tabs a[href="'+hash.replace(prefix,"")+'"]').tab('show');
+    $('.nav-pills a[href="'+hash.replace(prefix,"")+'"]').tab('show');
 }
 $('.nav-tabs a').on('shown.bs.tab', function (e) {
     window.location.hash = e.target.hash.replace("#", "#" + prefix);

+ 8 - 8
netbox/templates/dcim/devicetype.html

@@ -206,28 +206,28 @@
             </ul>
             <div class="tab-content">
                 <div role="tabpanel" class="tab-pane active" id="interfaces">
-                    {% include 'dcim/inc/devicetype_component_table.html' with table=interface_table title='Interfaces' %}
+                    {% include 'dcim/inc/devicetype_component_table.html' with table=interface_table title='Interfaces' tab='interfaces' %}
                 </div>
                 <div role="tabpanel" class="tab-pane" id="frontports">
-                    {% include 'dcim/inc/devicetype_component_table.html' with table=front_port_table title='Front Ports' %}
+                    {% include 'dcim/inc/devicetype_component_table.html' with table=front_port_table title='Front Ports' tab='frontports' %}
                 </div>
                 <div role="tabpanel" class="tab-pane" id="rearports">
-                    {% include 'dcim/inc/devicetype_component_table.html' with table=rear_port_table title='Rear Ports' %}
+                    {% include 'dcim/inc/devicetype_component_table.html' with table=rear_port_table title='Rear Ports' tab='rearports' %}
                 </div>
                 <div role="tabpanel" class="tab-pane" id="consoleports">
-                    {% include 'dcim/inc/devicetype_component_table.html' with table=consoleport_table title='Console Ports' %}
+                    {% include 'dcim/inc/devicetype_component_table.html' with table=consoleport_table title='Console Ports' tab='consoleports' %}
                 </div>
                 <div role="tabpanel" class="tab-pane" id="consoleserverports">
-                    {% include 'dcim/inc/devicetype_component_table.html' with table=consoleserverport_table title='Console Server Ports' %}
+                    {% include 'dcim/inc/devicetype_component_table.html' with table=consoleserverport_table title='Console Server Ports' tab='consoleserverports' %}
                 </div>
                 <div role="tabpanel" class="tab-pane" id="powerports">
-                    {% include 'dcim/inc/devicetype_component_table.html' with table=powerport_table title='Power Ports' %}
+                    {% include 'dcim/inc/devicetype_component_table.html' with table=powerport_table title='Power Ports' tab='powerports' %}
                 </div>
                 <div role="tabpanel" class="tab-pane" id="poweroutlets">
-                    {% include 'dcim/inc/devicetype_component_table.html' with table=poweroutlet_table title='Power Outlets' %}
+                    {% include 'dcim/inc/devicetype_component_table.html' with table=poweroutlet_table title='Power Outlets' tab='poweroutlets' %}
                 </div>
                 <div role="tabpanel" class="tab-pane" id="devicebays">
-                    {% include 'dcim/inc/devicetype_component_table.html' with table=devicebay_table title='Device Bays' %}
+                    {% include 'dcim/inc/devicetype_component_table.html' with table=devicebay_table title='Device Bays' tab='devicebays' %}
                 </div>
             </div>
         </div>

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

@@ -20,7 +20,7 @@
                     </button>
                 {% endif %}
                 <div class="pull-right">
-                    <a href="{% url table.Meta.model|viewname:"add" %}?device_type={{ devicetype.pk }}&return_url={{ devicetype.get_absolute_url }}" class="btn btn-primary btn-xs">
+                    <a href="{% url table.Meta.model|viewname:"add" %}?device_type={{ devicetype.pk }}&return_url={{ devicetype.get_absolute_url }}%23tab_{{ tab }}" class="btn btn-primary btn-xs">
                         <span class="glyphicon glyphicon-plus" aria-hidden="true"></span>
                         Add {{ title }}
                     </a>