mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-05-17 13:52:04 +00:00
Updated view toggle to store date
Also added test for user list order preferences
This commit is contained in:
parent
01be72d5e2
commit
9406b4d4c9
11 changed files with 155 additions and 20 deletions
app/Http/Controllers
|
@ -299,7 +299,6 @@ class UserController extends Controller
|
|||
*/
|
||||
public function changeSort(string $id, string $type, Request $request)
|
||||
{
|
||||
// TODO - Test this endpoint
|
||||
$validSortTypes = ['books', 'bookshelves'];
|
||||
if (!in_array($type, $validSortTypes)) {
|
||||
return redirect()->back(500);
|
||||
|
@ -307,6 +306,28 @@ class UserController extends Controller
|
|||
return $this->changeListSort($id, $request, $type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the stored section expansion preference for the given user.
|
||||
* @param string $id
|
||||
* @param string $key
|
||||
* @param Request $request
|
||||
* @return \Illuminate\Contracts\Routing\ResponseFactory|\Symfony\Component\HttpFoundation\Response
|
||||
*/
|
||||
public function updateExpansionPreference(string $id, string $key, Request $request)
|
||||
{
|
||||
$this->checkPermissionOrCurrentUser('users-manage', $id);
|
||||
$keyWhitelist = ['home-details'];
|
||||
if (!in_array($key, $keyWhitelist)) {
|
||||
return response("Invalid key", 500);
|
||||
}
|
||||
|
||||
$newState = $request->get('expand', 'false');
|
||||
|
||||
$user = $this->user->findOrFail($id);
|
||||
setting()->putUser($user, 'section_expansion#' . $key, $newState);
|
||||
return response("", 204);
|
||||
}
|
||||
|
||||
/**
|
||||
* Changed the stored preference for a list sort order.
|
||||
* @param int $userId
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue