Repository navigation
quick search: sort toggles for the dropdown results (stacked on #1563) - #1585
Merged
Merged
Conversation
The navbar/homepage dropdown only did a fixed substring match on
name/description/category/footprint; regex and extensive matching needed
Enter and a full results page.
When regex or extensive matching is checked in the search options, the
dropdown now sends the checked options to the typeahead endpoint, which
runs the same PartSearchFilter as the search page (selected fields,
regex, extensive, wildcard). With neither checked the request and the
existing fast autocomplete search are unchanged.
A half-typed regex (e.g. "lm(") answers an empty list instead of an
error, highlighting follows the regex or the individual words, and
toggling an option re-runs the dropdown for the text already typed.
The request-to-filter code moves from PartListsController to
PartSearchFilter::fromRequest() so both places share it.
The search dropdown always listed its results by name, so finding e.g. the most recently added part matching a keyword meant submitting the search and sorting the table. The header of the dropdown now has a row of small toggles to order the results by name, manufacturer, supplier, creation date, last modification, top-level category or category. A click sorts ascending, a second one descending and a third one returns to the default ordering. The choice is remembered in the local storage and shared by all search fields. The typeahead endpoint takes the ordering as "sort" and "sort_dir" query parameters. Parts without a value (e.g. no manufacturer) are put last in both directions and ties are ordered by name. The root category is not stored in the database, so that ordering is resolved in PHP from the IDs and category IDs of the matching parts. The search form submits the same parameters, and the results table opens sorted by the matching column where it has one (name, manufacturer, creation date, last modification, category). Such a requested ordering takes precedence over the saved table state, but does not overwrite it.
Ordered by supplier, manufacturer, a date or the top level category, the dropdown gave no hint why a result was where it was: each result now shows that value (marked with the ordering's icon). The toggles were small enough to miss and to mis-click; they are the size of the result text now.
The direction arrow was only rendered in the active toggle, which made it wider and pushed its neighbours aside: the arrow now always takes its space and is just invisible. The active toggle used the body background as text color, which is dark on the primary color in dark mode; it is white now.
phpstan (arrayFilter.strict) rejects array_filter without a callback.
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #1585 +/- ##
============================================
+ Coverage 62.97% 64.18% +1.21%
- Complexity 10071 10270 +199
============================================
Files 748 763 +15
Lines 32315 32868 +553
============================================
+ Hits 20351 21097 +746
+ Misses 11964 11771 -193 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Contributor
Author
…rect order to avoid rearranging them later in PHP
Member
|
Thats a cool feature. I fixed the styling of the buttons, improved code structure, and optimized the code to avoid sorting in PHP (we can directly request entities sorted by a list of ids from the database) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


This is stacked on #1563 (live dropdown search honors regex, extensive and field options) and contains its commit; please review that one first. Once it is merged this PR will only show its own changes. Both touch
part_search_controller.js,TypeaheadControllerandPartRepository, which is why it is built on top instead of beside it.The quick search dropdown always lists its results by name. With a few hundred matches the one you want is often far down, and the only way to get another order is to submit the search and sort the results table.
This adds a small row of toggles to the header of the dropdown to order the results by: name, manufacturer, supplier, created date, last modified date, top-level category, or category.
Server side:
sortandsort_dir; an unknownsortfalls back to the default. NULLs sort last in both directions, ties by name and then id.PartSearchSortholds the sort keys, the request parsing and the mapping to a results table column.The toggle arrow always takes its space and is only made visible on the active toggle, so the toggles do not move when one is chosen.
Ten new strings in
frontend.en.xlf(the JS translator only reads that domain).Notes for review:
PartSearchSort::getTableColumn().