diff --git a/InvenTree/part/templates/part/part_app_base.html b/InvenTree/part/templates/part/part_app_base.html index 16f3507d09..992ac15e87 100644 --- a/InvenTree/part/templates/part/part_app_base.html +++ b/InvenTree/part/templates/part/part_app_base.html @@ -20,20 +20,3 @@ {% include 'part/cat_link.html' with category=category %} {% endif %} {% endblock %} - -{% block js_ready %} -{{ block.super }} - - loadTree("{% url 'api-part-tree' %}", - "#part-tree", - { - name: 'part', - } - ); - - initNavTree({ - label: 'part', - treeId: '#sidenav-left', - toggleId: '#toggle-part-tree', - }); -{% endblock %} \ No newline at end of file diff --git a/InvenTree/stock/templates/stock/item_base.html b/InvenTree/stock/templates/stock/item_base.html index 51431d96cd..9efd71e9bc 100644 --- a/InvenTree/stock/templates/stock/item_base.html +++ b/InvenTree/stock/templates/stock/item_base.html @@ -426,19 +426,6 @@ {% block js_ready %} {{ block.super }} -loadTree("{% url 'api-stock-tree' %}", - "#stock-tree", - { - name: 'stock', - } -); - -initNavTree({ - label: 'stock', - treeId: '#sidenav-left', - toggleId: '#toggle-stock-tree', -}); - $("#stock-serialize").click(function() { launchModalForm( "{% url 'stock-item-serialize' item.id %}", diff --git a/InvenTree/stock/templates/stock/stock_app_base.html b/InvenTree/stock/templates/stock/stock_app_base.html index 72dcd3b2e8..3da3fad240 100644 --- a/InvenTree/stock/templates/stock/stock_app_base.html +++ b/InvenTree/stock/templates/stock/stock_app_base.html @@ -24,21 +24,3 @@ {% include 'stock/loc_link.html' with location=location %} {% endif %} {% endblock %} - -{% block js_ready %} -{{ block.super }} - - loadTree("{% url 'api-stock-tree' %}", - "#stock-tree", - { - name: 'stock', - } - ); - - initNavTree({ - label: 'stock', - treeId: '#sidenav-left', - toggleId: '#toggle-stock-tree', - }); - -{% endblock %} \ No newline at end of file diff --git a/InvenTree/templates/InvenTree/index.html b/InvenTree/templates/InvenTree/index.html index ece19e741d..a50059327d 100644 --- a/InvenTree/templates/InvenTree/index.html +++ b/InvenTree/templates/InvenTree/index.html @@ -7,6 +7,40 @@ {% inventree_title %} | {% trans "Index" %} {% endblock %} + +{% block sidebar %} + +{% include "sidebar_header.html" with text="Parts" icon="fa-shapes" %} +{% include "sidebar_item.html" with label='starred-parts' text="Starred Parts" icon="fa-star" badge=True %} +{% include "sidebar_item.html" with label='latest-parts' text="Latest Parts" icon="fa-newspaper" badge=True %} +{% include "sidebar_item.html" with label='bom-validation' text="BOM Requires Attention" icon="fa-times-circle" badge=True %} + + +{% include "sidebar_header.html" with text="Stock" icon="fa-boxes" %} +{% include "sidebar_item.html" with label='recently-updated-stock' text="Recently Updates" icon="fa-clock" badge=True %} +{% include "sidebar_item.html" with label='low-stock' text="Low Stock" icon="fa-shopping-cart" badge=True %} +{% include "sidebar_item.html" with label='depleted-stock' text="Depleted Stock" icon="fa-times badge=True" %} +{% include "sidebar_item.html" with label='stock-to-build' text="Need to Build" icon="fa-bullhorn" badge=True %} +{% include "sidebar_item.html" with label='expired-stock' text="Expired Stock" icon="fa-calendar-times" badge=True %} +{% include "sidebar_item.html" with label='stale-stock' text="Stale Stock" icon="fa-stopwatch" badge=True %} + + +{% include "sidebar_header.html" with text="Build Orders" icon="fa-tools" %} +{% include "sidebar_item.html" with label='build-pending' text="In Progress" icon="fa-cogs" badge=True %} +{% include "sidebar_item.html" with label='build-overdue' text="Overdue" icon="fa-calendar-times" badge=True %} + + +{% include "sidebar_header.html" with text="Purchase Orders" icon="fa-shopping-cart" %} +{% include "sidebar_item.html" with label='po-outstanding' text="Outstanding" icon="fa-sign-in-alt" badge=True %} +{% include "sidebar_item.html" with label='po-overdue' text="Overdue" icon="fa-calendar-times" badge=True %} + + +{% include "sidebar_header.html" with text="Sales Orders" icon="fa-truck" %} +{% include "sidebar_item.html" with label='so-outstanding' text="Outstanding" icon="fa-sign-out-alt" badge=True %} +{% include "sidebar_item.html" with label='so-overdue' text="Overdue" icon="fa-calendar-times" badge=True %} + +{% endblock %} + {% block content %}

{% inventree_title %}


@@ -320,4 +354,6 @@ loadSalesOrderTable("#table-so-overdue", { {% endif %} +enableSidebar('index'); + {% endblock %} \ No newline at end of file diff --git a/InvenTree/templates/js/dynamic/nav.js b/InvenTree/templates/js/dynamic/nav.js index 19e9a5e45b..0a99c70722 100644 --- a/InvenTree/templates/js/dynamic/nav.js +++ b/InvenTree/templates/js/dynamic/nav.js @@ -3,8 +3,6 @@ /* exported enableSidebar, - initNavTree, - loadTree, onPanelLoad, */ @@ -81,159 +79,6 @@ function onPanelLoad(panel, callback) { }); } -function loadTree(url, tree, options={}) { - /* Load the side-nav tree view - - Args: - url: URL to request tree data - tree: html ref to treeview - options: - data: data object to pass to the AJAX request - selected: ID of currently selected item - name: name of the tree - */ - - var data = {}; - - if (options.data) { - data = options.data; - } - - var key = 'inventree-sidenav-items-'; - - if (options.name) { - key += options.name; - } - - $.ajax({ - url: url, - type: 'get', - dataType: 'json', - data: data, - success: function(response) { - if (response.tree) { - $(tree).treeview({ - data: response.tree, - enableLinks: true, - showTags: true, - }); - - if (localStorage.getItem(key)) { - var saved_exp = localStorage.getItem(key).split(','); - - // Automatically expand the desired notes - for (var q = 0; q < saved_exp.length; q++) { - $(tree).treeview('expandNode', parseInt(saved_exp[q])); - } - } - - // Setup a callback whenever a node is toggled - $(tree).on('nodeExpanded nodeCollapsed', function(event, data) { - - // Record the entire list of expanded items - var expanded = $(tree).treeview('getExpanded'); - - var exp = []; - - for (var i = 0; i < expanded.length; i++) { - exp.push(expanded[i].nodeId); - } - - // Save the expanded nodes - localStorage.setItem(key, exp); - }); - } - }, - error: function(xhr, ajaxOptions, thrownError) { - // TODO - } - }); -} - - -/** - * Initialize navigation tree display - */ -function initNavTree(options) { - - var resize = true; - - if ('resize' in options) { - resize = options.resize; - } - - var label = options.label || 'nav'; - - var stateLabel = `${label}-tree-state`; - var widthLabel = `${label}-tree-width`; - - var treeId = options.treeId || '#sidenav-left'; - var toggleId = options.toggleId; - - // Initially hide the tree - $(treeId).animate({ - width: '0px', - }, 0, function() { - - if (resize) { - $(treeId).resizable({ - minWidth: '0px', - maxWidth: '500px', - handles: 'e, se', - grid: [5, 5], - stop: function(event, ui) { - var width = Math.round(ui.element.width()); - - if (width < 75) { - $(treeId).animate({ - width: '0px' - }, 50); - - localStorage.setItem(stateLabel, 'closed'); - } else { - localStorage.setItem(stateLabel, 'open'); - localStorage.setItem(widthLabel, `${width}px`); - } - } - }); - } - - var state = localStorage.getItem(stateLabel); - var width = localStorage.getItem(widthLabel) || '300px'; - - if (state && state == 'open') { - - $(treeId).animate({ - width: width, - }, 50); - } - }); - - // Register callback for 'toggle' button - if (toggleId) { - - $(toggleId).click(function() { - - var state = localStorage.getItem(stateLabel) || 'closed'; - var width = localStorage.getItem(widthLabel) || '300px'; - - if (state == 'open') { - $(treeId).animate({ - width: '0px' - }, 50); - - localStorage.setItem(stateLabel, 'closed'); - } else { - $(treeId).animate({ - width: width, - }, 50); - - localStorage.setItem(stateLabel, 'open'); - } - }); - } -} - /** * Enable support for sidebar on this page @@ -297,7 +142,8 @@ function setSidebarState(label, state) { if (state == "collapsed") { $('.sidebar-item-text').animate({ - opacity: 0.0, + 'opacity': 0.0, + 'font-size': '0%', }, 100, function() { $('.sidebar-item-text').hide(); $('#sidebar-toggle-icon').removeClass('fa-chevron-left').addClass('fa-chevron-right'); @@ -306,7 +152,8 @@ function setSidebarState(label, state) { $('.sidebar-item-text').show(); $('#sidebar-toggle-icon').removeClass('fa-chevron-right').addClass('fa-chevron-left'); $('.sidebar-item-text').animate({ - opacity: 1.0, + 'opacity': 1.0, + 'font-size': '100%', }, 100); } diff --git a/InvenTree/templates/sidebar_header.html b/InvenTree/templates/sidebar_header.html index 935862b64f..f4638ee64b 100644 --- a/InvenTree/templates/sidebar_header.html +++ b/InvenTree/templates/sidebar_header.html @@ -1,6 +1,8 @@ {% load i18n %} -
- -
+
+ + {% if icon %}{% endif %} + {% if text %}{% endif %} +
diff --git a/InvenTree/templates/sidebar_item.html b/InvenTree/templates/sidebar_item.html index 004885f0d3..d5c7b08365 100644 --- a/InvenTree/templates/sidebar_item.html +++ b/InvenTree/templates/sidebar_item.html @@ -1,4 +1,11 @@ {% load i18n %} - + + + + {% if badge %} + + + + {% endif %}