Fixed up device & device type tab navigation

This commit is contained in:
Jeremy Stretch 2020-10-30 11:41:51 -04:00
parent fcb5e6ae1c
commit f82e2a8d20
3 changed files with 13 additions and 12 deletions

View File

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

View File

@ -206,28 +206,28 @@
</ul> </ul>
<div class="tab-content"> <div class="tab-content">
<div role="tabpanel" class="tab-pane active" id="interfaces"> <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>
<div role="tabpanel" class="tab-pane" id="frontports"> <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>
<div role="tabpanel" class="tab-pane" id="rearports"> <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>
<div role="tabpanel" class="tab-pane" id="consoleports"> <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>
<div role="tabpanel" class="tab-pane" id="consoleserverports"> <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>
<div role="tabpanel" class="tab-pane" id="powerports"> <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>
<div role="tabpanel" class="tab-pane" id="poweroutlets"> <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>
<div role="tabpanel" class="tab-pane" id="devicebays"> <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> </div>
</div> </div>

View File

@ -20,7 +20,7 @@
</button> </button>
{% endif %} {% endif %}
<div class="pull-right"> <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> <span class="glyphicon glyphicon-plus" aria-hidden="true"></span>
Add {{ title }} Add {{ title }}
</a> </a>