diff --git a/InvenTree/InvenTree/static/css/inventree.css b/InvenTree/InvenTree/static/css/inventree.css
index 2e044d3e6f..a0053e5f53 100644
--- a/InvenTree/InvenTree/static/css/inventree.css
+++ b/InvenTree/InvenTree/static/css/inventree.css
@@ -497,6 +497,14 @@
background-color: #f33;
}
+.badge-orange {
+ background-color: #fcba03;
+}
+
+.badge-green {
+ background-color: #1A1;
+}
+
.part-thumb {
width: 200px;
height: 200px;
diff --git a/InvenTree/templates/InvenTree/index.html b/InvenTree/templates/InvenTree/index.html
index ff69bf16d7..687ceaf0ee 100644
--- a/InvenTree/templates/InvenTree/index.html
+++ b/InvenTree/templates/InvenTree/index.html
@@ -26,10 +26,6 @@ InvenTree | {% trans "Index" %}
{% endblock %}
-{% block js_load %}
-{{ block.super }}
-{% endblock %}
-
{% block js_ready %}
{{ block.super }}
@@ -78,7 +74,7 @@ function addHeaderAction(label, title, icon, options) {
// Remove css class from all action items
$("#action-item-list").children('li').each(function() {
$(this).removeClass('index-action-selected');
- })
+ });
// Add css class to the action we are interested in
$(`#action-${label}`).addClass('index-action-selected');
@@ -89,6 +85,10 @@ function addHeaderAction(label, title, icon, options) {
var count = $(`#table-${label}`).bootstrapTable('getData').length;
$(`#badge-${label}`).html(count);
+
+ if (count > 0) {
+ $(`#badge-${label}`).addClass('badge-orange');
+ }
});
}
diff --git a/InvenTree/templates/InvenTree/search.html b/InvenTree/templates/InvenTree/search.html
index d78204270a..4fc7442856 100644
--- a/InvenTree/templates/InvenTree/search.html
+++ b/InvenTree/templates/InvenTree/search.html
@@ -9,98 +9,123 @@ InvenTree | {% trans "Search Results" %}
{% block content %}
-
-{% include "search_form.html" with query_text=query %}
+
+ {% include "search_form.html" with query_text=query %}
-
-
-
{% if query %}
-
-
-
{% trans "No results found for " %}'{{ query }}'
-
-
-{% include "InvenTree/search_part_category.html" with collapse_id="categories" %}
-
-{% include "InvenTree/search_parts.html" with collapse_id='parts' %}
-
-{% include "InvenTree/search_company.html" with collapse_id='companies' %}
-
-{% include "InvenTree/search_supplier_parts.html" with collapse_id='supplier_parts' %}
-
-{% include "InvenTree/search_stock_location.html" with collapse_id="locations" %}
-
-{% include "InvenTree/search_stock_items.html" with collapse_id="stock" %}
-
{% else %}
-
-
{% trans "Enter a search query" %}
+ {% trans "Enter a search query" %}
-
{% endif %}
-{% endblock %}
+
+
+
+ -
+
+

+
+
+
+
-{% block js_load %}
-{{ block.super }}
-
{% endblock %}
{% block js_ready %}
{{ block.super }}
- function onSearchResults(table, output) {
+ function addItemTitle(title) {
+ // Add header block to the results list
+ $('#search-item-list').append(
+ `
${title}`
+ );
+ }
- $(table).on('load-success.bs.table', function() {
+ function addItem(label, title, icon, options) {
+ // Add a search itme to the action list
+ $('#search-item-list').append(
+ `
+
+
+ ${title}
+
+
+
+
+ `
+ );
- var panel = $(output).closest('.panel-group');
+ // Add a results table
+ $('#search-result-list').append(
+ `
+ ${title}
+
+ `
+ );
- var n = $(table).bootstrapTable('getData').length;
+ // Hide the results table
+ $(`#search-result-${label}`).hide();
- var text = '';
- if (n == 0) {
- text = '
No results'
+ // Add callback when the action is clicked
+ $(`#search-item-${label}`).click(function() {
- $(panel).hide();
+ // Hide all childs
+ $('#search-result-list').children('li').each(function() {
+ $(this).hide();
+ });
- } else {
- text = n + ' result';
+ // Show the one we want
+ $(`#search-result-${label}`).fadeIn();
- if (n > 1) {
- text += 's';
- }
+ // Remove css class from all action items
+ $("#search-item-list").children('li').each(function() {
+ $(this).removeClass('index-action-selected');
+ });
+
+ // Add css class to the action we are interested in
+ $(`#search-item-${label}`).addClass('index-action-selected');
+ });
- $(panel).show();
+ // Connect a callback to the table
+ $(`#table-${label}`).on('load-success.bs.table', function() {
+ var count = $(`#table-${label}`).bootstrapTable('getData').length;
- var collapse = panel.find('.panel-collapse');
+ $(`#badge-${label}`).html(count);
- collapse.collapse('show');
-
- $("#no-search-results").hide();
+ if (count > 0) {
+ $(`#badge-${label}`).addClass('badge-orange');
}
-
- $(output).html(`
${text}`);
});
}
- onSearchResults("#category-results-table", "#category-results-count");
-
- onSearchResults("#location-results-table", "#location-results-count");
-
- onSearchResults("#stock-results-table", "#stock-results-count");
-
- onSearchResults('#part-results-table', '#part-result-count');
+ {% if roles.part.view %}
+ addItemTitle('{% trans "Part" %}');
- onSearchResults('#company-results-table', '#company-result-count');
-
- onSearchResults('#supplier-part-results-table', '#supplier-part-result-count');
+ addItem('part', '{% trans "Parts" %}', 'fa-shapes');
- $("#category-results-table").inventreeTable({
+ loadPartTable("#table-part",
+ "{% url 'api-part-list' %}",
+ {
+ params: {
+ search: "{{ query }}",
+ },
+ checkbox: false,
+ disableFilters: true,
+ }
+ );
+
+ addItem('category', '{% trans "Part Categories" %}', 'fa-sitemap');
+
+ $("#table-category").inventreeTable({
url: "{% url 'api-part-category-list' %}",
queryParams: {
search: "{{ query }}",
@@ -120,7 +145,29 @@ InvenTree | {% trans "Search Results" %}
],
});
- $('#stock-results-table').inventreeTable({
+ addItem('supplier-part', '{% trans "Supplier Parts" %}', 'fa-pallet');
+
+ loadSupplierPartTable(
+ "#table-supplier-part",
+ "{% url 'api-supplier-part-list' %}",
+ {
+ params: {
+ search: "{{ query }}",
+ part_detail: true,
+ supplier_detail: true,
+ manufacturer_detail: true
+ },
+ }
+ );
+
+ {% endif %}
+
+ {% if roles.stock.view %}
+ addItemTitle('{% trans "Stock" %}');
+
+ addItem('stock', '{% trans "Stock Items" %}', 'fa-boxes');
+
+ $('#table-stock').inventreeTable({
url: "{% url 'api-stock-list' %}",
queryParams: {
search: "{{ query }}",
@@ -199,8 +246,9 @@ InvenTree | {% trans "Search Results" %}
]
});
+ addItem('location', '{% trans "Stock Locations" %}', 'fa-map-marker-alt');
- $("#location-results-table").inventreeTable({
+ $("#table-location").inventreeTable({
url: "{% url 'api-location-list' %}",
queryParams: {
search: "{{ query }}",
@@ -220,36 +268,48 @@ InvenTree | {% trans "Search Results" %}
],
});
+ {% endif %}
- loadPartTable("#part-results-table",
- "{% url 'api-part-list' %}",
- {
- params: {
- search: "{{ query }}",
- },
- checkbox: false,
- disableFilters: true,
- }
- );
-
+ {% if roles.purchase_order.view or roles.sales_order.view %}
+ addItemTitle('{% trans "Company" %}');
- loadCompanyTable('#company-results-table', "{% url 'api-company-list' %}", {
+ {% if roles.purchase_order.view %}
+ addItem('supplier', '{% trans "Suppliers" %}', 'fa-building');
+
+ loadCompanyTable('#table-supplier', "{% url 'api-company-list' %}", {
params: {
search: "{{ query }}",
+ is_supplier: "true",
}
});
- loadSupplierPartTable(
- "#supplier-part-results-table",
- "{% url 'api-supplier-part-list' %}",
- {
- params: {
- search: "{{ query }}",
- part_detail: true,
- supplier_detail: true,
- manufacturer_detail: true
- },
+ addItem('manufacturer', '{% trans "Manufacturers" %}', 'fa-industry');
+
+ loadCompanyTable('#table-manufacturer', "{% url 'api-company-list' %}", {
+ params: {
+ search: "{{ query }}",
+ is_manufacturer: "true",
}
- );
+ });
+
+
+ {% endif %}
+
+ {% if roles.sales_order.view %}
+ addItem('customer', '{% trans "Customers" %}', 'fa-user-tie');
+
+ loadCompanyTable('#table-customer', "{% url 'api-company-list' %}", {
+ params: {
+ search: "{{ query }}",
+ is_customer: "true",
+ }
+ });
+
+ {% endif %}
+
+ {% endif %}
+
+
+
{% endblock %}
\ No newline at end of file