mirror of
https://github.com/inventree/InvenTree.git
synced 2025-06-19 21:45:39 +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:
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,30 +2237,36 @@ function loadPartTable(table, url, options={}) {
|
||||
|
||||
options.params = options.params || {};
|
||||
|
||||
let table_name = options.name || 'parts';
|
||||
|
||||
// Ensure category detail is included
|
||||
options.params['category_detail'] = true;
|
||||
|
||||
var params = options.params || {};
|
||||
|
||||
var filters = loadTableFilters('parts', options.params);
|
||||
let filters = {};
|
||||
|
||||
setupFilterList('parts', $(table), options.filterTarget, {
|
||||
download: true,
|
||||
labels: {
|
||||
url: '{% url "api-part-label-list" %}',
|
||||
key: 'part',
|
||||
},
|
||||
singular_name: '{% trans "part" %}',
|
||||
plural_name: '{% trans "parts" %}',
|
||||
custom_actions: [
|
||||
{
|
||||
label: 'parts',
|
||||
icon: 'fa-tools',
|
||||
title: '{% trans "Part actions" %}',
|
||||
actions: makePartActions(table),
|
||||
}
|
||||
]
|
||||
});
|
||||
if (!options.disableFilters) {
|
||||
filters = loadTableFilters(table_name, options.params);
|
||||
|
||||
setupFilterList('parts', $(table), options.filterTarget, {
|
||||
download: true,
|
||||
labels: {
|
||||
url: '{% url "api-part-label-list" %}',
|
||||
key: 'part',
|
||||
},
|
||||
singular_name: '{% trans "part" %}',
|
||||
plural_name: '{% trans "parts" %}',
|
||||
custom_actions: [
|
||||
{
|
||||
label: 'parts',
|
||||
icon: 'fa-tools',
|
||||
title: '{% trans "Part actions" %}',
|
||||
actions: makePartActions(table),
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
var columns = [
|
||||
{
|
||||
@ -2426,9 +2432,9 @@ function loadPartTable(table, url, options={}) {
|
||||
$(table).inventreeTable({
|
||||
url: url,
|
||||
method: 'get',
|
||||
name: table_name,
|
||||
queryParams: filters,
|
||||
groupBy: false,
|
||||
name: options.name || 'part',
|
||||
original: params,
|
||||
sidePagination: 'server',
|
||||
pagination: 'true',
|
||||
|
@ -1843,44 +1843,48 @@ function loadStockTable(table, options) {
|
||||
|
||||
var params = options.params || {};
|
||||
|
||||
const filterTarget = options.filterTarget || '#filter-list-stock';
|
||||
let filters = {};
|
||||
|
||||
const filterKey = options.filterKey || options.name || 'stock';
|
||||
if (!options.disableFilters) {
|
||||
|
||||
let filters = loadTableFilters(filterKey, params);
|
||||
const filterTarget = options.filterTarget || '#filter-list-stock';
|
||||
const filterKey = options.filterKey || options.name || 'stock';
|
||||
|
||||
setupFilterList(filterKey, table, filterTarget, {
|
||||
download: true,
|
||||
report: {
|
||||
url: '{% url "api-stockitem-testreport-list" %}',
|
||||
key: 'item',
|
||||
},
|
||||
labels: {
|
||||
url: '{% url "api-stockitem-label-list" %}',
|
||||
key: 'item',
|
||||
},
|
||||
singular_name: '{% trans "stock item" %}',
|
||||
plural_name: '{% trans "stock items" %}',
|
||||
barcode_actions: [
|
||||
{
|
||||
icon: 'fa-sitemap',
|
||||
label: 'scantolocation',
|
||||
title: '{% trans "Scan to location" %}',
|
||||
permission: 'stock.change',
|
||||
callback: function(items) {
|
||||
scanItemsIntoLocation(items);
|
||||
filters = loadTableFilters(filterKey, params);
|
||||
|
||||
setupFilterList(filterKey, table, filterTarget, {
|
||||
download: true,
|
||||
report: {
|
||||
url: '{% url "api-stockitem-testreport-list" %}',
|
||||
key: 'item',
|
||||
},
|
||||
labels: {
|
||||
url: '{% url "api-stockitem-label-list" %}',
|
||||
key: 'item',
|
||||
},
|
||||
singular_name: '{% trans "stock item" %}',
|
||||
plural_name: '{% trans "stock items" %}',
|
||||
barcode_actions: [
|
||||
{
|
||||
icon: 'fa-sitemap',
|
||||
label: 'scantolocation',
|
||||
title: '{% trans "Scan to location" %}',
|
||||
permission: 'stock.change',
|
||||
callback: function(items) {
|
||||
scanItemsIntoLocation(items);
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
custom_actions: [
|
||||
{
|
||||
actions: makeStockActions(table),
|
||||
icon: 'fa-boxes',
|
||||
title: '{% trans "Stock Actions" %}',
|
||||
label: 'stock',
|
||||
}
|
||||
]
|
||||
});
|
||||
],
|
||||
custom_actions: [
|
||||
{
|
||||
actions: makeStockActions(table),
|
||||
icon: 'fa-boxes',
|
||||
title: '{% trans "Stock Actions" %}',
|
||||
label: 'stock',
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
// Override the default values, or add new ones
|
||||
for (var key in params) {
|
||||
|
Reference in New Issue
Block a user