mirror of
				https://github.com/inventree/InvenTree.git
				synced 2025-10-31 13:15:43 +00:00 
			
		
		
		
	Merge branch 'inventree:master' into matmair/issue2279
This commit is contained in:
		| @@ -74,13 +74,13 @@ | ||||
|  | ||||
|     <div class='row flex-nowrap inventree-body'> | ||||
|         <div class='col-auto px-1 sidebar-wrapper'> | ||||
|             <div id='sidebar' class='collapse collapse-horizontal show border-end' style='display: none;'> | ||||
|             <div id='sidebar' class='collapse collapse-horizontal show' style='display: none;'> | ||||
|                 <div id='sidebar-nav' class='list-group text-sm-start'> | ||||
|                     <ul id='sidebar-list-group' class='list-group sidebar-list-group'> | ||||
|                         {% block sidebar %} | ||||
|                         <!-- Sidebar goes here --> | ||||
|                         {% endblock %} | ||||
|                         {% include "sidebar_toggle.html" %} | ||||
|                         {% include "sidebar_toggle.html" with target='sidebar' %} | ||||
|                     </ul> | ||||
|                 </div> | ||||
|             </div> | ||||
| @@ -104,14 +104,20 @@ | ||||
|             {% endblock %} | ||||
|  | ||||
|             {% block breadcrumb_list %} | ||||
|             <div class='container-fluid navigation'> | ||||
|             <div class='container-fluid navigation' id='breadcrumb-div'> | ||||
|                 <nav aria-label='breadcrumb'> | ||||
|                     <ol class='breadcrumb'> | ||||
|                     <ol class='breadcrumb' id='breadcrumb-list'> | ||||
|                         {% block breadcrumbs %} | ||||
|                         {% endblock %} | ||||
|                     </ol> | ||||
|                 </nav> | ||||
|  | ||||
|                 <div id='breadcrumb-tree-collapse' class='collapse collapse-horizontal show border' style='display: none;'> | ||||
|                     {% block breadcrumb_tree %} | ||||
|                     {% endblock %} | ||||
|                 </div> | ||||
|             </div> | ||||
|  | ||||
|             {% endblock %} | ||||
|  | ||||
|             {% block content %} | ||||
|   | ||||
| @@ -6,6 +6,7 @@ | ||||
|     addSidebarHeader, | ||||
|     addSidebarItem, | ||||
|     addSidebarLink, | ||||
|     enableBreadcrumbTree, | ||||
|     enableSidebar, | ||||
|     onPanelLoad, | ||||
| */ | ||||
| @@ -145,6 +146,101 @@ function enableSidebar(label, options={}) { | ||||
|  | ||||
| } | ||||
|  | ||||
| /** | ||||
|  * Enable support for breadcrumb tree navigation on this page | ||||
|  */ | ||||
| function enableBreadcrumbTree(options) { | ||||
|  | ||||
|     var label = options.label; | ||||
|  | ||||
|     if (!label) { | ||||
|         console.log('ERROR: enableBreadcrumbTree called without supplying label'); | ||||
|         return; | ||||
|     } | ||||
|  | ||||
|     var filters = options.filters || {}; | ||||
|  | ||||
|     inventreeGet( | ||||
|         options.url, | ||||
|         filters, | ||||
|         { | ||||
|             success: function(data) { | ||||
|  | ||||
|                 // Data are returned from the InvenTree server as a flattened list; | ||||
|                 // We need to convert this into a tree structure | ||||
|  | ||||
|                 var nodes = {}; | ||||
|                 var roots = []; | ||||
|                 var node = null; | ||||
|  | ||||
|                 for (var i = 0; i < data.length; i++) { | ||||
|                     node = data[i]; | ||||
|                     node.nodes = []; | ||||
|                     nodes[node.pk] = node; | ||||
|                     node.selectable = false; | ||||
|  | ||||
|                     if (options.processNode) { | ||||
|                         node = options.processNode(node); | ||||
|                     } | ||||
|  | ||||
|                     node.state = { | ||||
|                         expanded: node.pk == options.selected, | ||||
|                         selected: node.pk == options.selected, | ||||
|                     }; | ||||
|                 } | ||||
|  | ||||
|                 for (var i = 0; i < data.length; i++) { | ||||
|                     node = data[i]; | ||||
|  | ||||
|                     if (node.parent != null) { | ||||
|                         nodes[node.parent].nodes.push(node); | ||||
|  | ||||
|                         if (node.state.expanded) { | ||||
|                             nodes[node.parent].state.expanded = true; | ||||
|                         } | ||||
|                          | ||||
|                     } else { | ||||
|                         roots.push(node); | ||||
|                     } | ||||
|                 } | ||||
|  | ||||
|                 $('#breadcrumb-tree').treeview({ | ||||
|                     data: roots, | ||||
|                     showTags: true, | ||||
|                     enableLinks: true, | ||||
|                     expandIcon: 'fas fa-chevron-right', | ||||
|                     collapseIcon: 'fa fa-chevron-down', | ||||
|                 }); | ||||
|  | ||||
|                 setBreadcrumbTreeState(label, state); | ||||
|             } | ||||
|         } | ||||
|     ); | ||||
|  | ||||
|     $('#breadcrumb-tree-toggle').click(function() { | ||||
|         // Add callback to "collapse" and "expand" the sidebar | ||||
|  | ||||
|         // By default, the menu is "expanded" | ||||
|         var state = localStorage.getItem(`inventree-tree-state-${label}`) || 'expanded'; | ||||
|          | ||||
|         // We wish to "toggle" the state! | ||||
|         setBreadcrumbTreeState(label, state == 'expanded' ? 'collapsed' : 'expanded'); | ||||
|     }); | ||||
|  | ||||
|     // Set the initial state (default = expanded) | ||||
|     var state = localStorage.getItem(`inventree-tree-state-${label}`) || 'expanded'; | ||||
|  | ||||
|     function setBreadcrumbTreeState(label, state) { | ||||
|  | ||||
|         if (state == 'collapsed') { | ||||
|             $('#breadcrumb-tree-collapse').hide(100); | ||||
|         } else { | ||||
|             $('#breadcrumb-tree-collapse').show(100); | ||||
|         } | ||||
|  | ||||
|         localStorage.setItem(`inventree-tree-state-${label}`, state); | ||||
|     } | ||||
| } | ||||
|  | ||||
| /* | ||||
|  * Set the "toggle" state of the sidebar | ||||
| @@ -180,7 +276,7 @@ function setSidebarState(label, state) { | ||||
| function addSidebarItem(options={}) { | ||||
|  | ||||
|     var html = ` | ||||
|     <a href='#' id='select-${options.label}' title='${options.text}' class='list-group-item sidebar-list-group-item border-end-0 d-inline-block text-truncate sidebar-selector' data-bs-parent='#sidebar'> | ||||
|     <a href='#' id='select-${options.label}' title='${options.text}' class='list-group-item sidebar-list-group-item border-end d-inline-block text-truncate sidebar-selector' data-bs-parent='#sidebar'> | ||||
|         <i class='bi bi-bootstrap'></i> | ||||
|         ${options.content_before || ''} | ||||
|         <span class='sidebar-item-icon fas ${options.icon}'></span> | ||||
| @@ -199,7 +295,7 @@ function addSidebarItem(options={}) { | ||||
| function addSidebarHeader(options={}) { | ||||
|  | ||||
|     var html = ` | ||||
|     <span title='${options.text}' class="list-group-item sidebar-list-group-item border-end-0 d-inline-block text-truncate" data-bs-parent="#sidebar"> | ||||
|     <span title='${options.text}' class="list-group-item sidebar-list-group-item border-end d-inline-block text-truncate" data-bs-parent="#sidebar"> | ||||
|         <h6> | ||||
|             <i class="bi bi-bootstrap"></i> | ||||
|             <span class='sidebar-item-text' style='display: none;'>${options.text}</span> | ||||
|   | ||||
| @@ -1658,7 +1658,7 @@ function allocateStockToSalesOrder(order_id, line_items, options={}) { | ||||
|                             var available = Math.max((data.quantity || 0) - (data.allocated || 0), 0); | ||||
|  | ||||
|                             // Remaining quantity to be allocated? | ||||
|                             var remaining = opts.quantity || available; | ||||
|                             var remaining = Math.max(line_item.quantity - line_item.shipped - line_item.allocated, 0); | ||||
|  | ||||
|                             // Maximum amount that we need | ||||
|                             var desired = Math.min(available, remaining); | ||||
|   | ||||
| @@ -1,5 +1,5 @@ | ||||
| {% load i18n %} | ||||
| <span title='{{ text }}' class="list-group-item sidebar-list-group-item border-end-0 d-inline-block text-truncate bg-light" data-bs-parent="#sidebar"> | ||||
| <span title='{{ text }}' class="list-group-item sidebar-list-group-item border-end d-inline-block text-truncate bg-light" data-bs-parent="#sidebar"> | ||||
|     <h6> | ||||
|         <i class="bi bi-bootstrap"></i> | ||||
|         {% if icon %}<span class='sidebar-item-icon fas {{ icon }}'></span>{% endif %} | ||||
|   | ||||
| @@ -1,5 +1,5 @@ | ||||
| {% load i18n %} | ||||
| <a href="#" id='select-{{ label }}' title='{{ text }}' class="list-group-item sidebar-list-group-item border-end-0 d-inline-block text-truncate sidebar-selector" data-bs-parent="#sidebar"> | ||||
| <a href="#" id='select-{{ label }}' title='{{ text }}' class="list-group-item sidebar-list-group-item border-end d-inline-block text-truncate sidebar-selector" data-bs-parent="#sidebar"> | ||||
|     <i class="bi bi-bootstrap"></i> | ||||
|     <span class='sidebar-item-icon fas {{ icon|default:"fa-circle" }}'></span> | ||||
|     <span class='sidebar-item-text' style='display: none;'>{{ text }}</span> | ||||
|   | ||||
| @@ -1,4 +1,4 @@ | ||||
| {% load i18n %} | ||||
| <a href="{{ url }}" class="list-group-item sidebar-list-group-item border-end-0 d-inline-block text-truncate" data-bs-parent="#sidebar"> | ||||
| <a href="{{ url }}" class="list-group-item sidebar-list-group-item border-end d-inline-block text-truncate" data-bs-parent="#sidebar"> | ||||
|     <i class="bi bi-bootstrap"></i><span class='sidebar-item-icon fas {{ icon }}'></span><span class='sidebar-item-text' style='display: none;'>{{ text }}</span> | ||||
| </a> | ||||
|   | ||||
| @@ -1,3 +1,4 @@ | ||||
| <a href="#" id='sidebar-toggle' class="list-group-item sidebar-list-group-item border-end-0 d-inline-block text-truncate sidebar-toggle" data-bs-parent="#sidebar" style='display: none;'> | ||||
| <a href="#" id='{{ target }}-toggle' class="list-group-item sidebar-list-group-item border-end d-inline-block text-truncate sidebar-toggle" data-bs-parent="#sidebar" style='display: none;'> | ||||
|     <i class="bi bi-bootstrap"></i><span id='sidebar-toggle-icon' class='sidebar-item-icon fas fa-chevron-left'></span> | ||||
|     {% if text %}<span class='sidebar-item-text' style='display: none;'>{{ text }}</span>{% endif %} | ||||
| </a> | ||||
|   | ||||
		Reference in New Issue
	
	Block a user