mirror of
				https://github.com/inventree/InvenTree.git
				synced 2025-11-03 22:55:43 +00:00 
			
		
		
		
	Required for order fix (#5077)
* Fix part tables on index page - Stop table filters overriding each other * Refactor "needed for build" table - Now shows amount actually needed * Fix typo * js fix * linting * Fix warning messages on index page * js linting
This commit is contained in:
		@@ -111,6 +111,7 @@ translated_javascript_urls = [
 | 
				
			|||||||
    re_path(r'^filters.js', DynamicJsView.as_view(template_name='js/translated/filters.js'), name='filters.js'),
 | 
					    re_path(r'^filters.js', DynamicJsView.as_view(template_name='js/translated/filters.js'), name='filters.js'),
 | 
				
			||||||
    re_path(r'^forms.js', DynamicJsView.as_view(template_name='js/translated/forms.js'), name='forms.js'),
 | 
					    re_path(r'^forms.js', DynamicJsView.as_view(template_name='js/translated/forms.js'), name='forms.js'),
 | 
				
			||||||
    re_path(r'^helpers.js', DynamicJsView.as_view(template_name='js/translated/helpers.js'), name='helpers.js'),
 | 
					    re_path(r'^helpers.js', DynamicJsView.as_view(template_name='js/translated/helpers.js'), name='helpers.js'),
 | 
				
			||||||
 | 
					    re_path(r'^index.js', DynamicJsView.as_view(template_name='js/translated/index.js'), name='index.js'),
 | 
				
			||||||
    re_path(r'^label.js', DynamicJsView.as_view(template_name='js/translated/label.js'), name='label.js'),
 | 
					    re_path(r'^label.js', DynamicJsView.as_view(template_name='js/translated/label.js'), name='label.js'),
 | 
				
			||||||
    re_path(r'^model_renderers.js', DynamicJsView.as_view(template_name='js/translated/model_renderers.js'), name='model_renderers.js'),
 | 
					    re_path(r'^model_renderers.js', DynamicJsView.as_view(template_name='js/translated/model_renderers.js'), name='model_renderers.js'),
 | 
				
			||||||
    re_path(r'^modals.js', DynamicJsView.as_view(template_name='js/translated/modals.js'), name='modals.js'),
 | 
					    re_path(r'^modals.js', DynamicJsView.as_view(template_name='js/translated/modals.js'), name='modals.js'),
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -962,7 +962,7 @@ class PartFilter(rest_filters.FilterSet):
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    depleted_stock = rest_filters.BooleanFilter(label='Depleted Stock', method='filter_depleted_stock')
 | 
					    depleted_stock = rest_filters.BooleanFilter(label='Depleted Stock', method='filter_depleted_stock')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def filter_deployed_stock(self, queryset, name, value):
 | 
					    def filter_depleted_stock(self, queryset, name, value):
 | 
				
			||||||
        """Filter the queryset based on whether the part is fully depleted of stock"""
 | 
					        """Filter the queryset based on whether the part is fully depleted of stock"""
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if str2bool(value):
 | 
					        if str2bool(value):
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -25,61 +25,6 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
{{ block.super }}
 | 
					{{ block.super }}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function addHeaderTitle(title) {
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    addSidebarHeader({
 | 
					 | 
				
			||||||
        text: title,
 | 
					 | 
				
			||||||
    });
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
function addHeaderAction(label, title, icon, options) {
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    // Construct a "badge" to add to the sidebar item
 | 
					 | 
				
			||||||
    var badge = `
 | 
					 | 
				
			||||||
    <span id='sidebar-badge-${label}' class='sidebar-item-badge badge rounded-pill badge-right bg-dark'>
 | 
					 | 
				
			||||||
        <span class='fas fa-spin fa-spinner'></span>
 | 
					 | 
				
			||||||
    </span>
 | 
					 | 
				
			||||||
    `;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    addSidebarItem({
 | 
					 | 
				
			||||||
        label: label,
 | 
					 | 
				
			||||||
        text: title,
 | 
					 | 
				
			||||||
        icon: icon,
 | 
					 | 
				
			||||||
        content_after: badge
 | 
					 | 
				
			||||||
    });
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    // Add a detail item to the detail item-panel
 | 
					 | 
				
			||||||
    $("#detail-panels").append(
 | 
					 | 
				
			||||||
        `<div class='panel panel-inventree panel-hidden' id='panel-${label}'>
 | 
					 | 
				
			||||||
            <div class='panel-heading'>
 | 
					 | 
				
			||||||
                <h4>${title}</h4>
 | 
					 | 
				
			||||||
            </div>
 | 
					 | 
				
			||||||
            <div class='panel-content'>
 | 
					 | 
				
			||||||
                <table class='table table-condensed table-striped' id='table-${label}'></table>
 | 
					 | 
				
			||||||
            </div>
 | 
					 | 
				
			||||||
        </div>`
 | 
					 | 
				
			||||||
    );
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    let table_name = `#table-${label}`;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    // Connect a callback to the table
 | 
					 | 
				
			||||||
    $(table_name).on('load-success.bs.table', function(data) {
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        let options = $(table_name).bootstrapTable('getOptions');
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        let count = options.totalRows;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        let badge = $(`#sidebar-badge-${label}`);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        badge.html(count);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        if (count > 0) {
 | 
					 | 
				
			||||||
            badge.removeClass('bg-dark');
 | 
					 | 
				
			||||||
            badge.addClass('bg-primary');
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    });
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
{% settings_value 'HOMEPAGE_HIDE_INACTIVE' user=request.user as hide_inactive %}
 | 
					{% settings_value 'HOMEPAGE_HIDE_INACTIVE' user=request.user as hide_inactive %}
 | 
				
			||||||
{% settings_value 'HOMEPAGE_PART_STARRED' user=request.user as setting_part_starred %}
 | 
					{% settings_value 'HOMEPAGE_PART_STARRED' user=request.user as setting_part_starred %}
 | 
				
			||||||
{% settings_value 'HOMEPAGE_CATEGORY_STARRED' user=request.user as setting_category_starred %}
 | 
					{% settings_value 'HOMEPAGE_CATEGORY_STARRED' user=request.user as setting_category_starred %}
 | 
				
			||||||
@@ -93,6 +38,7 @@ addHeaderTitle('{% trans "Parts" %}');
 | 
				
			|||||||
{% if setting_part_starred %}
 | 
					{% if setting_part_starred %}
 | 
				
			||||||
addHeaderAction('starred-parts', '{% trans "Subscribed Parts" %}', 'fa-bell');
 | 
					addHeaderAction('starred-parts', '{% trans "Subscribed Parts" %}', 'fa-bell');
 | 
				
			||||||
loadSimplePartTable("#table-starred-parts", "{% url 'api-part-list' %}", {
 | 
					loadSimplePartTable("#table-starred-parts", "{% url 'api-part-list' %}", {
 | 
				
			||||||
 | 
					    name: 'starred-parts',
 | 
				
			||||||
    params: {
 | 
					    params: {
 | 
				
			||||||
        starred: true,
 | 
					        starred: true,
 | 
				
			||||||
        {% if hide_inactive %}
 | 
					        {% if hide_inactive %}
 | 
				
			||||||
@@ -116,6 +62,7 @@ loadPartCategoryTable($('#table-starred-categories'), {
 | 
				
			|||||||
{% if setting_part_latest %}
 | 
					{% if setting_part_latest %}
 | 
				
			||||||
addHeaderAction('latest-parts', '{% trans "Latest Parts" %}', 'fa-newspaper');
 | 
					addHeaderAction('latest-parts', '{% trans "Latest Parts" %}', 'fa-newspaper');
 | 
				
			||||||
loadSimplePartTable("#table-latest-parts", "{% url 'api-part-list' %}", {
 | 
					loadSimplePartTable("#table-latest-parts", "{% url 'api-part-list' %}", {
 | 
				
			||||||
 | 
					    name: 'latest-parts',
 | 
				
			||||||
    params: {
 | 
					    params: {
 | 
				
			||||||
        ordering: "-creation_date",
 | 
					        ordering: "-creation_date",
 | 
				
			||||||
        created_after: moment().subtract(1, 'months').format('YYYY-MM-DD'),
 | 
					        created_after: moment().subtract(1, 'months').format('YYYY-MM-DD'),
 | 
				
			||||||
@@ -130,6 +77,7 @@ loadSimplePartTable("#table-latest-parts", "{% url 'api-part-list' %}", {
 | 
				
			|||||||
{% if setting_bom_validation %}
 | 
					{% if setting_bom_validation %}
 | 
				
			||||||
addHeaderAction('bom-validation', '{% trans "BOM Waiting Validation" %}', 'fa-times-circle');
 | 
					addHeaderAction('bom-validation', '{% trans "BOM Waiting Validation" %}', 'fa-times-circle');
 | 
				
			||||||
loadSimplePartTable("#table-bom-validation", "{% url 'api-part-list' %}", {
 | 
					loadSimplePartTable("#table-bom-validation", "{% url 'api-part-list' %}", {
 | 
				
			||||||
 | 
					    name: 'parts-invalid-bom',
 | 
				
			||||||
    params: {
 | 
					    params: {
 | 
				
			||||||
        "bom_valid": false,
 | 
					        "bom_valid": false,
 | 
				
			||||||
        {% if hide_inactive %}
 | 
					        {% if hide_inactive %}
 | 
				
			||||||
@@ -158,6 +106,7 @@ loadSimplePartTable("#table-bom-validation", "{% url 'api-part-list' %}", {
 | 
				
			|||||||
{% if setting_stock_recent %}
 | 
					{% if setting_stock_recent %}
 | 
				
			||||||
addHeaderAction('recently-updated-stock', '{% trans "Recently Updated" %}', 'fa-clock');
 | 
					addHeaderAction('recently-updated-stock', '{% trans "Recently Updated" %}', 'fa-clock');
 | 
				
			||||||
loadStockTable($('#table-recently-updated-stock'), {
 | 
					loadStockTable($('#table-recently-updated-stock'), {
 | 
				
			||||||
 | 
					    disableFilters: true,
 | 
				
			||||||
    params: {
 | 
					    params: {
 | 
				
			||||||
        part_detail: true,
 | 
					        part_detail: true,
 | 
				
			||||||
        ordering: "-updated",
 | 
					        ordering: "-updated",
 | 
				
			||||||
@@ -170,6 +119,7 @@ loadStockTable($('#table-recently-updated-stock'), {
 | 
				
			|||||||
{% if setting_stock_low %}
 | 
					{% if setting_stock_low %}
 | 
				
			||||||
addHeaderAction('low-stock', '{% trans "Low Stock" %}', 'fa-flag');
 | 
					addHeaderAction('low-stock', '{% trans "Low Stock" %}', 'fa-flag');
 | 
				
			||||||
loadSimplePartTable("#table-low-stock", "{% url 'api-part-list' %}", {
 | 
					loadSimplePartTable("#table-low-stock", "{% url 'api-part-list' %}", {
 | 
				
			||||||
 | 
					    name: 'parts-low-stock',
 | 
				
			||||||
    params: {
 | 
					    params: {
 | 
				
			||||||
        low_stock: true,
 | 
					        low_stock: true,
 | 
				
			||||||
        {% if hide_inactive %}
 | 
					        {% if hide_inactive %}
 | 
				
			||||||
@@ -183,6 +133,7 @@ loadSimplePartTable("#table-low-stock", "{% url 'api-part-list' %}", {
 | 
				
			|||||||
{% if setting_stock_depleted %}
 | 
					{% if setting_stock_depleted %}
 | 
				
			||||||
addHeaderAction('depleted-stock', '{% trans "Depleted Stock" %}', 'fa-times');
 | 
					addHeaderAction('depleted-stock', '{% trans "Depleted Stock" %}', 'fa-times');
 | 
				
			||||||
loadSimplePartTable("#table-depleted-stock", "{% url 'api-part-list' %}", {
 | 
					loadSimplePartTable("#table-depleted-stock", "{% url 'api-part-list' %}", {
 | 
				
			||||||
 | 
					    name: 'parts-depleted-stock',
 | 
				
			||||||
    params: {
 | 
					    params: {
 | 
				
			||||||
        depleted_stock: true,
 | 
					        depleted_stock: true,
 | 
				
			||||||
        {% if hide_inactive %}
 | 
					        {% if hide_inactive %}
 | 
				
			||||||
@@ -195,15 +146,8 @@ loadSimplePartTable("#table-depleted-stock", "{% url 'api-part-list' %}", {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
{% if setting_stock_needed %}
 | 
					{% if setting_stock_needed %}
 | 
				
			||||||
addHeaderAction('stock-to-build', '{% trans "Required for Build Orders" %}', 'fa-bullhorn');
 | 
					addHeaderAction('stock-to-build', '{% trans "Required for Build Orders" %}', 'fa-bullhorn');
 | 
				
			||||||
loadSimplePartTable("#table-stock-to-build", "{% url 'api-part-list' %}", {
 | 
					
 | 
				
			||||||
    params: {
 | 
					loadRequiredForBuildsPartsTable("#table-stock-to-build", {});
 | 
				
			||||||
        stock_to_build: true,
 | 
					 | 
				
			||||||
        {% if hide_inactive %}
 | 
					 | 
				
			||||||
        active: true,
 | 
					 | 
				
			||||||
        {% endif %}
 | 
					 | 
				
			||||||
    },
 | 
					 | 
				
			||||||
    name: "to_build_parts",
 | 
					 | 
				
			||||||
});
 | 
					 | 
				
			||||||
{% endif %}
 | 
					{% endif %}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
{% if expiry %}
 | 
					{% if expiry %}
 | 
				
			||||||
@@ -211,6 +155,7 @@ loadSimplePartTable("#table-stock-to-build", "{% url 'api-part-list' %}", {
 | 
				
			|||||||
{% if setting_stock_expired %}
 | 
					{% if setting_stock_expired %}
 | 
				
			||||||
addHeaderAction('expired-stock', '{% trans "Expired Stock" %}', 'fa-calendar-times');
 | 
					addHeaderAction('expired-stock', '{% trans "Expired Stock" %}', 'fa-calendar-times');
 | 
				
			||||||
loadStockTable($("#table-expired-stock"), {
 | 
					loadStockTable($("#table-expired-stock"), {
 | 
				
			||||||
 | 
					    disableFilters: true,
 | 
				
			||||||
    params: {
 | 
					    params: {
 | 
				
			||||||
        expired: true,
 | 
					        expired: true,
 | 
				
			||||||
        location_detail: true,
 | 
					        location_detail: true,
 | 
				
			||||||
@@ -219,12 +164,14 @@ loadStockTable($("#table-expired-stock"), {
 | 
				
			|||||||
        active: true,
 | 
					        active: true,
 | 
				
			||||||
        {% endif %}
 | 
					        {% endif %}
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
 | 
					    name: 'expired-stock',
 | 
				
			||||||
});
 | 
					});
 | 
				
			||||||
{% endif %}
 | 
					{% endif %}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
{% if setting_stock_stale %}
 | 
					{% if setting_stock_stale %}
 | 
				
			||||||
addHeaderAction('stale-stock', '{% trans "Stale Stock" %}', 'fa-stopwatch');
 | 
					addHeaderAction('stale-stock', '{% trans "Stale Stock" %}', 'fa-stopwatch');
 | 
				
			||||||
loadStockTable($("#table-stale-stock"), {
 | 
					loadStockTable($("#table-stale-stock"), {
 | 
				
			||||||
 | 
					    disableFilters: true,
 | 
				
			||||||
    params: {
 | 
					    params: {
 | 
				
			||||||
        stale: true,
 | 
					        stale: true,
 | 
				
			||||||
        expired: false,
 | 
					        expired: false,
 | 
				
			||||||
@@ -234,6 +181,7 @@ loadStockTable($("#table-stale-stock"), {
 | 
				
			|||||||
        active: true,
 | 
					        active: true,
 | 
				
			||||||
        {% endif %}
 | 
					        {% endif %}
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
 | 
					    name: 'stale-stock',
 | 
				
			||||||
});
 | 
					});
 | 
				
			||||||
{% endif %}
 | 
					{% endif %}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -161,6 +161,7 @@
 | 
				
			|||||||
<script defer type='text/javascript' src="{% i18n_static 'filters.js' %}"></script>
 | 
					<script defer type='text/javascript' src="{% i18n_static 'filters.js' %}"></script>
 | 
				
			||||||
<script defer type='text/javascript' src="{% i18n_static 'forms.js' %}"></script>
 | 
					<script defer type='text/javascript' src="{% i18n_static 'forms.js' %}"></script>
 | 
				
			||||||
<script defer type='text/javascript' src="{% i18n_static 'helpers.js' %}"></script>
 | 
					<script defer type='text/javascript' src="{% i18n_static 'helpers.js' %}"></script>
 | 
				
			||||||
 | 
					<script defer type='text/javascript' src="{% i18n_static 'index.js' %}"></script>
 | 
				
			||||||
<script defer type='text/javascript' src="{% i18n_static 'label.js' %}"></script>
 | 
					<script defer type='text/javascript' src="{% i18n_static 'label.js' %}"></script>
 | 
				
			||||||
<script defer type='text/javascript' src="{% i18n_static 'modals.js' %}"></script>
 | 
					<script defer type='text/javascript' src="{% i18n_static 'modals.js' %}"></script>
 | 
				
			||||||
<script defer type='text/javascript' src="{% i18n_static 'model_renderers.js' %}"></script>
 | 
					<script defer type='text/javascript' src="{% i18n_static 'model_renderers.js' %}"></script>
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										135
									
								
								InvenTree/templates/js/translated/index.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										135
									
								
								InvenTree/templates/js/translated/index.js
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,135 @@
 | 
				
			|||||||
 | 
					{% load i18n %}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* globals
 | 
				
			||||||
 | 
					    addSidebarHeader,
 | 
				
			||||||
 | 
					    addSidebarItem,
 | 
				
			||||||
 | 
					    checkPermission,
 | 
				
			||||||
 | 
					    global_settings,
 | 
				
			||||||
 | 
					    imageHoverIcon,
 | 
				
			||||||
 | 
					    makeProgressBar,
 | 
				
			||||||
 | 
					    renderLink,
 | 
				
			||||||
 | 
					    shortenString,
 | 
				
			||||||
 | 
					    user_settings,
 | 
				
			||||||
 | 
					    withTitle,
 | 
				
			||||||
 | 
					*/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* exported
 | 
				
			||||||
 | 
					    addHeaderAction,
 | 
				
			||||||
 | 
					    addHeaderTitle,
 | 
				
			||||||
 | 
					*/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/*
 | 
				
			||||||
 | 
					 * Add a 'header title' to the index sidebar
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					function addHeaderTitle(title) {
 | 
				
			||||||
 | 
					    addSidebarHeader({
 | 
				
			||||||
 | 
					        text: title,
 | 
				
			||||||
 | 
					    });
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					function addHeaderAction(label, title, icon, options) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // Construct a "badge" to add to the sidebar item
 | 
				
			||||||
 | 
					    var badge = `
 | 
				
			||||||
 | 
					    <span id='sidebar-badge-${label}' class='sidebar-item-badge badge rounded-pill badge-right bg-dark'>
 | 
				
			||||||
 | 
					        <span class='fas fa-spin fa-spinner'></span>
 | 
				
			||||||
 | 
					    </span>
 | 
				
			||||||
 | 
					    `;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    addSidebarItem({
 | 
				
			||||||
 | 
					        label: label,
 | 
				
			||||||
 | 
					        text: title,
 | 
				
			||||||
 | 
					        icon: icon,
 | 
				
			||||||
 | 
					        content_after: badge
 | 
				
			||||||
 | 
					    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // Add a detail item to the detail item-panel
 | 
				
			||||||
 | 
					    $("#detail-panels").append(
 | 
				
			||||||
 | 
					        `<div class='panel panel-inventree panel-hidden' id='panel-${label}'>
 | 
				
			||||||
 | 
					            <div class='panel-heading'>
 | 
				
			||||||
 | 
					                <h4>${title}</h4>
 | 
				
			||||||
 | 
					            </div>
 | 
				
			||||||
 | 
					            <div class='panel-content'>
 | 
				
			||||||
 | 
					                <table class='table table-condensed table-striped' id='table-${label}'></table>
 | 
				
			||||||
 | 
					            </div>
 | 
				
			||||||
 | 
					        </div>`
 | 
				
			||||||
 | 
					    );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    let table_name = `#table-${label}`;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // Connect a callback to the table
 | 
				
			||||||
 | 
					    $(table_name).on('load-success.bs.table', function(data) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        let options = $(table_name).bootstrapTable('getOptions');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        let count = options.totalRows;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        let badge = $(`#sidebar-badge-${label}`);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        badge.html(count);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (count > 0) {
 | 
				
			||||||
 | 
					            badge.removeClass('bg-dark');
 | 
				
			||||||
 | 
					            badge.addClass('bg-primary');
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    });
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/*
 | 
				
			||||||
 | 
					 * Load a table displaying parts which are outstanding for builds
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					function loadRequiredForBuildsPartsTable(table, options={}) {
 | 
				
			||||||
 | 
					    let name = 'parts-required-for-builds';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    let params = {
 | 
				
			||||||
 | 
					        stock_to_build: true,
 | 
				
			||||||
 | 
					    };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    $(table).inventreeTable({
 | 
				
			||||||
 | 
					        url: '{% url "api-part-list" %}',
 | 
				
			||||||
 | 
					        queryParams: params,
 | 
				
			||||||
 | 
					        name: name,
 | 
				
			||||||
 | 
					        showColumns: false,
 | 
				
			||||||
 | 
					        search: false,
 | 
				
			||||||
 | 
					        sortable: false,
 | 
				
			||||||
 | 
					        formatNoMatches: function() {
 | 
				
			||||||
 | 
					            return '{% trans "No parts required for builds" %}';
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
 | 
					        columns: [
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                field: 'name',
 | 
				
			||||||
 | 
					                title: '{% trans "Part" %}',
 | 
				
			||||||
 | 
					                formatter: function(value, row) {
 | 
				
			||||||
 | 
					                    let name = shortenString(row.full_name);
 | 
				
			||||||
 | 
					                    let display= imageHoverIcon(row.thumbnail) + renderLink(name, `/part/${row.pk}/`);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    return withTitle(display, row.full_name);
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            },
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                field: 'description',
 | 
				
			||||||
 | 
					                title: '{% trans "Description" %}',
 | 
				
			||||||
 | 
					            },
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                field: 'total_in_stock',
 | 
				
			||||||
 | 
					                title: '{% trans "Available" %}',
 | 
				
			||||||
 | 
					                formatter: function(value, row) {
 | 
				
			||||||
 | 
					                    return value;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            },
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                field: 'allocated_to_build_orders',
 | 
				
			||||||
 | 
					                title: '{% trans "Allocated Stock" %}',
 | 
				
			||||||
 | 
					                formatter: function(_value, row) {
 | 
				
			||||||
 | 
					                    return makeProgressBar(
 | 
				
			||||||
 | 
					                        row.allocated_to_build_orders,
 | 
				
			||||||
 | 
					                        row.required_for_build_orders,
 | 
				
			||||||
 | 
					                    );
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            },
 | 
				
			||||||
 | 
					        ]
 | 
				
			||||||
 | 
					    });
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -2237,12 +2237,17 @@ function loadPartTable(table, url, options={}) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    options.params = options.params || {};
 | 
					    options.params = options.params || {};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    let table_name = options.name || 'parts';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // Ensure category detail is included
 | 
					    // Ensure category detail is included
 | 
				
			||||||
    options.params['category_detail'] = true;
 | 
					    options.params['category_detail'] = true;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    var params = options.params || {};
 | 
					    var params = options.params || {};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    var filters = loadTableFilters('parts', options.params);
 | 
					    let filters = {};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if (!options.disableFilters) {
 | 
				
			||||||
 | 
					        filters = loadTableFilters(table_name, options.params);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        setupFilterList('parts', $(table), options.filterTarget, {
 | 
					        setupFilterList('parts', $(table), options.filterTarget, {
 | 
				
			||||||
            download: true,
 | 
					            download: true,
 | 
				
			||||||
@@ -2261,6 +2266,7 @@ function loadPartTable(table, url, options={}) {
 | 
				
			|||||||
                }
 | 
					                }
 | 
				
			||||||
            ]
 | 
					            ]
 | 
				
			||||||
        });
 | 
					        });
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    var columns = [
 | 
					    var columns = [
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
@@ -2426,9 +2432,9 @@ function loadPartTable(table, url, options={}) {
 | 
				
			|||||||
    $(table).inventreeTable({
 | 
					    $(table).inventreeTable({
 | 
				
			||||||
        url: url,
 | 
					        url: url,
 | 
				
			||||||
        method: 'get',
 | 
					        method: 'get',
 | 
				
			||||||
 | 
					        name: table_name,
 | 
				
			||||||
        queryParams: filters,
 | 
					        queryParams: filters,
 | 
				
			||||||
        groupBy: false,
 | 
					        groupBy: false,
 | 
				
			||||||
        name: options.name || 'part',
 | 
					 | 
				
			||||||
        original: params,
 | 
					        original: params,
 | 
				
			||||||
        sidePagination: 'server',
 | 
					        sidePagination: 'server',
 | 
				
			||||||
        pagination: 'true',
 | 
					        pagination: 'true',
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1843,11 +1843,14 @@ function loadStockTable(table, options) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    var params = options.params || {};
 | 
					    var params = options.params || {};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    const filterTarget = options.filterTarget || '#filter-list-stock';
 | 
					    let filters = {};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if (!options.disableFilters) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        const filterTarget = options.filterTarget || '#filter-list-stock';
 | 
				
			||||||
        const filterKey = options.filterKey || options.name || 'stock';
 | 
					        const filterKey = options.filterKey || options.name || 'stock';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    let filters = loadTableFilters(filterKey, params);
 | 
					        filters = loadTableFilters(filterKey, params);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        setupFilterList(filterKey, table, filterTarget, {
 | 
					        setupFilterList(filterKey, table, filterTarget, {
 | 
				
			||||||
            download: true,
 | 
					            download: true,
 | 
				
			||||||
@@ -1881,6 +1884,7 @@ function loadStockTable(table, options) {
 | 
				
			|||||||
                }
 | 
					                }
 | 
				
			||||||
            ]
 | 
					            ]
 | 
				
			||||||
        });
 | 
					        });
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // Override the default values, or add new ones
 | 
					    // Override the default values, or add new ones
 | 
				
			||||||
    for (var key in params) {
 | 
					    for (var key in params) {
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user