diff --git a/InvenTree/part/templates/part/category.html b/InvenTree/part/templates/part/category.html index fd8f20d2aa..2d76b08ac9 100644 --- a/InvenTree/part/templates/part/category.html +++ b/InvenTree/part/templates/part/category.html @@ -156,6 +156,7 @@ {% endif %} }, buttons: ['#part-options'], + checkbox: true, }, ); diff --git a/InvenTree/static/script/inventree/part.js b/InvenTree/static/script/inventree/part.js index 1001ef11a1..7c933ef303 100644 --- a/InvenTree/static/script/inventree/part.js +++ b/InvenTree/static/script/inventree/part.js @@ -82,6 +82,7 @@ function loadPartTable(table, url, options={}) { * - url: Base URL for API query * - options: object containing following (optional) fields * allowInactive: If true, allow display of inactive parts + * checkbox: Show the checkbox column * query: extra query params for API request * buttons: If provided, link buttons to selection status of this table */ @@ -94,6 +95,84 @@ function loadPartTable(table, url, options={}) { query.active = true; } + var columns = [ + { + field: 'pk', + title: 'ID', + visible: false, + } + ]; + + if (options.checkbox) { + columns.push({ + checkbox: true, + title: 'Select', + searchable: false, + }); + } + + columns.push({ + field: 'full_name', + title: 'Part', + sortable: true, + formatter: function(value, row, index, field) { + + if (row.is_template) { + value = '' + value + ''; + } + + var display = imageHoverIcon(row.image_url) + renderLink(value, row.url); + + if (!row.active) { + display = display + "INACTIVE"; + } + return display; + } + }); + + columns.push({ + sortable: true, + field: 'description', + title: 'Description', + formatter: function(value, row, index, field) { + + if (row.is_template) { + value = '' + value + ''; + } + + return value; + } + }); + + columns.push({ + sortable: true, + field: 'category_name', + title: 'Category', + formatter: function(value, row, index, field) { + if (row.category) { + return renderLink(row.category_name, "/part/category/" + row.category + "/"); + } + else { + return ''; + } + } + }); + + columns.push({ + field: 'total_stock', + title: 'Stock', + searchable: false, + sortable: true, + formatter: function(value, row, index, field) { + if (value) { + return renderLink(value, row.url + 'stock/'); + } + else { + return "No Stock"; + } + } + }); + $(table).bootstrapTable({ url: url, sortable: true, @@ -107,76 +186,7 @@ function loadPartTable(table, url, options={}) { queryParams: function(p) { return query; }, - columns: [ - { - checkbox: true, - title: 'Select', - searchable: false, - }, - { - field: 'pk', - title: 'ID', - visible: false, - }, - { - field: 'full_name', - title: 'Part', - sortable: true, - formatter: function(value, row, index, field) { - - if (row.is_template) { - value = '' + value + ''; - } - - var display = imageHoverIcon(row.image_url) + renderLink(value, row.url); - - if (!row.active) { - display = display + "INACTIVE"; - } - return display; - } - }, - { - sortable: true, - field: 'description', - title: 'Description', - formatter: function(value, row, index, field) { - - if (row.is_template) { - value = '' + value + ''; - } - - return value; - } - }, - { - sortable: true, - field: 'category_name', - title: 'Category', - formatter: function(value, row, index, field) { - if (row.category) { - return renderLink(row.category_name, "/part/category/" + row.category + "/"); - } - else { - return ''; - } - } - }, - { - field: 'total_stock', - title: 'Stock', - searchable: false, - sortable: true, - formatter: function(value, row, index, field) { - if (value) { - return renderLink(value, row.url + 'stock/'); - } - else { - return "No Stock"; - } - } - } - ], + columns: columns, }); if (options.buttons) { diff --git a/InvenTree/templates/InvenTree/search.html b/InvenTree/templates/InvenTree/search.html index 7de08fd9b6..70915a49fd 100644 --- a/InvenTree/templates/InvenTree/search.html +++ b/InvenTree/templates/InvenTree/search.html @@ -17,6 +17,10 @@ InvenTree | Search Results


+
+

No results found

+
+ {% include "InvenTree/search_part_category.html" with collapse_id="categories" %} {% include "InvenTree/search_parts.html" with collapse_id='parts' %} @@ -35,10 +39,12 @@ InvenTree | Search Results {% block js_ready %} {{ block.super }} + $(".panel-group").hide(); + function onSearchResults(table, output) { $(table).on('load-success.bs.table', function() { - var panel = $(output).parent('.panel-group'); + var panel = $(output).closest('.panel-group'); var n = $(table).bootstrapTable('getData').length; @@ -47,8 +53,6 @@ InvenTree | Search Results text = 'No results' $(panel).hide(); - - $(table).hide(); } else { @@ -59,6 +63,8 @@ InvenTree | Search Results } $(panel).show(); + + $("#no-search-results").hide(); } $(output).html(text); @@ -120,6 +126,7 @@ InvenTree | Search Results search: "{{ query }}", }, allowInactive: true, + checkbox: false, } ); diff --git a/InvenTree/templates/search_form.html b/InvenTree/templates/search_form.html index 72d317d3ec..e9c2214731 100644 --- a/InvenTree/templates/search_form.html +++ b/InvenTree/templates/search_form.html @@ -3,5 +3,5 @@
- +