From c4ea3ecf6fc3eb4e2db69c16218ac44b2d219cf0 Mon Sep 17 00:00:00 2001 From: Oliver Date: Wed, 3 Nov 2021 13:27:58 +1100 Subject: [PATCH 1/4] Bug fix for stock location table (cherry picked from commit 44794d7b78520023e3b70da61dc13938bfd4bd14) --- InvenTree/stock/templates/stock/location.html | 3 +- InvenTree/templates/js/translated/stock.js | 52 +++++++++++-------- 2 files changed, 31 insertions(+), 24 deletions(-) diff --git a/InvenTree/stock/templates/stock/location.html b/InvenTree/stock/templates/stock/location.html index 7490d262bd..521a7bdca8 100644 --- a/InvenTree/stock/templates/stock/location.html +++ b/InvenTree/stock/templates/stock/location.html @@ -183,7 +183,8 @@ {% else %} parent: 'null', {% endif %} - } + }, + allowTreeView: true, }); linkButtonsToSelection( diff --git a/InvenTree/templates/js/translated/stock.js b/InvenTree/templates/js/translated/stock.js index 62e765b25b..04a27f6682 100644 --- a/InvenTree/templates/js/translated/stock.js +++ b/InvenTree/templates/js/translated/stock.js @@ -1416,8 +1416,11 @@ function loadStockTable(table, options) { }); } + +/* + * Display a table of stock locations + */ function loadStockLocationTable(table, options) { - /* Display a table of stock locations */ var params = options.params || {}; @@ -1443,15 +1446,15 @@ function loadStockLocationTable(table, options) { filters[key] = params[key]; } - var tree_view = inventreeLoad('location-tree-view') == 1; + var tree_view = options.allowTreeView && inventreeLoad('location-tree-view') == 1; table.inventreeTable({ - treeEnable: tree_view, + treeEnable: options.allowTreeView && tree_view, rootParentId: options.params.parent, uniqueId: 'pk', idField: 'pk', treeShowField: 'name', - parentIdField: 'parent', + parentIdField: tree_view ? 'parent' : null, disablePagination: tree_view, sidePagination: tree_view ? 'client' : 'server', serverSort: !tree_view, @@ -1465,28 +1468,31 @@ function loadStockLocationTable(table, options) { showColumns: true, 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'); - $('#view-location-tree').removeClass('btn-outline-secondary').addClass('btn-secondary'); - - table.treegrid({ - treeColumn: 1, - onChange: function() { - table.bootstrapTable('resetView'); - }, - onExpand: function() { - - } - }); - } else { - $('#view-location-tree').removeClass('btn-secondary').addClass('btn-outline-secondary'); - $('#view-location-list').removeClass('btn-outline-secondary').addClass('btn-secondary'); + if (tree_view) { + + $('#view-location-list').removeClass('btn-secondary').addClass('btn-outline-secondary'); + $('#view-location-tree').removeClass('btn-outline-secondary').addClass('btn-secondary'); + + table.treegrid({ + treeColumn: 1, + onChange: function() { + table.bootstrapTable('resetView'); + }, + 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', attributes: { @@ -1525,7 +1531,7 @@ function loadStockLocationTable(table, options) { ); } } - ], + ] : [], columns: [ { checkbox: true, From 08ffa102c627b5ad6b4cf83c5183060dc3f2dd33 Mon Sep 17 00:00:00 2001 From: Oliver Date: Wed, 3 Nov 2021 13:33:38 +1100 Subject: [PATCH 2/4] Fixes for part category table (cherry picked from commit f7ef309995f8a52c213748f4a9226724e288c936) --- InvenTree/part/templates/part/category.html | 3 +- InvenTree/templates/js/translated/part.js | 51 +++++++++++---------- InvenTree/templates/js/translated/stock.js | 4 +- 3 files changed, 32 insertions(+), 26 deletions(-) diff --git a/InvenTree/part/templates/part/category.html b/InvenTree/part/templates/part/category.html index 6672adf210..03369b093d 100644 --- a/InvenTree/part/templates/part/category.html +++ b/InvenTree/part/templates/part/category.html @@ -210,7 +210,8 @@ {% else %} parent: null, {% endif %} - } + }, + allowTreeView: true, } ); diff --git a/InvenTree/templates/js/translated/part.js b/InvenTree/templates/js/translated/part.js index ec72d2682c..44295e67ea 100644 --- a/InvenTree/templates/js/translated/part.js +++ b/InvenTree/templates/js/translated/part.js @@ -1133,8 +1133,10 @@ function loadPartTable(table, url, options={}) { } +/* + * Display a table of part categories + */ function loadPartCategoryTable(table, options) { - /* Display a table of part categories */ var params = options.params || {}; @@ -1157,15 +1159,15 @@ function loadPartCategoryTable(table, options) { setupFilterList(filterKey, table, filterListElement); - var tree_view = inventreeLoad('category-tree-view') == 1; + var tree_view = options.allowTreeView && inventreeLoad('category-tree-view') == 1; table.inventreeTable({ treeEnable: tree_view, - rootParentId: options.params.parent, + rootParentId: tree_view ? options.params.parent : null, uniqueId: 'pk', idField: 'pk', treeShowField: 'name', - parentIdField: 'parent', + parentIdField: tree_view ? 'parent' : null, method: 'get', url: options.url || '{% url "api-part-category-list" %}', queryParams: filters, @@ -1176,7 +1178,7 @@ function loadPartCategoryTable(table, options) { name: 'category', original: original, showColumns: true, - buttons: [ + buttons: options.allowTreeView ? [ { icon: 'fas fa-bars', attributes: { @@ -1215,28 +1217,31 @@ function loadPartCategoryTable(table, options) { ); } } - ], + ] : [], 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'); - $('#view-category-tree').removeClass('btn-outline-secondary').addClass('btn-secondary'); - - table.treegrid({ - treeColumn: 0, - onChange: function() { - table.bootstrapTable('resetView'); - }, - onExpand: function() { - - } - }); - } else { - $('#view-category-tree').removeClass('btn-secondary').addClass('btn-outline-secondary'); - $('#view-category-list').removeClass('btn-outline-secondary').addClass('btn-secondary'); + if (tree_view) { + + $('#view-category-list').removeClass('btn-secondary').addClass('btn-outline-secondary'); + $('#view-category-tree').removeClass('btn-outline-secondary').addClass('btn-secondary'); + + table.treegrid({ + treeColumn: 0, + onChange: function() { + table.bootstrapTable('resetView'); + }, + onExpand: function() { + + } + }); + } else { + $('#view-category-tree').removeClass('btn-secondary').addClass('btn-outline-secondary'); + $('#view-category-list').removeClass('btn-outline-secondary').addClass('btn-secondary'); + } } }, columns: [ diff --git a/InvenTree/templates/js/translated/stock.js b/InvenTree/templates/js/translated/stock.js index 04a27f6682..261cb4d1d6 100644 --- a/InvenTree/templates/js/translated/stock.js +++ b/InvenTree/templates/js/translated/stock.js @@ -1449,8 +1449,8 @@ function loadStockLocationTable(table, options) { var tree_view = options.allowTreeView && inventreeLoad('location-tree-view') == 1; table.inventreeTable({ - treeEnable: options.allowTreeView && tree_view, - rootParentId: options.params.parent, + treeEnable: tree_view, + rootParentId: tree_view ? options.params.parent : null, uniqueId: 'pk', idField: 'pk', treeShowField: 'name', From d435689562f996d4e393403d0c260a08d933862f Mon Sep 17 00:00:00 2001 From: Oliver Date: Wed, 3 Nov 2021 13:57:50 +1100 Subject: [PATCH 3/4] Add more information to the "part details" tab --- InvenTree/part/templates/part/detail.html | 32 +++++++++++++++++------ 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/InvenTree/part/templates/part/detail.html b/InvenTree/part/templates/part/detail.html index e45e7e14b8..1bc4b9b967 100644 --- a/InvenTree/part/templates/part/detail.html +++ b/InvenTree/part/templates/part/detail.html @@ -20,13 +20,6 @@ - {% if part.IPN %} - - - - - - {% endif %} @@ -37,6 +30,13 @@ + {% if part.IPN %} + + + + + + {% endif %} {% if part.revision %} @@ -44,6 +44,20 @@ {% endif %} + {% if part.units %} + + + + + + {% endif %} + {% if part.minimum_stock %} + + + + + + {% endif %} {% if part.keywords %} @@ -79,7 +93,9 @@ - + {% endif %} {% if part.default_supplier %} From 31ea71d3913f6be45922f7cc65e6ba0593838107 Mon Sep 17 00:00:00 2001 From: Oliver Date: Wed, 3 Nov 2021 14:00:13 +1100 Subject: [PATCH 4/4] Display part category --- InvenTree/part/templates/part/detail.html | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/InvenTree/part/templates/part/detail.html b/InvenTree/part/templates/part/detail.html index 1bc4b9b967..fc9795b6e0 100644 --- a/InvenTree/part/templates/part/detail.html +++ b/InvenTree/part/templates/part/detail.html @@ -30,6 +30,15 @@ + {% if part.category %} + + + + + + {% endif %} {% if part.IPN %}
{% trans "IPN" %}{{ part.IPN }}{% include "clip.html"%}
{% trans "Name" %}{% trans "Description" %} {{ part.description }}{% include "clip.html"%}
{% trans "IPN" %}{{ part.IPN }}{% include "clip.html"%}
{{ part.revision }}{% include "clip.html"%}
{% trans "Units" %}{{ part.units }}
{% trans "Minimum stock level" %}{{ part.minimum_stock }}
{% trans "Default Location" %}{{ part.default_location }} + {{ part.default_location }} +
{% trans "Description" %} {{ part.description }}{% include "clip.html"%}
{% trans "Category" %} + {{ part.category }} +