Bug fix for stock location table

(cherry picked from commit 44794d7b78520023e3b70da61dc13938bfd4bd14)
This commit is contained in:
Oliver 2021-11-03 13:27:58 +11:00
parent 08719d4d1b
commit c4ea3ecf6f
2 changed files with 31 additions and 24 deletions

View File

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

View File

@ -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,