From 7ab58f683fcce9d75f11af3a8c7208bb1b76e6e9 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Thu, 16 Apr 2020 21:33:35 +1000 Subject: [PATCH 1/3] Fix search result tables --- InvenTree/part/templates/part/category.html | 47 ++++++++++--------- InvenTree/templates/InvenTree/search.html | 4 +- .../templates/InvenTree/search_parts.html | 6 +++ 3 files changed, 32 insertions(+), 25 deletions(-) diff --git a/InvenTree/part/templates/part/category.html b/InvenTree/part/templates/part/category.html index 63a60bd71e..9382259cce 100644 --- a/InvenTree/part/templates/part/category.html +++ b/InvenTree/part/templates/part/category.html @@ -137,29 +137,30 @@ $("#cat-create").click(function() { launchModalForm( - "{% url 'category-create' %}", - { - follow: true, - {% if category %} - data: { - category: {{ category.id }} - }, - {% endif %} - secondary: [ - { - field: 'default_location', - label: 'New Location', - title: 'Create new location', - url: "{% url 'stock-location-create' %}", - }, - { - field: 'parent', - label: 'New Category', - title: 'Create new category', - url: "{% url 'category-create' %}", - }, - ] - }); + "{% url 'category-create' %}", + { + follow: true, + {% if category %} + data: { + category: {{ category.id }} + }, + {% endif %} + secondary: [ + { + field: 'default_location', + label: 'New Location', + title: 'Create new location', + url: "{% url 'stock-location-create' %}", + }, + { + field: 'parent', + label: 'New Category', + title: 'Create new category', + url: "{% url 'category-create' %}", + }, + ] + } + ); }) $("#part-export").click(function() { diff --git a/InvenTree/templates/InvenTree/search.html b/InvenTree/templates/InvenTree/search.html index e8cda96809..99b704c626 100644 --- a/InvenTree/templates/InvenTree/search.html +++ b/InvenTree/templates/InvenTree/search.html @@ -127,7 +127,7 @@ InvenTree | {% trans "Search Results" %} loadPartTable("#part-results-table", "{% url 'api-part-list' %}", { - query: { + params: { search: "{{ query }}", }, allowInactive: true, @@ -137,7 +137,7 @@ InvenTree | {% trans "Search Results" %} loadCompanyTable('#company-results-table', "{% url 'api-company-list' %}", { params: { - serach: "{{ query }}", + search: "{{ query }}", } }); diff --git a/InvenTree/templates/InvenTree/search_parts.html b/InvenTree/templates/InvenTree/search_parts.html index 69c5c29051..f06155354d 100644 --- a/InvenTree/templates/InvenTree/search_parts.html +++ b/InvenTree/templates/InvenTree/search_parts.html @@ -9,6 +9,12 @@ {% endblock %} {% block collapse_content %} +
+
+
+
+
+
{% endblock %} \ No newline at end of file From 206d67337f033be1cc5a8fcf9a2258ba805b01bd Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Thu, 16 Apr 2020 21:41:45 +1000 Subject: [PATCH 2/3] Option to disable filters for part table --- InvenTree/InvenTree/static/script/inventree/part.js | 8 ++++++-- InvenTree/templates/InvenTree/search.html | 7 +++++-- InvenTree/templates/InvenTree/search_parts.html | 1 + 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/InvenTree/InvenTree/static/script/inventree/part.js b/InvenTree/InvenTree/static/script/inventree/part.js index 05328dbbd8..7954caa012 100644 --- a/InvenTree/InvenTree/static/script/inventree/part.js +++ b/InvenTree/InvenTree/static/script/inventree/part.js @@ -81,15 +81,19 @@ function loadPartTable(table, url, options={}) { * - table: HTML reference to the table * - 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 + * disableFilters: If true, disable custom filters */ var params = options.params || {}; - var filters = loadTableFilters("parts"); + var filters = {}; + + if (!options.disableFilters) { + filters = loadTableFilters("parts"); + } for (var key in params) { filters[key] = params[key]; diff --git a/InvenTree/templates/InvenTree/search.html b/InvenTree/templates/InvenTree/search.html index 99b704c626..76fd62b697 100644 --- a/InvenTree/templates/InvenTree/search.html +++ b/InvenTree/templates/InvenTree/search.html @@ -104,6 +104,7 @@ InvenTree | {% trans "Search Results" %} ], }); + $("#location-results-table").inventreeTable({ url: "{% url 'api-location-list' %}", queryParams: { @@ -124,16 +125,18 @@ InvenTree | {% trans "Search Results" %} ], }); + loadPartTable("#part-results-table", "{% url 'api-part-list' %}", { params: { search: "{{ query }}", }, - allowInactive: true, checkbox: false, + disableFilters: true, } ); + loadCompanyTable('#company-results-table', "{% url 'api-company-list' %}", { params: { @@ -153,5 +156,5 @@ InvenTree | {% trans "Search Results" %} }, } ); - + {% endblock %} \ No newline at end of file diff --git a/InvenTree/templates/InvenTree/search_parts.html b/InvenTree/templates/InvenTree/search_parts.html index f06155354d..ca75b096c2 100644 --- a/InvenTree/templates/InvenTree/search_parts.html +++ b/InvenTree/templates/InvenTree/search_parts.html @@ -11,6 +11,7 @@ {% block collapse_content %}
+
From 0ee53758b462580479afaa973f168bbab0bb1c75 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Thu, 16 Apr 2020 21:43:21 +1000 Subject: [PATCH 3/3] Add same optio for stock table --- InvenTree/InvenTree/static/script/inventree/stock.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/InvenTree/InvenTree/static/script/inventree/stock.js b/InvenTree/InvenTree/static/script/inventree/stock.js index bf0ddbef5e..d68d0946a2 100644 --- a/InvenTree/InvenTree/static/script/inventree/stock.js +++ b/InvenTree/InvenTree/static/script/inventree/stock.js @@ -41,6 +41,7 @@ function loadStockTable(table, options) { * groupByField - Column for grouping stock items * buttons - Which buttons to link to stock selection callbacks * filterList -
    element where filters are displayed + * disableFilters: If true, disable custom filters */ // List of user-params which override the default filters @@ -48,7 +49,11 @@ function loadStockTable(table, options) { var filterListElement = options.filterList || "#filter-list-stock"; - var filters = loadTableFilters("stock"); + var filters = {}; + + if (!options.disableFilters) { + filters = loadTableFilters("stock"); + } var original = {};