mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Add result counter to quick search bar (#4524)
This commit is contained in:
parent
5481e63d69
commit
4006ccfa0d
@ -270,7 +270,7 @@ function updateSearch() {
|
|||||||
let result = response[resultType.key];
|
let result = response[resultType.key];
|
||||||
|
|
||||||
if (result.count != null && result.count > 0 && result.results) {
|
if (result.count != null && result.count > 0 && result.results) {
|
||||||
addSearchResults(result.results, resultType);
|
addSearchResults(result.results, resultType, result.count);
|
||||||
|
|
||||||
any_results = true;
|
any_results = true;
|
||||||
}
|
}
|
||||||
@ -337,7 +337,7 @@ function addSearchQuery(key, title, query_params, render_params={}) {
|
|||||||
|
|
||||||
|
|
||||||
// Add a group of results to the list
|
// Add a group of results to the list
|
||||||
function addSearchResults(results, resultType) {
|
function addSearchResults(results, resultType, resultCount) {
|
||||||
|
|
||||||
if (results.length == 0) {
|
if (results.length == 0) {
|
||||||
// Do not display this group, as there are no results
|
// Do not display this group, as there are no results
|
||||||
@ -354,12 +354,14 @@ function addSearchResults(results, resultType) {
|
|||||||
let renderer = resultType.renderer;
|
let renderer = resultType.renderer;
|
||||||
let renderParams = resultType.renderParams;
|
let renderParams = resultType.renderParams;
|
||||||
|
|
||||||
|
let resultText = resultCount == 1 ? '{% trans "result" %}' : '{% trans "results" %}';
|
||||||
|
|
||||||
// Add the result group to the panel
|
// Add the result group to the panel
|
||||||
panel.find('#search-results').append(`
|
panel.find('#search-results').append(`
|
||||||
<div class='search-result-group-wrapper' id='search-results-wrapper-${key}'>
|
<div class='search-result-group-wrapper' id='search-results-wrapper-${key}'>
|
||||||
<div class='search-result-group' id='search-results-${key}'>
|
<div class='search-result-group' id='search-results-${key}'>
|
||||||
<div class='search-result-header' style='display: flex;'>
|
<div class='search-result-header' style='display: flex;'>
|
||||||
<h5>${title}</h5>
|
<h5>${title}</h5><span class='float-right'><em><small> - ${resultCount} ${resultText}</small></em></span>
|
||||||
<span class='flex' style='flex-grow: 1;'></span>
|
<span class='flex' style='flex-grow: 1;'></span>
|
||||||
<div class='search-result-group-buttons btn-group float-right' role='group'>
|
<div class='search-result-group-buttons btn-group float-right' role='group'>
|
||||||
<button class='btn btn-outline-secondary' id='hide-results-${key}' title='{% trans "Minimize results" %}'>
|
<button class='btn btn-outline-secondary' id='hide-results-${key}' title='{% trans "Minimize results" %}'>
|
||||||
|
Loading…
Reference in New Issue
Block a user