new: [layout:sidebar] Save sidebar expanded state in user setting
parent
4d85d70799
commit
7fbf83bf49
|
@ -16,6 +16,8 @@
|
|||
use Cake\Core\Configure;
|
||||
|
||||
$cakeDescription = 'Cerebrate';
|
||||
|
||||
$sidebarOpen = $loggedUser->user_settings_by_name['ui.sidebar.expanded']->value;
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
@ -72,7 +74,7 @@ $cakeDescription = 'Cerebrate';
|
|||
<header class="navbar top-navbar navbar-dark">
|
||||
<?= $this->element('layouts/header') ?>
|
||||
</header>
|
||||
<nav id="app-sidebar" class="collapse d-sm-block sidebar">
|
||||
<nav id="app-sidebar" class="collapse d-sm-block sidebar <?= !empty($sidebarOpen) ? 'expanded' : '' ?>">
|
||||
<?= $this->element('layouts/sidebar') ?>
|
||||
</nav>
|
||||
<main role="main" class="content">
|
||||
|
|
|
@ -162,4 +162,18 @@ $(document).ready(() => {
|
|||
$('#globalSearch')
|
||||
.keydown(debouncedGlobalSearch)
|
||||
.keydown(focusSearchResults);
|
||||
})
|
||||
|
||||
$('.lock-sidebar a.btn-lock-sidebar').click(() => {
|
||||
const $sidebar = $('.sidebar')
|
||||
let expanded = $sidebar.hasClass('expanded');
|
||||
if (expanded) {
|
||||
$sidebar.removeClass('expanded')
|
||||
} else {
|
||||
$sidebar.addClass('expanded')
|
||||
}
|
||||
const settingName = 'ui.sidebar.expanded';
|
||||
const url = `/user-settings/setSetting/${settingName}`
|
||||
AJAXApi.quickFetchAndPostForm(url, {
|
||||
value: expanded ? 0 : 1
|
||||
}, { provideFeedback: false})
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue