2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-06-18 13:05:42 +00:00

Enable regex search (#4566)

* Adds custom search filter to allow 'regex' searching of results

* Specify if "shell" can access database for certain commands

* Bug fix for settings API

- Do not allow cache on detail endpoints
- Was causing strange error conditions with missing or duplicate PK values

* Adds user setting to control regex search

* Enable regex for search queries

- bootstrap tables
- search preview

* Pass search options through bettererer

* Refactor API endpoints to use new filter approach

* Bump API version

* Add "whole word" search

- Closes https://github.com/inventree/InvenTree/issues/4510

* Handle case where existing fields are empty

* pop > get
This commit is contained in:
Oliver
2023-04-04 07:05:55 +10:00
committed by GitHub
parent eef303dfea
commit d6715d94c1
19 changed files with 165 additions and 72 deletions

View File

@ -14,6 +14,9 @@
<div class='row'>
<table class='table table-striped table-condensed'>
<tbody>
{% include "InvenTree/settings/setting.html" with key="SEARCH_WHOLE" user_setting=True icon='fa-spell-check' %}
{% include "InvenTree/settings/setting.html" with key="SEARCH_REGEX" user_setting=True icon='fa-code' %}
{% 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_SHOW_PARTS" user_setting=True icon='fa-shapes' %}
{% include "InvenTree/settings/setting.html" with key="SEARCH_HIDE_INACTIVE_PARTS" user_setting=True icon='fa-eye-slash' %}
{% include "InvenTree/settings/setting.html" with key="SEARCH_PREVIEW_SHOW_SUPPLIER_PARTS" user_setting=True icon='fa-building' %}
@ -31,7 +34,6 @@
{% include "InvenTree/settings/setting.html" with key="SEARCH_PREVIEW_SHOW_RETURN_ORDERS" user_setting=True icon='fa-truck' %}
{% include "InvenTree/settings/setting.html" with key="SEARCH_PREVIEW_EXCLUDE_INACTIVE_RETURN_ORDERS" user_setting=True icon='fa-eye-slash' %}
{% include "InvenTree/settings/setting.html" with key="SEARCH_PREVIEW_RESULTS" user_setting=True icon='fa-search' %}
</tbody>
</table>

View File

@ -141,6 +141,8 @@ function updateSearch() {
// Construct base query
searchQuery = {
search: searchTextCurrent,
search_regex: user_settings.SEARCH_REGEX ? true : false,
search_whole: user_settings.SEARCH_WHOLE ? true : false,
limit: user_settings.SEARCH_PREVIEW_RESULTS,
offset: 0,
};

View File

@ -355,6 +355,16 @@ function convertQueryParameters(params, filters) {
delete params['original_search'];
}
// Enable regex search
if (user_settings.SEARCH_REGEX) {
params['search_regex'] = true;
}
// Enable whole word search
if (user_settings.SEARCH_WHOLE) {
params['search_whole'] = true;
}
return params;
}