Add option to hide inactive parts in search preview window

This commit is contained in:
Oliver 2021-11-04 22:25:35 +11:00
parent ceba5b7312
commit 71bb6fff50
4 changed files with 22 additions and 5 deletions

View File

@ -563,6 +563,7 @@
.search-autocomplete-item {
border-top: 1px solid #EEE;
margin-bottom: 2px;
overflow-x: hidden;
}
.modal {

View File

@ -131,13 +131,21 @@ function inventreeDocReady() {
if ($('#search-bar').exists()) {
$('#search-bar').autocomplete({
source: function(request, response) {
var params = {
search: request.term,
limit: user_settings.SEARCH_PREVIEW_RESULTS,
offset: 0,
};
if (user_settings.SEARCH_HIDE_INACTIVE_PARTS) {
// Limit to active parts
params.active = true;
}
$.ajax({
url: '/api/part/',
data: {
search: request.term,
limit: user_settings.SEARCH_PREVIEW_RESULTS,
offset: 0
},
data: params,
success: function(data) {
var transformed = $.map(data.results, function(el) {

View File

@ -1012,6 +1012,13 @@ class InvenTreeUserSetting(BaseInvenTreeSetting):
'validator': bool,
},
'SEARCH_HIDE_INACTIVE_PARTS': {
'name': _("Hide Inactive Parts"),
'description': _('Hide inactive parts in search preview window'),
'default': False,
'validator': bool,
},
'PART_SHOW_QUANTITY_IN_FORMS': {
'name': _('Show Quantity in Forms'),
'description': _('Display available part quantity in some forms'),

View File

@ -16,6 +16,7 @@
<tbody>
{% include "InvenTree/settings/setting.html" with key="SEARCH_PREVIEW_RESULTS" user_setting=True icon='fa-search' %}
{% include "InvenTree/settings/setting.html" with key="SEARCH_SHOW_STOCK_LEVELS" user_setting=True icon='fa-boxes' %}
{% include "InvenTree/settings/setting.html" with key="SEARCH_HIDE_INACTIVE_PARTS" user_setting=True icon='fa-eye-slash' %}
</tbody>
</table>
</div>