From 74c8b6768da1dd22ba0f4ecdba82296407eb39d9 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Tue, 14 May 2019 15:43:16 +1000 Subject: [PATCH] BOM table fixes - Reorder columns - Allow proper part name filtering --- InvenTree/static/script/inventree/bom.js | 49 ++++++++++++------------ 1 file changed, 25 insertions(+), 24 deletions(-) diff --git a/InvenTree/static/script/inventree/bom.js b/InvenTree/static/script/inventree/bom.js index eaa1d40d3d..7d7fe6ab28 100644 --- a/InvenTree/static/script/inventree/bom.js +++ b/InvenTree/static/script/inventree/bom.js @@ -89,11 +89,11 @@ function loadBomTable(table, options) { // Part column cols.push( { - field: 'sub_part_detail', + field: 'sub_part_detail.full_name', title: 'Part', sortable: true, formatter: function(value, row, index, field) { - return imageHoverIcon(value.image_url) + renderLink(value.full_name, value.url); + return imageHoverIcon(row.sub_part_detail.image_url) + renderLink(row.sub_part_detail.full_name, row.sub_part_detail.url); } } ); @@ -115,29 +115,8 @@ function loadBomTable(table, options) { sortable: true, } ); - - // Part notes - cols.push( - { - field: 'note', - title: 'Notes', - searchable: true, - sortable: true, - } - ); - if (options.editable) { - cols.push({ - formatter: function(value, row, index, field) { - var bEdit = ""; - var bDelt = ""; - - return "
" + bEdit + bDelt + "
"; - } - }); - } - - else { + if (!options.editable) { cols.push( { field: 'sub_part_detail.available_stock', @@ -161,6 +140,27 @@ function loadBomTable(table, options) { } ); } + + // Part notes + cols.push( + { + field: 'note', + title: 'Notes', + searchable: true, + sortable: true, + } + ); + + if (options.editable) { + cols.push({ + formatter: function(value, row, index, field) { + var bEdit = ""; + var bDelt = ""; + + return "
" + bEdit + bDelt + "
"; + } + }); + } // Configure the table (bootstrap-table) @@ -172,6 +172,7 @@ function loadBomTable(table, options) { queryParams: function(p) { return { part: options.parent_id, + ordering: 'name', } }, columns: cols,