mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-05-20 15:09:38 +00:00
Updated view-change endpoints to be clearer, separated books and shelf
- Separated books-list and shelf-show view types to be saved separately. During review of #1755
This commit is contained in:
parent
b8c16b15a9
commit
053cbbd5b6
9 changed files with 54 additions and 61 deletions
app/Http/Controllers
|
@ -7,7 +7,6 @@ use BookStack\Auth\UserRepo;
|
|||
use BookStack\Exceptions\UserUpdateException;
|
||||
use BookStack\Uploads\ImageRepo;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class UserController extends Controller
|
||||
|
@ -20,10 +19,6 @@ class UserController extends Controller
|
|||
|
||||
/**
|
||||
* UserController constructor.
|
||||
* @param User $user
|
||||
* @param UserRepo $userRepo
|
||||
* @param UserInviteService $inviteService
|
||||
* @param ImageRepo $imageRepo
|
||||
*/
|
||||
public function __construct(User $user, UserRepo $userRepo, UserInviteService $inviteService, ImageRepo $imageRepo)
|
||||
{
|
||||
|
@ -36,8 +31,6 @@ class UserController extends Controller
|
|||
|
||||
/**
|
||||
* Display a listing of the users.
|
||||
* @param Request $request
|
||||
* @return Response
|
||||
*/
|
||||
public function index(Request $request)
|
||||
{
|
||||
|
@ -55,7 +48,6 @@ class UserController extends Controller
|
|||
|
||||
/**
|
||||
* Show the form for creating a new user.
|
||||
* @return Response
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
|
@ -67,9 +59,8 @@ class UserController extends Controller
|
|||
|
||||
/**
|
||||
* Store a newly created user in storage.
|
||||
* @param Request $request
|
||||
* @return Response
|
||||
* @throws UserUpdateException
|
||||
* @throws \Illuminate\Validation\ValidationException
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
|
@ -138,13 +129,11 @@ class UserController extends Controller
|
|||
|
||||
/**
|
||||
* Update the specified user in storage.
|
||||
* @param Request $request
|
||||
* @param int $id
|
||||
* @return Response
|
||||
* @throws UserUpdateException
|
||||
* @throws \BookStack\Exceptions\ImageUploadException
|
||||
* @throws \Illuminate\Validation\ValidationException
|
||||
*/
|
||||
public function update(Request $request, $id)
|
||||
public function update(Request $request, int $id)
|
||||
{
|
||||
$this->preventAccessInDemoMode();
|
||||
$this->checkPermissionOrCurrentUser('users-manage', $id);
|
||||
|
@ -212,10 +201,8 @@ class UserController extends Controller
|
|||
|
||||
/**
|
||||
* Show the user delete page.
|
||||
* @param int $id
|
||||
* @return \Illuminate\View\View
|
||||
*/
|
||||
public function delete($id)
|
||||
public function delete(int $id)
|
||||
{
|
||||
$this->checkPermissionOrCurrentUser('users-manage', $id);
|
||||
|
||||
|
@ -226,11 +213,9 @@ class UserController extends Controller
|
|||
|
||||
/**
|
||||
* Remove the specified user from storage.
|
||||
* @param int $id
|
||||
* @return Response
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function destroy($id)
|
||||
public function destroy(int $id)
|
||||
{
|
||||
$this->preventAccessInDemoMode();
|
||||
$this->checkPermissionOrCurrentUser('users-manage', $id);
|
||||
|
@ -255,8 +240,6 @@ class UserController extends Controller
|
|||
|
||||
/**
|
||||
* Show the user profile page
|
||||
* @param $id
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
*/
|
||||
public function showProfilePage($id)
|
||||
{
|
||||
|
@ -276,34 +259,32 @@ class UserController extends Controller
|
|||
|
||||
/**
|
||||
* Update the user's preferred book-list display setting.
|
||||
* @param Request $request
|
||||
* @param $id
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function switchBookView(Request $request, $id)
|
||||
public function switchBooksView(Request $request, int $id)
|
||||
{
|
||||
return $this->switchViewType($id, $request, 'books');
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the user's preferred shelf-list display setting.
|
||||
* @param Request $request
|
||||
* @param $id
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function switchShelfView(Request $request, $id)
|
||||
public function switchShelvesView(Request $request, int $id)
|
||||
{
|
||||
return $this->switchViewType($id, $request, 'bookshelves');
|
||||
}
|
||||
|
||||
/**
|
||||
* For a type of list, switch with stored view type for a user.
|
||||
* @param integer $userId
|
||||
* @param Request $request
|
||||
* @param string $listName
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
* Update the user's preferred shelf-view book list display setting.
|
||||
*/
|
||||
protected function switchViewType($userId, Request $request, string $listName)
|
||||
public function switchShelfView(Request $request, int $id)
|
||||
{
|
||||
return $this->switchViewType($id, $request, 'bookshelf');
|
||||
}
|
||||
|
||||
/**
|
||||
* For a type of list, switch with stored view type for a user.
|
||||
*/
|
||||
protected function switchViewType(int $userId, Request $request, string $listName)
|
||||
{
|
||||
$this->checkPermissionOrCurrentUser('users-manage', $userId);
|
||||
|
||||
|
@ -321,10 +302,6 @@ class UserController extends Controller
|
|||
|
||||
/**
|
||||
* Change the stored sort type for a particular view.
|
||||
* @param Request $request
|
||||
* @param string $id
|
||||
* @param string $type
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function changeSort(Request $request, string $id, string $type)
|
||||
{
|
||||
|
@ -337,10 +314,6 @@ class UserController extends Controller
|
|||
|
||||
/**
|
||||
* Update the stored section expansion preference for the given user.
|
||||
* @param Request $request
|
||||
* @param string $id
|
||||
* @param string $key
|
||||
* @return \Illuminate\Contracts\Routing\ResponseFactory|\Symfony\Component\HttpFoundation\Response
|
||||
*/
|
||||
public function updateExpansionPreference(Request $request, string $id, string $key)
|
||||
{
|
||||
|
@ -359,10 +332,6 @@ class UserController extends Controller
|
|||
|
||||
/**
|
||||
* Changed the stored preference for a list sort order.
|
||||
* @param int $userId
|
||||
* @param Request $request
|
||||
* @param string $listName
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
protected function changeListSort(int $userId, Request $request, string $listName)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue