mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2026-07-28 20:21:41 +00:00
Implement extensive search (#1406)
* Implement advanced search Up to 5 individual tokens (separated by spaces) can be given as search string. Each token is individually searched for in all selected fields. Examples (assuming the relevant fields are selected for search): - a part named `foo` with a tag `bar` will be found with the search string "foo bar". - a part named `bar baz` will be found with the search string "baz bar". - a part with the ID 123 and in storage location `a_qux_b` will be found with the search string "qux 123". * Add tests These were created with the help of GPT-5.2. Disclaimer: I don't have the experience to judge the quality or validity of the results. * Restructure query buildup * Update tests * Move options from Settings to localStorage * Consider mutual exclusivity of search options If regex search is enabled, the other two options are disabled (only visually). This should give the user a fair idea of what's happening while keeping things as simple as possible. * Added translations for the checkboxes * Fix stimulus controller to allow handling multiple instances of the dropdown menu * Added tooltips for the different search mode options --------- Co-authored-by: Jan Böhmer <mail@jan-boehmer.de>
This commit is contained in:
parent
49ffd3c938
commit
1686df968f
8 changed files with 434 additions and 34 deletions
54
assets/controllers/elements/search_config_controller.js
Normal file
54
assets/controllers/elements/search_config_controller.js
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
/*
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
* Copyright (C) 2019 - 2026 Jan Böhmer (https://github.com/jbtronics)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published
|
||||
* by the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import {Controller} from "@hotwired/stimulus";
|
||||
|
||||
|
||||
/**
|
||||
* Used to disable the extensive and wildcard search options, when Regex search is enabled.
|
||||
*/
|
||||
export default class extends Controller
|
||||
{
|
||||
static targets = ["regex", "extensive", "wildcard"]
|
||||
|
||||
connect() {
|
||||
|
||||
this.regexTarget.addEventListener('change', () => {
|
||||
this.updateOthers()
|
||||
});
|
||||
}
|
||||
|
||||
updateOthers() {
|
||||
let value = this.regexTarget.checked;
|
||||
let ext = this.extensiveTarget;
|
||||
let wild = this.wildcardTarget;
|
||||
if (value === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (value) {
|
||||
ext.disabled = 'disabled'
|
||||
wild.disabled = 'disabled'
|
||||
}
|
||||
else {
|
||||
ext.removeAttribute('disabled')
|
||||
wild.removeAttribute('disabled')
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue