mirror of
				https://github.com/inventree/InvenTree.git
				synced 2025-11-04 07:05:41 +00:00 
			
		
		
		
	Refactor StockLocation pages
This commit is contained in:
		@@ -4,7 +4,7 @@
 | 
				
			|||||||
{% load i18n %}
 | 
					{% load i18n %}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
{% block menubar %}
 | 
					{% block menubar %}
 | 
				
			||||||
{% include "stock/location_navbar.html" with tab="stock" %}
 | 
					{% include "stock/location_navbar.html" %}
 | 
				
			||||||
{% endblock %}
 | 
					{% endblock %}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
{% block content %}
 | 
					{% block content %}
 | 
				
			||||||
@@ -143,13 +143,39 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
{% block location_content %}
 | 
					{% block location_content %}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
<div class='panel panel-default panel-inventree'>
 | 
					<div class='panel panel-default panel-inventree panel-hidden' id='panel-stock'>
 | 
				
			||||||
    <div class='panel-heading'>
 | 
					    <div class='panel-heading'>
 | 
				
			||||||
        <h4>{% trans "Stock Items" %}</h4>
 | 
					        <h4>{% trans "Stock Items" %}</h4>
 | 
				
			||||||
    </div>
 | 
					    </div>
 | 
				
			||||||
    {% include "stock_table.html" %}
 | 
					    {% include "stock_table.html" %}
 | 
				
			||||||
</div>
 | 
					</div>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					<div class='panel panel-default panel-inventree panel-hidden' id='panel-sublocations'>
 | 
				
			||||||
 | 
					    <div class='panel-heading'>
 | 
				
			||||||
 | 
					        <h4>{% trans "Sublocations" %}</h4>
 | 
				
			||||||
 | 
					    </div>
 | 
				
			||||||
 | 
					    <div class='panel-content'>
 | 
				
			||||||
 | 
					        <div id='sublocation-button-toolbar'>
 | 
				
			||||||
 | 
					            <div class='button-toolbar container-fluid' style='float: right;'>
 | 
				
			||||||
 | 
					                <!-- Printing actions menu -->
 | 
				
			||||||
 | 
					                <div class='btn-group'>
 | 
				
			||||||
 | 
					                    <button id='location-print-options' class='btn btn-primary dropdown-toggle' type='button' data-toggle="dropdown" title='{% trans "Printing Actions" %}'>
 | 
				
			||||||
 | 
					                        <span class='fas fa-print'></span> <span class='caret'></span>
 | 
				
			||||||
 | 
					                    </button>
 | 
				
			||||||
 | 
					                    <ul class='dropdown-menu'>
 | 
				
			||||||
 | 
					                        <li><a href='#' id='multi-location-print-label' title='{% trans "Print labels" %}'><span class='fas fa-tags'></span> {% trans "Print labels" %}</a></li>
 | 
				
			||||||
 | 
					                    </ul>
 | 
				
			||||||
 | 
					                </div>
 | 
				
			||||||
 | 
					                <div class='filter-list' id='filter-list-location'>
 | 
				
			||||||
 | 
					                    <!-- An empty div in which the filter list will be constructed -->
 | 
				
			||||||
 | 
					                </div>
 | 
				
			||||||
 | 
					            </div>
 | 
				
			||||||
 | 
					        </div>
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					        <table class='table table-striped table-condensed' data-toolbar='#sublocation-button-toolbar' id='sublocation-table'></table>
 | 
				
			||||||
 | 
					    </div>
 | 
				
			||||||
 | 
					</div>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
{% endblock %}
 | 
					{% endblock %}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
</div>
 | 
					</div>
 | 
				
			||||||
@@ -164,6 +190,36 @@
 | 
				
			|||||||
        toggleId: '#location-menu-toggle'
 | 
					        toggleId: '#location-menu-toggle'
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    loadStockLocationTable($('#sublocation-table'), {
 | 
				
			||||||
 | 
					        params: {
 | 
				
			||||||
 | 
					            {% if location %}
 | 
				
			||||||
 | 
					            parent: {{ location.pk }},
 | 
				
			||||||
 | 
					            {% else %}
 | 
				
			||||||
 | 
					            parent: 'null',
 | 
				
			||||||
 | 
					            {% endif %}
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    });
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    linkButtonsToSelection(
 | 
				
			||||||
 | 
					        $('#sublocation-table'),
 | 
				
			||||||
 | 
					        [
 | 
				
			||||||
 | 
					            '#location-print-options',
 | 
				
			||||||
 | 
					        ]
 | 
				
			||||||
 | 
					    );
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    $('#multi-location-print-label').click(function() {
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					        var selections = $('#sublocation-table').bootstrapTable('getSelections');
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					        var locations = [];
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					        selections.forEach(function(loc) {
 | 
				
			||||||
 | 
					            locations.push(loc.pk);
 | 
				
			||||||
 | 
					        });
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					        printStockLocationLabels(locations);
 | 
				
			||||||
 | 
					    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    {% if location %}
 | 
					    {% if location %}
 | 
				
			||||||
    $("#barcode-check-in").click(function() {
 | 
					    $("#barcode-check-in").click(function() {
 | 
				
			||||||
        barcodeCheckIn({{ location.id }});
 | 
					        barcodeCheckIn({{ location.id }});
 | 
				
			||||||
@@ -301,4 +357,10 @@
 | 
				
			|||||||
        },
 | 
					        },
 | 
				
			||||||
        url: "{% url 'api-stock-list' %}",
 | 
					        url: "{% url 'api-stock-list' %}",
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    attachNavCallbacks({
 | 
				
			||||||
 | 
					        name: 'stocklocation',
 | 
				
			||||||
 | 
					        default: 'stock'
 | 
				
			||||||
 | 
					    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
{% endblock %}
 | 
					{% endblock %}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -8,23 +8,15 @@
 | 
				
			|||||||
        </a>
 | 
					        </a>
 | 
				
			||||||
    </li>
 | 
					    </li>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    <li class='list-group-item {% if tab == "sublocations" %}active{% endif %}' title='{% trans "Sublocations" %}'>
 | 
					    <li class='list-group-item' title='{% trans "Sublocations" %}'>
 | 
				
			||||||
        {% if location %}
 | 
					        <a href='#' id='select-sublocations' class='nav-toggle'>
 | 
				
			||||||
        <a href='{% url "stock-location-sublocation" location.id %}'>
 | 
					 | 
				
			||||||
        {% else %}
 | 
					 | 
				
			||||||
        <a href='{% url "stock-sublocations" %}'>
 | 
					 | 
				
			||||||
        {% endif %}
 | 
					 | 
				
			||||||
            <span class='fas fa-sitemap sidebar-icon'></span>
 | 
					            <span class='fas fa-sitemap sidebar-icon'></span>
 | 
				
			||||||
            {% trans "Sublocations" %}
 | 
					            {% trans "Sublocations" %}
 | 
				
			||||||
        </a>
 | 
					        </a>
 | 
				
			||||||
    </li>
 | 
					    </li>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    <li class='list-group-item {% if tab == "stock" %}active{% endif %}' title='{% trans "Stock Items" %}'>
 | 
					    <li class='list-group-item {% if tab == "stock" %}active{% endif %}' title='{% trans "Stock Items" %}'>
 | 
				
			||||||
        {% if location %}
 | 
					        <a href='#' id='select-stock' class='nav-toggle'>
 | 
				
			||||||
        <a href='{% url "stock-location-detail" location.id %}'>
 | 
					 | 
				
			||||||
        {% else %}
 | 
					 | 
				
			||||||
        <a href='{% url "stock-index" %}'>
 | 
					 | 
				
			||||||
        {% endif %}
 | 
					 | 
				
			||||||
            <span class='fas fa-boxes sidebar-icon'></span>
 | 
					            <span class='fas fa-boxes sidebar-icon'></span>
 | 
				
			||||||
            {% trans "Stock Items" %}
 | 
					            {% trans "Stock Items" %}
 | 
				
			||||||
        </a>
 | 
					        </a>
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,74 +0,0 @@
 | 
				
			|||||||
{% extends "stock/location.html" %}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
{% load static %}
 | 
					 | 
				
			||||||
{% load i18n %}
 | 
					 | 
				
			||||||
{% load inventree_extras %}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
{% block menubar %}
 | 
					 | 
				
			||||||
{% include "stock/location_navbar.html" with tab="sublocations" %}
 | 
					 | 
				
			||||||
{% endblock %}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
{% block location_content %}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
<div class='panel panel-default panel-inventree'>
 | 
					 | 
				
			||||||
    <div class='panel-heading'>
 | 
					 | 
				
			||||||
        <h4>{% trans "Sublocations" %}</h4>
 | 
					 | 
				
			||||||
    </div>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    <div id='button-toolbar'>
 | 
					 | 
				
			||||||
        <div class='button-toolbar container-fluid' style='float: right;'>
 | 
					 | 
				
			||||||
            <!-- Printing actions menu -->
 | 
					 | 
				
			||||||
            <div class='btn-group'>
 | 
					 | 
				
			||||||
                <button id='location-print-options' class='btn btn-primary dropdown-toggle' type='button' data-toggle="dropdown" title='{% trans "Printing Actions" %}'>
 | 
					 | 
				
			||||||
                    <span class='fas fa-print'></span> <span class='caret'></span>
 | 
					 | 
				
			||||||
                </button>
 | 
					 | 
				
			||||||
                <ul class='dropdown-menu'>
 | 
					 | 
				
			||||||
                    <li><a href='#' id='multi-location-print-label' title='{% trans "Print labels" %}'><span class='fas fa-tags'></span> {% trans "Print labels" %}</a></li>
 | 
					 | 
				
			||||||
                </ul>
 | 
					 | 
				
			||||||
            </div>
 | 
					 | 
				
			||||||
            <div class='filter-list' id='filter-list-location'>
 | 
					 | 
				
			||||||
                <!-- An empty div in which the filter list will be constructed -->
 | 
					 | 
				
			||||||
            </div>
 | 
					 | 
				
			||||||
        </div>
 | 
					 | 
				
			||||||
    </div>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    <table class='table table-striped table-condensed' data-toolbar='#button-toolbar' id='sublocation-table'></table>
 | 
					 | 
				
			||||||
</div>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
{% endblock %}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
{% block js_ready %}
 | 
					 | 
				
			||||||
{{ block.super }}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
loadStockLocationTable($('#sublocation-table'), {
 | 
					 | 
				
			||||||
    params: {
 | 
					 | 
				
			||||||
        {% if location %}
 | 
					 | 
				
			||||||
        parent: {{ location.pk }},
 | 
					 | 
				
			||||||
        {% else %}
 | 
					 | 
				
			||||||
        parent: 'null',
 | 
					 | 
				
			||||||
        {% endif %}
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
});
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
linkButtonsToSelection(
 | 
					 | 
				
			||||||
    $('#sublocation-table'),
 | 
					 | 
				
			||||||
    [
 | 
					 | 
				
			||||||
        '#location-print-options',
 | 
					 | 
				
			||||||
    ]
 | 
					 | 
				
			||||||
);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
$('#multi-location-print-label').click(function() {
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    var selections = $('#sublocation-table').bootstrapTable('getSelections');
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    var locations = [];
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    selections.forEach(function(loc) {
 | 
					 | 
				
			||||||
        locations.push(loc.pk);
 | 
					 | 
				
			||||||
    });
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    printStockLocationLabels(locations);
 | 
					 | 
				
			||||||
})
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
{% endblock %}
 | 
					 | 
				
			||||||
@@ -14,9 +14,7 @@ location_urls = [
 | 
				
			|||||||
        url(r'^edit/?', views.StockLocationEdit.as_view(), name='stock-location-edit'),
 | 
					        url(r'^edit/?', views.StockLocationEdit.as_view(), name='stock-location-edit'),
 | 
				
			||||||
        url(r'^delete/?', views.StockLocationDelete.as_view(), name='stock-location-delete'),
 | 
					        url(r'^delete/?', views.StockLocationDelete.as_view(), name='stock-location-delete'),
 | 
				
			||||||
        url(r'^qr_code/?', views.StockLocationQRCode.as_view(), name='stock-location-qr'),
 | 
					        url(r'^qr_code/?', views.StockLocationQRCode.as_view(), name='stock-location-qr'),
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
        url(r'sublocation/', views.StockLocationDetail.as_view(template_name='stock/sublocation.html'), name='stock-location-sublocation'),
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        # Anything else
 | 
					        # Anything else
 | 
				
			||||||
        url('^.*$', views.StockLocationDetail.as_view(), name='stock-location-detail'),
 | 
					        url('^.*$', views.StockLocationDetail.as_view(), name='stock-location-detail'),
 | 
				
			||||||
    ])),
 | 
					    ])),
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user