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

Improve sorting Shelf Books

This commit is contained in:
Guillaume Hanotel
2021-01-31 04:25:31 +01:00
parent 26ba056302
commit a7848b916b
4 changed files with 14 additions and 22 deletions

View File

@ -101,8 +101,14 @@ class BookshelfController extends Controller
$shelf = $this->bookshelfRepo->getBySlug($slug);
$this->checkOwnablePermission('book-view', $shelf);
$sort = setting()->getForCurrentUser('books_sort', 'name');
$order = setting()->getForCurrentUser('books_sort_order', 'asc');
$sort = setting()->getForCurrentUser('shelf_books_sort', 'name');
$order = setting()->getForCurrentUser('shelf_books_sort_order', 'asc');
$visibleShelfBooks = $shelf->visibleBooks()->get();
$sortedVisibleShelfBooks = $visibleShelfBooks
->sortBy($sort, SORT_REGULAR, $order === 'desc')
->values()
->all();
Views::add($shelf);
$this->entityContextManager->setShelfContext($shelf->id);
@ -111,6 +117,7 @@ class BookshelfController extends Controller
$this->setPageTitle($shelf->getShortName());
return view('shelves.show', [
'shelf' => $shelf,
'sortedVisibleShelfBooks' => $sortedVisibleShelfBooks,
'view' => $view,
'activity' => Activity::entityActivity($shelf, 20, 1),
'order' => $order,