mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-05-17 22:02:05 +00:00
Adds button to allow users to toggle the book view via the books list page.
Closes #613 Signed-off-by: Abijeet <abijeetpatro@gmail.com>
This commit is contained in:
parent
03eb63ec77
commit
0d4db603a4
5 changed files with 30 additions and 2 deletions
app/Http/Controllers
|
@ -249,4 +249,25 @@ class UserController extends Controller
|
|||
'assetCounts' => $assetCounts
|
||||
]);
|
||||
}
|
||||
|
||||
public function switchBookView($id, Request $request) {
|
||||
$this->checkPermission('users-manage');
|
||||
$viewType = $request->get('book_view_type');
|
||||
|
||||
if (!in_array($viewType, ['grid', 'list'])) {
|
||||
$viewType = 'list';
|
||||
}
|
||||
|
||||
$user = $this->user->findOrFail($id);
|
||||
setting()->putUser($user, 'books_view_type', $viewType);
|
||||
|
||||
$previousUrl = url()->previous();
|
||||
if (empty($previousUrl)) {
|
||||
// if no previous URL, redirect to settings
|
||||
return redirect("/settings/users/$id");
|
||||
} else {
|
||||
// redirect to the previous page.
|
||||
return redirect($previousUrl);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue