2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-04-30 20:46:47 +00:00

Merge remote-tracking branch 'inventree/master' into stock-item-forms

This commit is contained in:
Oliver 2021-11-03 15:46:30 +11:00
commit e5435df2ba
5 changed files with 94 additions and 56 deletions

View File

@ -210,7 +210,8 @@
{% else %} {% else %}
parent: null, parent: null,
{% endif %} {% endif %}
} },
allowTreeView: true,
} }
); );

View File

@ -20,13 +20,6 @@
<!-- Details Table --> <!-- Details Table -->
<table class="table table-striped table-condensed"> <table class="table table-striped table-condensed">
<col width='25'> <col width='25'>
{% if part.IPN %}
<tr>
<td><span class='fas fa-tag'></span></td>
<td>{% trans "IPN" %}</td>
<td>{{ part.IPN }}{% include "clip.html"%}</td>
</tr>
{% endif %}
<tr> <tr>
<td><span class='fas fa-shapes'></span></td> <td><span class='fas fa-shapes'></span></td>
<td>{% trans "Name" %}</td> <td>{% trans "Name" %}</td>
@ -37,6 +30,22 @@
<td>{% trans "Description" %}</td> <td>{% trans "Description" %}</td>
<td>{{ part.description }}{% include "clip.html"%}</td> <td>{{ part.description }}{% include "clip.html"%}</td>
</tr> </tr>
{% if part.category %}
<tr>
<td><span class='fas fa-sitemap'></span></td>
<td>{% trans "Category" %}</td>
<td>
<a href='{% url "category-detail" part.category.pk %}'>{{ part.category }}</a>
</td>
</tr>
{% endif %}
{% if part.IPN %}
<tr>
<td><span class='fas fa-tag'></span></td>
<td>{% trans "IPN" %}</td>
<td>{{ part.IPN }}{% include "clip.html"%}</td>
</tr>
{% endif %}
{% if part.revision %} {% if part.revision %}
<tr> <tr>
<td><span class='fas fa-code-branch'></span></td> <td><span class='fas fa-code-branch'></span></td>
@ -44,6 +53,20 @@
<td>{{ part.revision }}{% include "clip.html"%}</td> <td>{{ part.revision }}{% include "clip.html"%}</td>
</tr> </tr>
{% endif %} {% endif %}
{% if part.units %}
<tr>
<td></td>
<td>{% trans "Units" %}</td>
<td>{{ part.units }}</td>
</tr>
{% endif %}
{% if part.minimum_stock %}
<tr>
<td><span class='fas fa-less-than-equal'></span></td>
<td>{% trans "Minimum stock level" %}</td>
<td>{{ part.minimum_stock }}</td>
</tr>
{% endif %}
{% if part.keywords %} {% if part.keywords %}
<tr> <tr>
<td><span class='fas fa-key'></span></td> <td><span class='fas fa-key'></span></td>
@ -79,7 +102,9 @@
<tr> <tr>
<td><span class='fas fa-search-location'></span></td> <td><span class='fas fa-search-location'></span></td>
<td>{% trans "Default Location" %}</td> <td>{% trans "Default Location" %}</td>
<td>{{ part.default_location }}</td> <td>
<a href='{% url "stock-location-detail" part.default_location.pk %}'>{{ part.default_location }}</a>
</td>
</tr> </tr>
{% endif %} {% endif %}
{% if part.default_supplier %} {% if part.default_supplier %}

View File

@ -191,7 +191,8 @@
{% else %} {% else %}
parent: 'null', parent: 'null',
{% endif %} {% endif %}
} },
allowTreeView: true,
}); });
linkButtonsToSelection( linkButtonsToSelection(

View File

@ -1133,8 +1133,10 @@ function loadPartTable(table, url, options={}) {
} }
/*
* Display a table of part categories
*/
function loadPartCategoryTable(table, options) { function loadPartCategoryTable(table, options) {
/* Display a table of part categories */
var params = options.params || {}; var params = options.params || {};
@ -1157,15 +1159,15 @@ function loadPartCategoryTable(table, options) {
setupFilterList(filterKey, table, filterListElement); setupFilterList(filterKey, table, filterListElement);
var tree_view = inventreeLoad('category-tree-view') == 1; var tree_view = options.allowTreeView && inventreeLoad('category-tree-view') == 1;
table.inventreeTable({ table.inventreeTable({
treeEnable: tree_view, treeEnable: tree_view,
rootParentId: options.params.parent, rootParentId: tree_view ? options.params.parent : null,
uniqueId: 'pk', uniqueId: 'pk',
idField: 'pk', idField: 'pk',
treeShowField: 'name', treeShowField: 'name',
parentIdField: 'parent', parentIdField: tree_view ? 'parent' : null,
method: 'get', method: 'get',
url: options.url || '{% url "api-part-category-list" %}', url: options.url || '{% url "api-part-category-list" %}',
queryParams: filters, queryParams: filters,
@ -1176,7 +1178,7 @@ function loadPartCategoryTable(table, options) {
name: 'category', name: 'category',
original: original, original: original,
showColumns: true, showColumns: true,
buttons: [ buttons: options.allowTreeView ? [
{ {
icon: 'fas fa-bars', icon: 'fas fa-bars',
attributes: { attributes: {
@ -1215,28 +1217,31 @@ function loadPartCategoryTable(table, options) {
); );
} }
} }
], ] : [],
onPostBody: function() { onPostBody: function() {
tree_view = inventreeLoad('category-tree-view') == 1; if (options.allowTreeView) {
if (tree_view) { tree_view = inventreeLoad('category-tree-view') == 1;
$('#view-category-list').removeClass('btn-secondary').addClass('btn-outline-secondary'); if (tree_view) {
$('#view-category-tree').removeClass('btn-outline-secondary').addClass('btn-secondary');
table.treegrid({ $('#view-category-list').removeClass('btn-secondary').addClass('btn-outline-secondary');
treeColumn: 0, $('#view-category-tree').removeClass('btn-outline-secondary').addClass('btn-secondary');
onChange: function() {
table.bootstrapTable('resetView');
},
onExpand: function() {
} table.treegrid({
}); treeColumn: 0,
} else { onChange: function() {
$('#view-category-tree').removeClass('btn-secondary').addClass('btn-outline-secondary'); table.bootstrapTable('resetView');
$('#view-category-list').removeClass('btn-outline-secondary').addClass('btn-secondary'); },
onExpand: function() {
}
});
} else {
$('#view-category-tree').removeClass('btn-secondary').addClass('btn-outline-secondary');
$('#view-category-list').removeClass('btn-outline-secondary').addClass('btn-secondary');
}
} }
}, },
columns: [ columns: [

View File

@ -1669,8 +1669,11 @@ function loadStockTable(table, options) {
}); });
} }
/*
* Display a table of stock locations
*/
function loadStockLocationTable(table, options) { function loadStockLocationTable(table, options) {
/* Display a table of stock locations */
var params = options.params || {}; var params = options.params || {};
@ -1696,15 +1699,15 @@ function loadStockLocationTable(table, options) {
filters[key] = params[key]; filters[key] = params[key];
} }
var tree_view = inventreeLoad('location-tree-view') == 1; var tree_view = options.allowTreeView && inventreeLoad('location-tree-view') == 1;
table.inventreeTable({ table.inventreeTable({
treeEnable: tree_view, treeEnable: tree_view,
rootParentId: options.params.parent, rootParentId: tree_view ? options.params.parent : null,
uniqueId: 'pk', uniqueId: 'pk',
idField: 'pk', idField: 'pk',
treeShowField: 'name', treeShowField: 'name',
parentIdField: 'parent', parentIdField: tree_view ? 'parent' : null,
disablePagination: tree_view, disablePagination: tree_view,
sidePagination: tree_view ? 'client' : 'server', sidePagination: tree_view ? 'client' : 'server',
serverSort: !tree_view, serverSort: !tree_view,
@ -1718,28 +1721,31 @@ function loadStockLocationTable(table, options) {
showColumns: true, showColumns: true,
onPostBody: function() { onPostBody: function() {
tree_view = inventreeLoad('location-tree-view') == 1; if (options.allowTreeView) {
if (tree_view) { tree_view = inventreeLoad('location-tree-view') == 1;
$('#view-location-list').removeClass('btn-secondary').addClass('btn-outline-secondary'); if (tree_view) {
$('#view-location-tree').removeClass('btn-outline-secondary').addClass('btn-secondary');
table.treegrid({ $('#view-location-list').removeClass('btn-secondary').addClass('btn-outline-secondary');
treeColumn: 1, $('#view-location-tree').removeClass('btn-outline-secondary').addClass('btn-secondary');
onChange: function() {
table.bootstrapTable('resetView');
},
onExpand: function() {
} table.treegrid({
}); treeColumn: 1,
} else { onChange: function() {
$('#view-location-tree').removeClass('btn-secondary').addClass('btn-outline-secondary'); table.bootstrapTable('resetView');
$('#view-location-list').removeClass('btn-outline-secondary').addClass('btn-secondary'); },
onExpand: function() {
}
});
} else {
$('#view-location-tree').removeClass('btn-secondary').addClass('btn-outline-secondary');
$('#view-location-list').removeClass('btn-outline-secondary').addClass('btn-secondary');
}
} }
}, },
buttons: [ buttons: options.allowTreeView ? [
{ {
icon: 'fas fa-bars', icon: 'fas fa-bars',
attributes: { attributes: {
@ -1778,7 +1784,7 @@ function loadStockLocationTable(table, options) {
); );
} }
} }
], ] : [],
columns: [ columns: [
{ {
checkbox: true, checkbox: true,