chg: [userSettings] Initial version of template - WiP

pull/72/head
Sami Mokaddem 2021-10-12 10:16:36 +02:00
parent 29ca08ce60
commit 0d6e6aa7a4
No known key found for this signature in database
GPG Key ID: 164C473F627A06FA
5 changed files with 99 additions and 3 deletions

View File

@ -148,6 +148,11 @@ class UsersController extends AppController
}
}
public function settings()
{
$this->set('user', $this->ACL->getUser());
}
public function register()
{
$this->InboxProcessors = TableRegistry::getTableLocator()->get('InboxProcessors');

View File

@ -16,4 +16,14 @@ class Individual extends AppModel
protected $_accessibleOnNew = [
'uuid' => true,
];
protected $_virtual = ['full_name'];
protected function _getFullName()
{
if (empty($this->first_name) && empty($this->last_name)) {
return $this->username;
}
return sprintf("%s %s", $this->first_name, $this->last_name);
}
}

View File

@ -42,8 +42,6 @@ function genNavcard($settingsProvider, $appView)
]);
array_unshift($cardContent, $notice);
$tabsOptions0 = [
// 'vertical' => true,
// 'vertical-size' => 2,
'card' => false,
'pills' => false,
'justify' => 'center',

View File

@ -0,0 +1,80 @@
<?php
use Cake\ORM\TableRegistry;
function isLeaf($setting)
{
return !empty($setting['name']) && !empty($setting['type']);
}
function getResolvableID($sectionName, $panelName = false)
{
$id = sprintf('sp-%s', preg_replace('/(\.|\W)/', '_', h($sectionName)));
if (!empty($panelName)) {
$id .= '-' . preg_replace('/(\.|\W)/', '_', h($panelName));
}
return $id;
}
$settings = [
__('Appearance') => [
'ui.bsTheme' => [
'description' => 'The Bootstrap theme to use for the application',
'default' => 'default',
'name' => 'UI Theme',
'options' => (function () {
$instanceTable = TableRegistry::getTableLocator()->get('Instance');
$themes = $instanceTable->getAvailableThemes();
return array_combine($themes, $themes);
})(),
'severity' => 'info',
'type' => 'select'
],
],
__('Bookmarks') => 'Bookmarks',
__('Account Security') => 'Account Security',
];
$cardNavs = array_keys($settings);
$cardContent = [];
$sectionHtml = '';
foreach ($settings[__('Appearance')] as $sectionName => $sectionContent) {
$sectionHtml .= $this->element('Settings/panel', [
'sectionName' => $sectionName,
'panelName' => $sectionName,
'panelSettings' => $sectionContent,
]);
}
$cardContent[] = $sectionHtml;
$cardContent[] = $settings[__('Bookmarks')];
$cardContent[] = $settings[__('Account Security')];
$tabsOptions = [
'vertical' => true,
'vertical-size' => 2,
'card' => true,
'pills' => true,
'justify' => 'center',
'nav-class' => ['settings-tabs'],
'data' => [
'navs' => $cardNavs,
'content' => $cardContent
]
];
$tabs = $this->Bootstrap->tabs($tabsOptions);
?>
<h2 class="fw-light"><?= __('Account settings') ?></h2>
<div class="p-2">
<div>
<div>
<span class="fw-bold font-monospace me-2 fs-5"><?= h($user->username) ?></span>
<span><?= h($user->individual->full_name) ?></span>
</div>
<div class="fw-light"><?= __('Your personnal account') ?></div>
</div>
<div class="mt-2">
<?= $tabs ?>
</div>
</div>

View File

@ -19,7 +19,10 @@ use Cake\Routing\Router;
<i class="me-1 <?= $this->FontAwesome->getClass('user-circle') ?>"></i>
<?= __('My Account') ?>
</a>
<a class="dropdown-item" href="<?= Router::url(['controller' => 'user-settings', 'action' => 'index', 'plugin' => null, '?' => ['Users.id' => h($this->request->getAttribute('identity')['id'])]]) ?>">
<a
class="dropdown-item"
href="<?= Router::url(['controller' => 'users', 'action' => 'settings', 'plugin' => null, h($this->request->getAttribute('identity')['id'])]) ?>"
>
<i class="me-1 <?= $this->FontAwesome->getClass('user-cog') ?>"></i>
<?= __('Settings') ?>
</a>