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

Added experimental breadcrumb traversal

This commit is contained in:
Dan Brown
2019-02-24 15:57:35 +00:00
parent e70423c73f
commit 035a0d8efb
17 changed files with 296 additions and 11 deletions

View File

@ -3,6 +3,7 @@
use BookStack\Actions\ViewService;
use BookStack\Entities\Repos\EntityRepo;
use BookStack\Entities\SearchService;
use BookStack\Exceptions\NotFoundException;
use Illuminate\Http\Request;
class SearchController extends Controller
@ -104,4 +105,45 @@ class SearchController extends Controller
return view('search/entity-ajax-list', ['entities' => $entities]);
}
/**
* Search siblings items in the system.
* @param Request $request
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View|mixed
*/
public function searchSiblings(Request $request)
{
$type = $request->get('entity_type', null);
$id = $request->get('entity_id', null);
$entity = $this->entityRepo->getById($type, $id);
if (!$entity) {
return $this->jsonError(trans('errors.entity_not_found'), 404);
}
$entities = [];
// Page in chapter
if ($entity->isA('page') && $entity->chapter) {
$entities = $this->entityRepo->getChapterChildren($entity->chapter);
}
// Page in book or chapter
if (($entity->isA('page') && !$entity->chapter) || $entity->isA('chapter')) {
$entities = $this->entityRepo->getBookDirectChildren($entity->book);
}
// Book in shelf
// TODO - When shelve tracking added, Update below if criteria
// Book
if ($entity->isA('book')) {
$entities = $this->entityRepo->getAll('book');
}
// Shelve
// TODO - When shelve tracking added
return view('partials.entity-list-basic', ['entities' => $entities, 'style' => 'compact']);
}
}