bug fixes and permission tests

This commit is contained in:
Dennis Eichhorn 2022-01-22 21:56:01 +01:00
parent 97f3e61864
commit 68e82d0238
6 changed files with 203 additions and 4 deletions

View File

@ -0,0 +1,17 @@
[
{
"id": 1000501001,
"pid": "/admin/module",
"type": 3,
"subtype": 1,
"name": "Navigation",
"uri": "{/prefix}admin/module/navigation/list?{?}",
"target": "self",
"icon": null,
"order": 10,
"from": "Navigation",
"permission": { "permission": 2, "type": null, "element": null },
"parent": 1000105001,
"children": []
}
]

View File

@ -0,0 +1,43 @@
<?php
/**
* Orange Management
*
* PHP Version 8.0
*
* @package Modules\Navigation\Admin\Install
* @copyright Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link https://orange-management.org
*/
declare(strict_types=1);
namespace Modules\Navigation\Admin\Install;
use phpOMS\Application\ApplicationAbstract;
/**
* Navigation class.
*
* @package Modules\Navigation\Admin\Install
* @license OMS License 1.0
* @link https://orange-management.org
* @since 1.0.0
*/
class Navigation
{
/**
* Install navigation providing
*
* @param string $path Module path
* @param ApplicationAbstract $app Application
*
* @return void
*
* @since 1.0.0
*/
public static function install(string $path, ApplicationAbstract $app) : void
{
\Modules\Navigation\Admin\Installer::installExternal($app, ['path' => __DIR__ . '/Navigation.install.json']);
}
}

View File

@ -39,4 +39,15 @@ return [
],
],
],
'^.*/admin/module/navigation/list\?.*$' => [
[
'dest' => '\Modules\Navigation\Controller\BackendController:viewModuleNavigationList',
'verb' => RouteVerb::GET,
'permission' => [
'module' => BackendController::NAME,
'type' => PermissionType::READ,
'state' => \Modules\Admin\Models\PermissionState::MODULE,
],
],
],
];

View File

@ -0,0 +1,100 @@
<?php
/**
* Orange Management
*
* PHP Version 8.0
*
* @package Modules\Admin\Template\Backend
* @copyright Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link https://orange-management.org
*/
declare(strict_types=1);
use phpOMS\Message\Http\HttpHeader;
/**
* @var \phpOMS\Views\View $this
*/
$navs = $this->getData('navs') ?? [];
$apps = $this->getData('apps') ?? [];
echo $this->getData('nav')->render();
?>
<div class="row">
<div class="col-xs-12">
<div class="portlet">
<div class="portlet-head"><?= $this->getHtml('Logs'); ?><i class="fa fa-download floatRight download btn"></i></div>
<div class="slider">
<table id="navElements" class="default sticky">
<thead>
<tr>
<td><?= $this->getHtml('Active'); ?>
<td><?= $this->getHtml('App'); ?>
<label for="navElements-sort-1">
<input type="radio" name="navElements-sort" id="navElements-sort-1">
<i class="sort-asc fa fa-chevron-up"></i>
</label>
<label for="navElements-sort-2">
<input type="radio" name="navElements-sort" id="navElements-sort-2">
<i class="sort-desc fa fa-chevron-down"></i>
</label>
<label>
<i class="filter fa fa-filter"></i>
</label>
<td><?= $this->getHtml('ID', '0', '0'); ?>
<label for="navElements-sort-1">
<input type="radio" name="navElements-sort" id="navElements-sort-1">
<i class="sort-asc fa fa-chevron-up"></i>
</label>
<label for="navElements-sort-2">
<input type="radio" name="navElements-sort" id="navElements-sort-2">
<i class="sort-desc fa fa-chevron-down"></i>
</label>
<label>
<i class="filter fa fa-filter"></i>
</label>
<td><?= $this->getHtml('Name'); ?>
<label for="navElements-sort-1">
<input type="radio" name="navElements-sort" id="navElements-sort-1">
<i class="sort-asc fa fa-chevron-up"></i>
</label>
<label for="navElements-sort-2">
<input type="radio" name="navElements-sort" id="navElements-sort-2">
<i class="sort-desc fa fa-chevron-down"></i>
</label>
<label>
<i class="filter fa fa-filter"></i>
</label>
<td><?= $this->getHtml('Link'); ?>
<label for="navElements-sort-1">
<input type="radio" name="navElements-sort" id="navElements-sort-1">
<i class="sort-asc fa fa-chevron-up"></i>
</label>
<label for="navElements-sort-2">
<input type="radio" name="navElements-sort" id="navElements-sort-2">
<i class="sort-desc fa fa-chevron-down"></i>
</label>
<label>
<i class="filter fa fa-filter"></i>
</label>
</thead>
<tbody>
<?php $c = 0;
foreach ($navs as $nav) : ++$c; ?>
<tr>
<td><label class="checkbox" for="iActive-<?= $c ?>">
<input id="iActive-<?= $c ?>" type="checkbox" name="active_route" value="<?= $this->printHtml($nav->uri); ?>"<?= true ? ' checked' : ''; ?>>
<span class="checkmark"></span>
</label>
<td><?= $apps[$nav->app]?->name; ?>
<td><?= $nav->id; ?>
<td><?= $nav->name; ?>
<td><?= $nav->uri; ?>
<?php endforeach; ?>
</table>
</div>
</div>
</div>

View File

@ -79,10 +79,8 @@ jsOMS.Modules.Navigation = class {
|| document.body.clientWidth;
/**
* @todo Orange-Management/Modules#192
* The sidebar navigation is not working properly in many cases
* 1. if the content is too wide then the side nav becomes smaller (resize window for testing)
* 2. if the device is a handheld device it feels unintuitive to open/hide the navigation
* @todo Navigation sidebar width
* The sidebar navigation is not working properly if the content is too wide then the side nav becomes smaller (resize window for testing)
*/
e.nextElementSibling.checked = width < 800;
}

View File

@ -16,6 +16,7 @@ namespace Modules\Navigation\Controller;
use Model\NullSetting;
use Model\SettingMapper;
use Modules\Admin\Models\AppMapper;
use Modules\Navigation\Models\NavElementMapper;
use Modules\Navigation\Models\Navigation;
use Modules\Navigation\Views\NavigationView;
@ -214,4 +215,33 @@ final class BackendController extends Controller
return $view;
}
/**
* Method which generates the module profile view.
*
* @param RequestAbstract $request Request
* @param ResponseAbstract $response Response
* @param mixed $data Generic data
*
* @return RenderableInterface Response can be rendered
*
* @since 1.0.0
*/
public function viewModuleNavigationList(RequestAbstract $request, ResponseAbstract $response, $data = null) : RenderableInterface
{
$view = new View($this->app->l11nManager, $request, $response);
$view->setTemplate('/Modules/Navigation/Admin/Settings/Theme/Backend/modules-nav-list');
$view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1000105001, $request, $response));
$module = $request->getData('id') ?? '';
$view->setData('module', $module);
$activeNavElements = NavElementMapper::getAll()->where('from', $module)->execute();
$view->setData('navs', $activeNavElements);
$apps = AppMapper::getAll()->execute();
$view->setData('apps', $apps);
return $view;
}
}