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 %}
 | 
			
		||||
 | 
			
		||||
{% block menubar %}
 | 
			
		||||
{% include "stock/location_navbar.html" with tab="stock" %}
 | 
			
		||||
{% include "stock/location_navbar.html" %}
 | 
			
		||||
{% endblock %}
 | 
			
		||||
 | 
			
		||||
{% block content %}
 | 
			
		||||
@@ -143,13 +143,39 @@
 | 
			
		||||
 | 
			
		||||
{% 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'>
 | 
			
		||||
        <h4>{% trans "Stock Items" %}</h4>
 | 
			
		||||
    </div>
 | 
			
		||||
    {% include "stock_table.html" %}
 | 
			
		||||
</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 %}
 | 
			
		||||
 | 
			
		||||
</div>
 | 
			
		||||
@@ -164,6 +190,36 @@
 | 
			
		||||
        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 %}
 | 
			
		||||
    $("#barcode-check-in").click(function() {
 | 
			
		||||
        barcodeCheckIn({{ location.id }});
 | 
			
		||||
@@ -301,4 +357,10 @@
 | 
			
		||||
        },
 | 
			
		||||
        url: "{% url 'api-stock-list' %}",
 | 
			
		||||
    });
 | 
			
		||||
 | 
			
		||||
    attachNavCallbacks({
 | 
			
		||||
        name: 'stocklocation',
 | 
			
		||||
        default: 'stock'
 | 
			
		||||
    });
 | 
			
		||||
 | 
			
		||||
{% endblock %}
 | 
			
		||||
 
 | 
			
		||||
@@ -8,23 +8,15 @@
 | 
			
		||||
        </a>
 | 
			
		||||
    </li>
 | 
			
		||||
 | 
			
		||||
    <li class='list-group-item {% if tab == "sublocations" %}active{% endif %}' title='{% trans "Sublocations" %}'>
 | 
			
		||||
        {% if location %}
 | 
			
		||||
        <a href='{% url "stock-location-sublocation" location.id %}'>
 | 
			
		||||
        {% else %}
 | 
			
		||||
        <a href='{% url "stock-sublocations" %}'>
 | 
			
		||||
        {% endif %}
 | 
			
		||||
    <li class='list-group-item' title='{% trans "Sublocations" %}'>
 | 
			
		||||
        <a href='#' id='select-sublocations' class='nav-toggle'>
 | 
			
		||||
            <span class='fas fa-sitemap sidebar-icon'></span>
 | 
			
		||||
            {% trans "Sublocations" %}
 | 
			
		||||
        </a>
 | 
			
		||||
    </li>
 | 
			
		||||
 | 
			
		||||
    <li class='list-group-item {% if tab == "stock" %}active{% endif %}' title='{% trans "Stock Items" %}'>
 | 
			
		||||
        {% if location %}
 | 
			
		||||
        <a href='{% url "stock-location-detail" location.id %}'>
 | 
			
		||||
        {% else %}
 | 
			
		||||
        <a href='{% url "stock-index" %}'>
 | 
			
		||||
        {% endif %}
 | 
			
		||||
        <a href='#' id='select-stock' class='nav-toggle'>
 | 
			
		||||
            <span class='fas fa-boxes sidebar-icon'></span>
 | 
			
		||||
            {% trans "Stock Items" %}
 | 
			
		||||
        </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 %}
 | 
			
		||||
@@ -15,8 +15,6 @@ location_urls = [
 | 
			
		||||
        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'sublocation/', views.StockLocationDetail.as_view(template_name='stock/sublocation.html'), name='stock-location-sublocation'),
 | 
			
		||||
 | 
			
		||||
        # Anything else
 | 
			
		||||
        url('^.*$', views.StockLocationDetail.as_view(), name='stock-location-detail'),
 | 
			
		||||
    ])),
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user