Started interface user shortcut form interface

Built controller actions and initual UI.
Still needs JS logic for shortcut input handling.
This commit is contained in:
Dan Brown
2022-11-08 21:17:45 +00:00
parent 1fc994177f
commit 66c8809799
13 changed files with 232 additions and 40 deletions

View File

@ -3,6 +3,7 @@
namespace BookStack\Http\Controllers;
use BookStack\Auth\UserRepo;
use BookStack\Settings\UserShortcutMap;
use Illuminate\Http\Request;
class UserPreferencesController extends Controller
@ -14,6 +15,37 @@ class UserPreferencesController extends Controller
$this->userRepo = $userRepo;
}
/**
* Show the user-specific interface shortcuts.
*/
public function showShortcuts()
{
$shortcuts = UserShortcutMap::fromUserPreferences();
$enabled = setting()->getForCurrentUser('ui-shortcuts-enabled', false);
return view('users.preferences.shortcuts', [
'shortcuts' => $shortcuts,
'enabled' => $enabled,
]);
}
/**
* Update the user-specific interface shortcuts.
*/
public function updateShortcuts(Request $request)
{
$enabled = $request->get('enabled') === 'true';
$providedShortcuts = $request->get('shortcuts', []);
$shortcuts = new UserShortcutMap($providedShortcuts);
setting()->putUser(user(), 'ui-shortcuts', $shortcuts->toJson());
setting()->putUser(user(), 'ui-shortcuts-enabled', $enabled);
$this->showSuccessNotification('Shortcuts preferences have been updated!');
return redirect('/preferences/shortcuts');
}
/**
* Update the user's preferred book-list display setting.
*/