mirror of
https://github.com/BookStackApp/BookStack.git
synced 2024-11-23 07:54:34 +08: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
|
@ -46,7 +46,7 @@ class BookController extends Controller
|
|||
'books' => $books,
|
||||
'recents' => $recents,
|
||||
'popular' => $popular,
|
||||
'new' => $new,
|
||||
'new' => $new,
|
||||
'booksViewType' => $booksViewType
|
||||
]);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -99,6 +99,7 @@ return [
|
|||
'books_sort_named' => 'Sort Book :bookName',
|
||||
'books_sort_show_other' => 'Show Other Books',
|
||||
'books_sort_save' => 'Save New Order',
|
||||
'books_toggle_view' => 'Toggle Book View',
|
||||
|
||||
/**
|
||||
* Chapters
|
||||
|
|
|
@ -4,6 +4,11 @@
|
|||
<div class="col-xs-1"></div>
|
||||
<div class="col-xs-11 faded">
|
||||
<div class="action-buttons">
|
||||
<form action="{{ baseUrl("/settings/users/{$currentUser->id}/switch-book-view") }}" method="POST" class="inline">
|
||||
{!! csrf_field() !!}
|
||||
<input type="hidden" value="{{ $booksViewType === 'list'? 'grid' : 'list' }}" name="book_view_type">
|
||||
<button type="submit" class="text-pos text-button"><i class="zmdi zmdi-wrap-text"></i>{{ trans('entities.books_toggle_view') }}</button>
|
||||
</form>
|
||||
@if($currentUser->can('book-create-all'))
|
||||
<a href="{{ baseUrl("/books/create") }}" class="text-pos text-button"><i class="zmdi zmdi-plus"></i>{{ trans('entities.books_create') }}</a>
|
||||
@endif
|
||||
|
@ -52,7 +57,7 @@
|
|||
<hr>
|
||||
@endforeach
|
||||
{!! $books->render() !!}
|
||||
@else
|
||||
@else
|
||||
<div class="row auto-clear">
|
||||
@foreach($books as $key => $book)
|
||||
@include('books/grid-item', ['book' => $book])
|
||||
|
|
|
@ -146,6 +146,7 @@ Route::group(['middleware' => 'auth'], function () {
|
|||
Route::get('/users', 'UserController@index');
|
||||
Route::get('/users/create', 'UserController@create');
|
||||
Route::get('/users/{id}/delete', 'UserController@delete');
|
||||
Route::post('/users/{id}/switch-book-view', 'UserController@switchBookView');
|
||||
Route::post('/users/create', 'UserController@store');
|
||||
Route::get('/users/{id}', 'UserController@edit');
|
||||
Route::put('/users/{id}', 'UserController@update');
|
||||
|
|
Loading…
Reference in New Issue
Block a user