Updated book view change to PATCH + other amends
Moved toggle to right of header bar and added unique text and icon for each view type. Removed old profile setting to keep things clean.
This commit is contained in:
parent
1aa4d0dc59
commit
141bf22725
|
@ -250,12 +250,18 @@ class UserController extends Controller
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the user's preferred book-list display setting.
|
||||||
|
* @param $id
|
||||||
|
* @param Request $request
|
||||||
|
* @return \Illuminate\Http\RedirectResponse
|
||||||
|
*/
|
||||||
public function switchBookView($id, Request $request) {
|
public function switchBookView($id, Request $request) {
|
||||||
$this->checkPermissionOr('users-manage', function () use ($id) {
|
$this->checkPermissionOr('users-manage', function () use ($id) {
|
||||||
return $this->currentUser->id == $id;
|
return $this->currentUser->id == $id;
|
||||||
});
|
});
|
||||||
$viewType = $request->get('book_view_type');
|
|
||||||
|
|
||||||
|
$viewType = $request->get('book_view_type');
|
||||||
if (!in_array($viewType, ['grid', 'list'])) {
|
if (!in_array($viewType, ['grid', 'list'])) {
|
||||||
$viewType = 'list';
|
$viewType = 'list';
|
||||||
}
|
}
|
||||||
|
@ -263,13 +269,7 @@ class UserController extends Controller
|
||||||
$user = $this->user->findOrFail($id);
|
$user = $this->user->findOrFail($id);
|
||||||
setting()->putUser($user, 'books_view_type', $viewType);
|
setting()->putUser($user, 'books_view_type', $viewType);
|
||||||
|
|
||||||
$previousUrl = url()->previous();
|
return redirect()->back(302, [], "/settings/users/$id");
|
||||||
if (empty($previousUrl)) {
|
|
||||||
// if no previous URL, redirect to settings
|
|
||||||
return redirect("/settings/users/$id");
|
|
||||||
} else {
|
|
||||||
// redirect to the previous page.
|
|
||||||
return redirect($previousUrl);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,6 +49,8 @@ return [
|
||||||
'toggle_details' => 'Toggle Details',
|
'toggle_details' => 'Toggle Details',
|
||||||
'toggle_thumbnails' => 'Toggle Thumbnails',
|
'toggle_thumbnails' => 'Toggle Thumbnails',
|
||||||
'details' => 'Details',
|
'details' => 'Details',
|
||||||
|
'grid_view' => 'Grid View',
|
||||||
|
'list_view' => 'List View',
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Header
|
* Header
|
||||||
|
|
|
@ -99,7 +99,6 @@ return [
|
||||||
'books_sort_named' => 'Sort Book :bookName',
|
'books_sort_named' => 'Sort Book :bookName',
|
||||||
'books_sort_show_other' => 'Show Other Books',
|
'books_sort_show_other' => 'Show Other Books',
|
||||||
'books_sort_save' => 'Save New Order',
|
'books_sort_save' => 'Save New Order',
|
||||||
'books_toggle_view' => 'Toggle Book View',
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Chapters
|
* Chapters
|
||||||
|
|
|
@ -96,7 +96,6 @@ return [
|
||||||
'users_external_auth_id' => 'External Authentication ID',
|
'users_external_auth_id' => 'External Authentication ID',
|
||||||
'users_password_warning' => 'Only fill the below if you would like to change your password:',
|
'users_password_warning' => 'Only fill the below if you would like to change your password:',
|
||||||
'users_system_public' => 'This user represents any guest users that visit your instance. It cannot be used to log in but is assigned automatically.',
|
'users_system_public' => 'This user represents any guest users that visit your instance. It cannot be used to log in but is assigned automatically.',
|
||||||
'users_books_view_type' => 'Preferred layout for books viewing',
|
|
||||||
'users_delete' => 'Delete User',
|
'users_delete' => 'Delete User',
|
||||||
'users_delete_named' => 'Delete user :userName',
|
'users_delete_named' => 'Delete user :userName',
|
||||||
'users_delete_warning' => 'This will fully delete this user with the name \':userName\' from the system.',
|
'users_delete_warning' => 'This will fully delete this user with the name \':userName\' from the system.',
|
||||||
|
|
|
@ -1,14 +1,22 @@
|
||||||
@extends('sidebar-layout')
|
@extends('sidebar-layout')
|
||||||
|
|
||||||
@section('toolbar')
|
@section('toolbar')
|
||||||
<div class="col-xs-1"></div>
|
<div class="col-xs-6">
|
||||||
<div class="col-xs-11 faded">
|
<div class="action-buttons text-left">
|
||||||
<div class="action-buttons">
|
|
||||||
<form action="{{ baseUrl("/settings/users/{$currentUser->id}/switch-book-view") }}" method="POST" class="inline">
|
<form action="{{ baseUrl("/settings/users/{$currentUser->id}/switch-book-view") }}" method="POST" class="inline">
|
||||||
{!! csrf_field() !!}
|
{!! csrf_field() !!}
|
||||||
|
{!! method_field('PATCH') !!}
|
||||||
<input type="hidden" value="{{ $booksViewType === 'list'? 'grid' : 'list' }}" name="book_view_type">
|
<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>
|
@if ($booksViewType === 'list')
|
||||||
|
<button type="submit" class="text-pos text-button"><i class="zmdi zmdi-view-module"></i>{{ trans('common.grid_view') }}</button>
|
||||||
|
@else
|
||||||
|
<button type="submit" class="text-pos text-button"><i class="zmdi zmdi-view-list"></i>{{ trans('common.list_view') }}</button>
|
||||||
|
@endif
|
||||||
</form>
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-xs-6 faded">
|
||||||
|
<div class="action-buttons">
|
||||||
@if($currentUser->can('book-create-all'))
|
@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>
|
<a href="{{ baseUrl("/books/create") }}" class="text-pos text-button"><i class="zmdi zmdi-plus"></i>{{ trans('entities.books_create') }}</a>
|
||||||
@endif
|
@endif
|
||||||
|
|
|
@ -43,13 +43,6 @@
|
||||||
@endforeach
|
@endforeach
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
|
||||||
<label for="books-view-type">{{ trans('settings.users_books_view_type') }}</label>
|
|
||||||
<select name="setting[books_view_type]" id="books-view-type">
|
|
||||||
<option @if(setting()->getUser($user, 'books_view_type', 'list') === 'list') selected @endif value="list">List</option>
|
|
||||||
<option @if(setting()->getUser($user, 'books_view_type', 'list') === 'grid') selected @endif value="grid">Grid</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group text-right">
|
<div class="form-group text-right">
|
||||||
|
|
|
@ -146,7 +146,7 @@ Route::group(['middleware' => 'auth'], function () {
|
||||||
Route::get('/users', 'UserController@index');
|
Route::get('/users', 'UserController@index');
|
||||||
Route::get('/users/create', 'UserController@create');
|
Route::get('/users/create', 'UserController@create');
|
||||||
Route::get('/users/{id}/delete', 'UserController@delete');
|
Route::get('/users/{id}/delete', 'UserController@delete');
|
||||||
Route::post('/users/{id}/switch-book-view', 'UserController@switchBookView');
|
Route::patch('/users/{id}/switch-book-view', 'UserController@switchBookView');
|
||||||
Route::post('/users/create', 'UserController@store');
|
Route::post('/users/create', 'UserController@store');
|
||||||
Route::get('/users/{id}', 'UserController@edit');
|
Route::get('/users/{id}', 'UserController@edit');
|
||||||
Route::put('/users/{id}', 'UserController@update');
|
Route::put('/users/{id}', 'UserController@update');
|
||||||
|
|
Loading…
Reference in New Issue