mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-07-31 15:24:31 +03:00
Merge branch 'feature/sort-shelf-books' of git://github.com/guillaumehanotel/BookStack into guillaumehanotel-feature/sort-shelf-books
This commit is contained in:
@ -101,6 +101,15 @@ class BookshelfController extends Controller
|
||||
$shelf = $this->bookshelfRepo->getBySlug($slug);
|
||||
$this->checkOwnablePermission('book-view', $shelf);
|
||||
|
||||
$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);
|
||||
$view = setting()->getForCurrentUser('bookshelf_view_type');
|
||||
@ -108,8 +117,11 @@ class BookshelfController extends Controller
|
||||
$this->setPageTitle($shelf->getShortName());
|
||||
return view('shelves.show', [
|
||||
'shelf' => $shelf,
|
||||
'sortedVisibleShelfBooks' => $sortedVisibleShelfBooks,
|
||||
'view' => $view,
|
||||
'activity' => Activity::entityActivity($shelf, 20, 1)
|
||||
'activity' => Activity::entityActivity($shelf, 20, 1),
|
||||
'order' => $order,
|
||||
'sort' => $sort
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -300,7 +300,7 @@ class UserController extends Controller
|
||||
*/
|
||||
public function changeSort(Request $request, string $id, string $type)
|
||||
{
|
||||
$validSortTypes = ['books', 'bookshelves'];
|
||||
$validSortTypes = ['books', 'bookshelves', 'shelf_books'];
|
||||
if (!in_array($type, $validSortTypes)) {
|
||||
return redirect()->back(500);
|
||||
}
|
||||
|
Reference in New Issue
Block a user