2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-04-29 03:56:43 +00:00

Merge pull request #2252 from SchrodingersGat/hide-inactive

Add option to hide inactive parts in search preview window
This commit is contained in:
Oliver 2021-11-04 23:06:54 +11:00 committed by GitHub
commit ce30b852e7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 22 additions and 5 deletions

View File

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

View File

@ -131,13 +131,21 @@ function inventreeDocReady() {
if ($('#search-bar').exists()) { if ($('#search-bar').exists()) {
$('#search-bar').autocomplete({ $('#search-bar').autocomplete({
source: function(request, response) { 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({ $.ajax({
url: '/api/part/', url: '/api/part/',
data: { data: params,
search: request.term,
limit: user_settings.SEARCH_PREVIEW_RESULTS,
offset: 0
},
success: function(data) { success: function(data) {
var transformed = $.map(data.results, function(el) { var transformed = $.map(data.results, function(el) {

View File

@ -1012,6 +1012,13 @@ class InvenTreeUserSetting(BaseInvenTreeSetting):
'validator': bool, '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': { 'PART_SHOW_QUANTITY_IN_FORMS': {
'name': _('Show Quantity in Forms'), 'name': _('Show Quantity in Forms'),
'description': _('Display available part quantity in some forms'), 'description': _('Display available part quantity in some forms'),

View File

@ -16,6 +16,7 @@
<tbody> <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_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_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> </tbody>
</table> </table>
</div> </div>