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:
Dan Brown 2017-12-29 16:49:03 +00:00
parent 1aa4d0dc59
commit 141bf22725
No known key found for this signature in database
GPG Key ID: 46D9F943C24A2EF9
7 changed files with 24 additions and 23 deletions

View File

@ -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) {
$this->checkPermissionOr('users-manage', function () use ($id) {
return $this->currentUser->id == $id;
});
$viewType = $request->get('book_view_type');
$viewType = $request->get('book_view_type');
if (!in_array($viewType, ['grid', 'list'])) {
$viewType = 'list';
}
@ -263,13 +269,7 @@ class UserController extends Controller
$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);
}
return redirect()->back(302, [], "/settings/users/$id");
}
}

View File

@ -49,6 +49,8 @@ return [
'toggle_details' => 'Toggle Details',
'toggle_thumbnails' => 'Toggle Thumbnails',
'details' => 'Details',
'grid_view' => 'Grid View',
'list_view' => 'List View',
/**
* Header

View File

@ -99,7 +99,6 @@ 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

View File

@ -96,7 +96,6 @@ return [
'users_external_auth_id' => 'External Authentication ID',
'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_books_view_type' => 'Preferred layout for books viewing',
'users_delete' => 'Delete User',
'users_delete_named' => 'Delete user :userName',
'users_delete_warning' => 'This will fully delete this user with the name \':userName\' from the system.',

View File

@ -1,14 +1,22 @@
@extends('sidebar-layout')
@section('toolbar')
<div class="col-xs-1"></div>
<div class="col-xs-11 faded">
<div class="action-buttons">
<div class="col-xs-6">
<div class="action-buttons text-left">
<form action="{{ baseUrl("/settings/users/{$currentUser->id}/switch-book-view") }}" method="POST" class="inline">
{!! csrf_field() !!}
{!! method_field('PATCH') !!}
<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>
</div>
</div>
<div class="col-xs-6 faded">
<div class="action-buttons">
@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

View File

@ -43,13 +43,6 @@
@endforeach
</select>
</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 class="form-group text-right">

View File

@ -146,7 +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::patch('/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');