todo implementations

This commit is contained in:
Dennis Eichhorn 2021-11-20 17:10:10 +01:00
parent 8e5669a77d
commit d9c2892e35
8 changed files with 171 additions and 2 deletions

View File

@ -18,6 +18,28 @@ use phpOMS\Account\PermissionType;
use phpOMS\Router\RouteVerb;
return [
'^.*/admin/module/settings\?id=QA$' => [
[
'dest' => '\Modules\QA\Controller\BackendController:viewModuleSettings',
'verb' => RouteVerb::GET,
'permission' => [
'module' => BackendController::NAME,
'type' => PermissionType::READ,
'state' => \Modules\Admin\Models\PermissionState::MODULE,
],
],
],
'^.*/admin/module/settings\?id=QA&app=.*?$' => [
[
'dest' => '\Modules\QA\Controller\BackendController:viewAppSettings',
'verb' => RouteVerb::GET,
'permission' => [
'module' => BackendController::NAME,
'type' => PermissionType::READ,
'state' => \Modules\Admin\Models\PermissionState::MODULE,
],
],
],
'^.*/qa.*$' => [
[
'dest' => '\Modules\QA\Controller\BackendController:setUpBackend',

View File

@ -0,0 +1,72 @@
<?php
/**
* Orange Management
*
* PHP Version 8.0
*
* @package Modules\Auditor
* @copyright Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link https://orange-management.org
*/
declare(strict_types=1);
use phpOMS\Uri\UriFactory;
/**
* @var \phpOMS\Views\View $this
* @var \Modules\QA\Models\QAApp[] $apps
*/
$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('Apps'); ?><i class="fa fa-download floatRight download btn"></i></div>
<div class="slider">
<table id="appList" class="default sticky">
<thead>
<tr>
<td><?= $this->getHtml('ID', '0', '0'); ?>
<label for="appList-sort-1">
<input app="radio" name="appList-sort" id="appList-sort-1">
<i class="sort-asc fa fa-chevron-up"></i>
</label>
<label for="appList-sort-2">
<input app="radio" name="appList-sort" id="appList-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="appList-sort-3">
<input app="radio" name="appList-sort" id="appList-sort-3">
<i class="sort-asc fa fa-chevron-up"></i>
</label>
<label for="appList-sort-4">
<input app="radio" name="appList-sort" id="appList-sort-4">
<i class="sort-desc fa fa-chevron-down"></i>
</label>
<label>
<i class="filter fa fa-filter"></i>
</label>
<tbody>
<?php $count = 0;
foreach ($apps as $key => $app) : ++$count;
$url = UriFactory::build('{/prefix}admin/module/settings?id=QA&app=' . $app->id); ?>
<tr tabindex="0" data-href="<?= $url; ?>">
<td><a href="<?= $url; ?>"><?= $app->getId(); ?></a>
<td><a href="<?= $url; ?>"><?= $this->printHtml($app->name); ?></a>
<?php endforeach; ?>
<?php if ($count === 0) : ?>
<tr><td colspan="8" class="empty"><?= $this->getHtml('Empty', '0', '0'); ?>
<?php endif; ?>
</table>
</div>
</div>
</div>
</div>

View File

@ -14,6 +14,8 @@ declare(strict_types=1);
namespace Modules\QA\Controller;
use Model\NullSetting;
use Model\SettingMapper;
use Modules\QA\Models\QAAppMapper;
use Modules\QA\Models\QAHelperMapper;
use Modules\QA\Models\QAQuestionMapper;
@ -129,4 +131,61 @@ final class BackendController extends Controller
return $view;
}
/**
* Method which generates the module settings 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 viewModuleSettings(RequestAbstract $request, ResponseAbstract $response, $data = null): RenderableInterface
{
$view = new View($this->app->l11nManager, $request, $response);
$view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1000105001, $request, $response));
$id = $request->getData('id') ?? '';
$settings = SettingMapper::getFor($id, 'module');
if (!($settings instanceof NullSetting)) {
$view->setData('settings', !\is_array($settings) ? [$settings] : $settings);
}
$apps = QAAppMapper::getAll();
$view->setData('apps', $apps);
if (\is_file(__DIR__ . '/../Admin/Settings/Theme/Backend/settings.tpl.php')) {
$view->setTemplate('/Modules/' . static::NAME . '/Admin/Settings/Theme/Backend/settings');
} else {
$view->setTemplate('/Modules/Admin/Theme/Backend/modules-settings');
}
return $view;
}
/**
* Method which generates a app settings 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 viewAppSettings(RequestAbstract $request, ResponseAbstract $response, $data = null): RenderableInterface
{
$view = new View($this->app->l11nManager, $request, $response);
$view->setTemplate('/Modules/' . static::NAME . '/Admin/Settings/Theme/Backend/settings-app');
$view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1000105001, $request, $response));
$view->addData('app', QAAppMapper::get((int) $request->getData('app')));
return $view;
}
}

View File

@ -141,7 +141,7 @@ class QAQuestion implements \JsonSerializable
{
$this->createdAt = new \DateTimeImmutable('now');
$this->createdBy = new NullProfile();
$this->app = new QAApp();
$this->app = new NullQAApp(1);
}
/**

View File

@ -62,7 +62,7 @@ echo $this->getData('nav')->render();
<a class="account-info" href="<?= UriFactory::build('{/prefix}profile/single?{?}&id=' . $question->createdBy->getId()); ?>">
<span class="name">
<div class="content"><?= $this->printHtml($question->createdBy->account->name2); ?>, <?= $this->printHtml($question->createdBy->account->name1); ?></div>
<div class="content"><?= $this->printHtml($question->createdBy->account->name2); ?> <?= $this->printHtml($question->createdBy->account->name1); ?></div>
<div class="name-score">Score: <?= $scores[$question->createdBy->account->getId()] ?? 0; ?></div>
</span>

View File

@ -15,6 +15,13 @@
min-width: 50px; }
.qa-question-view .counter-container + .counter-container {
margin-top: 10px; }
.qa-question-view .portlet {
display: flex;
flex-direction: column;
}
.qa-question-view .portlet-body {
height: 100%;
}
.qa .qa-accept {
font-size: 2rem;

View File

@ -25,6 +25,15 @@
min-width: 50px;
}
.portlet {
display: flex;
flex-direction: column;
}
.portlet-body {
height: 100%;
}
.counter-container+.counter-container {
margin-top: 10px;
}