mirror of
https://github.com/BookStackApp/BookStack.git
synced 2024-08-27 12:41:58 +00:00
![Dan Brown](/assets/img/avatar_default.png)
- 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
64 lines
1.6 KiB
PHP
64 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace BookStack\Http\Controllers;
|
|
|
|
use BookStack\Actions\TagRepo;
|
|
use Illuminate\Http\Request;
|
|
|
|
class TagController extends Controller
|
|
{
|
|
protected TagRepo $tagRepo;
|
|
|
|
public function __construct(TagRepo $tagRepo)
|
|
{
|
|
$this->tagRepo = $tagRepo;
|
|
}
|
|
|
|
/**
|
|
* Show a listing of existing tags in the system.
|
|
*/
|
|
public function index(Request $request)
|
|
{
|
|
$search = $request->get('search', '');
|
|
$nameFilter = $request->get('name', '');
|
|
$tags = $this->tagRepo
|
|
->queryWithTotals($search, $nameFilter)
|
|
->paginate(50)
|
|
->appends(array_filter([
|
|
'search' => $search,
|
|
'name' => $nameFilter,
|
|
]));
|
|
|
|
$this->setPageTitle(trans('entities.tags'));
|
|
|
|
return view('tags.index', [
|
|
'tags' => $tags,
|
|
'search' => $search,
|
|
'nameFilter' => $nameFilter,
|
|
]);
|
|
}
|
|
|
|
/**
|
|
* Get tag name suggestions from a given search term.
|
|
*/
|
|
public function getNameSuggestions(Request $request)
|
|
{
|
|
$searchTerm = $request->get('search', '');
|
|
$suggestions = $this->tagRepo->getNameSuggestions($searchTerm);
|
|
|
|
return response()->json($suggestions);
|
|
}
|
|
|
|
/**
|
|
* Get tag value suggestions from a given search term.
|
|
*/
|
|
public function getValueSuggestions(Request $request)
|
|
{
|
|
$searchTerm = $request->get('search', '');
|
|
$tagName = $request->get('name', '');
|
|
$suggestions = $this->tagRepo->getValueSuggestions($searchTerm, $tagName);
|
|
|
|
return response()->json($suggestions);
|
|
}
|
|
}
|