mirror of
https://github.com/BookStackApp/BookStack.git
synced 2024-10-01 01:36:00 -04:00
Merge branch 'feature-613' of git://github.com/Abijeet/BookStack into Abijeet-feature-613
This commit is contained in:
commit
1aa4d0dc59
@ -249,4 +249,27 @@ class UserController extends Controller
|
||||
'assetCounts' => $assetCounts
|
||||
]);
|
||||
}
|
||||
|
||||
public function switchBookView($id, Request $request) {
|
||||
$this->checkPermissionOr('users-manage', function () use ($id) {
|
||||
return $this->currentUser->id == $id;
|
||||
});
|
||||
$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
|
||||
|
@ -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');
|
||||
|
@ -82,6 +82,27 @@ class EntityTest extends BrowserKitTest
|
||||
->see($firstChapter->name);
|
||||
}
|
||||
|
||||
public function test_toggle_book_view()
|
||||
{
|
||||
$editor = $this->getEditor();
|
||||
setting()->putUser($editor, 'books_view_type', 'grid');
|
||||
|
||||
$this->actingAs($editor)
|
||||
->visit('/books')
|
||||
->pageHasElement('.featured-image-container')
|
||||
->submitForm('Toggle Book View')
|
||||
// Check redirection.
|
||||
->seePageIs('/books')
|
||||
->pageNotHasElement('.featured-image-container');
|
||||
|
||||
$this->actingAs($editor)
|
||||
->visit('/books')
|
||||
->submitForm('Toggle Book View')
|
||||
->seePageIs('/books')
|
||||
->pageHasElement('.featured-image-container');
|
||||
|
||||
}
|
||||
|
||||
public function pageCreation($chapter)
|
||||
{
|
||||
$page = factory(Page::class)->make([
|
||||
|
@ -103,7 +103,7 @@ class UserProfileTest extends BrowserKitTest
|
||||
$this->actingAs($editor)
|
||||
->visit('/books')
|
||||
->pageNotHasElement('.featured-image-container')
|
||||
->pageHasElement('.entity-list-item');
|
||||
->pageHasElement('.content .entity-list-item');
|
||||
}
|
||||
|
||||
public function test_books_view_is_grid()
|
||||
|
Loading…
Reference in New Issue
Block a user