1
0
mirror of https://github.com/BookStackApp/BookStack.git synced 2025-07-28 17:02:04 +03:00

Improved tag suggestion handling

- Aligned prefix-type filtering with back-end.
- Increased suggestion search cut-off from 3 to 4.
- Increased amount of suggestions shown.
- Ordered suggestions to be name asc, as you'd expect on search.
- Updated front-end filtering to use full search query, instead of
  truncated version, for further front-end filtering capability.

Related to #3720
This commit is contained in:
Dan Brown
2022-09-28 13:50:40 +01:00
parent 1ac1cf0c78
commit 8f3430d386
3 changed files with 17 additions and 19 deletions

View File

@ -7,11 +7,8 @@ use Illuminate\Http\Request;
class TagController extends Controller
{
protected $tagRepo;
protected TagRepo $tagRepo;
/**
* TagController constructor.
*/
public function __construct(TagRepo $tagRepo)
{
$this->tagRepo = $tagRepo;
@ -46,7 +43,7 @@ class TagController extends Controller
*/
public function getNameSuggestions(Request $request)
{
$searchTerm = $request->get('search', null);
$searchTerm = $request->get('search', '');
$suggestions = $this->tagRepo->getNameSuggestions($searchTerm);
return response()->json($suggestions);
@ -57,8 +54,8 @@ class TagController extends Controller
*/
public function getValueSuggestions(Request $request)
{
$searchTerm = $request->get('search', null);
$tagName = $request->get('name', null);
$searchTerm = $request->get('search', '');
$tagName = $request->get('name', '');
$suggestions = $this->tagRepo->getValueSuggestions($searchTerm, $tagName);
return response()->json($suggestions);