mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-05-22 15:57:29 +00:00
Added core code-lang-favourites JS, PHP & CSS logic
- Got the functionality now working to favourite items and store that status within the system for the user. - Improved CSS display for usability.
This commit is contained in:
parent
ebc5a53410
commit
0df5ae0658
5 changed files with 76 additions and 8 deletions
app/Http/Controllers
|
@ -289,6 +289,27 @@ class UserController extends Controller
|
|||
return response('', 204);
|
||||
}
|
||||
|
||||
public function updateCodeLanguageFavourite(Request $request)
|
||||
{
|
||||
$validated = $this->validate($request, [
|
||||
'language' => ['required', 'string', 'max:20'],
|
||||
'active' => ['required', 'bool'],
|
||||
]);
|
||||
|
||||
$currentFavoritesStr = setting()->getForCurrentUser('code-language-favourites', '');
|
||||
$currentFavorites = array_filter(explode(',', $currentFavoritesStr));
|
||||
|
||||
$isFav = in_array($validated['language'], $currentFavorites);
|
||||
if (!$isFav && $validated['active']) {
|
||||
$currentFavorites[] = $validated['language'];
|
||||
} else if ($isFav && !$validated['active']) {
|
||||
$index = array_search($validated['language'], $currentFavorites);
|
||||
array_splice($currentFavorites, $index, 1);
|
||||
}
|
||||
|
||||
setting()->putUser(user(), 'code-language-favourites', implode(',', $currentFavorites));
|
||||
}
|
||||
|
||||
/**
|
||||
* Changed the stored preference for a list sort order.
|
||||
*/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue