This commit is contained in:
Dennis Eichhorn 2023-07-09 02:32:02 +00:00
parent cd6393febe
commit b27061be3b
8 changed files with 34 additions and 30 deletions

View File

@ -14,12 +14,15 @@ declare(strict_types=1);
namespace Modules\Workflow\Admin;
use Modules\Workflow\Admin\Install\Workflow;
use phpOMS\Application\ApplicationAbstract;
use phpOMS\Message\Http\HttpRequest;
use phpOMS\Message\Http\HttpResponse;
use phpOMS\Module\InstallerAbstract;
use phpOMS\System\File\PathException;
use phpOMS\Uri\HttpUri;
use phpOMS\Config\SettingsInterface;
use phpOMS\Module\ModuleInfo;
/**
* Installer class.
@ -39,6 +42,15 @@ final class Installer extends InstallerAbstract
*/
public const PATH = __DIR__;
/**
* {@inheritdoc}
*/
public static function install(ApplicationAbstract $app, ModuleInfo $info, SettingsInterface $cfgHandler) : void
{
parent::install($app, $info, $cfgHandler);
Workflow::install($app, '');
}
/**
* Install data from providing modules.
*

View File

@ -51,17 +51,6 @@ return [
],
],
],
'^.*/workflow/dashboard.*$' => [
[
'dest' => '\Modules\Workflow\Controller\BackendController:viewDashboard',
'verb' => RouteVerb::GET,
'permission' => [
'module' => BackendController::NAME,
'type' => PermissionType::CREATE,
'state' => PermissionCategory::WORKFLOW,
],
],
],
'^.*/workflow/instance/list.*$' => [
[
'dest' => '\Modules\Workflow\Controller\BackendController:viewInstanceList',

View File

@ -445,7 +445,7 @@ final class ApiController extends Controller
return;
}
$actions = \json_decode(\file_get_contents(__DIR__ . '/../Definitions/actions.json'), true);
$actions = \json_decode($actionContent, true);
if (!\is_array($actions)) {
$this->fillJsonResponse($request, $response, NotificationLevel::ERROR, 'Template', 'Template creation failed', $template);

View File

@ -146,21 +146,14 @@ final class BackendController extends Controller
*
* @return RenderableInterface
*
* @todo: remove, the router is already adjusted.
*
* @since 1.0.0
* @codeCoverageIgnore
*/
public function viewDashboard(RequestAbstract $request, ResponseAbstract $response, mixed $data = null) : RenderableInterface
{
$view = new View($this->app->l11nManager, $request, $response);
$view->setTemplate('/Modules/Workflow/Theme/Backend/workflow-dashboard');
$view->data['nav'] = $this->app->moduleManager->get('Navigation')->createNavigationMid(1005501001, $request, $response);
$instances = WorkflowInstanceAbstractMapper::getAll()
->execute();
$view->data['instances'] = $instances;
return $view;
return $this->viewInstanceList($request, $response, $data);
}
/**
@ -183,6 +176,7 @@ final class BackendController extends Controller
/** @var \Modules\Workflow\Models\WorkflowInstanceAbstract $instances */
$instances = WorkflowInstanceAbstractMapper::getAll()
->with('template')
->execute();
$view->data['instances'] = $instances;

View File

@ -19,6 +19,7 @@ return ['Workflow' => [
'Created' => 'Created',
'Name' => 'Name',
'Creator' => 'Creator',
'Date' => 'Date',
'Due' => 'Due',
'Media' => 'Media',
'Message' => 'Message',
@ -32,4 +33,8 @@ return ['Workflow' => [
'Workflow' => 'Workflow',
'Workflows' => 'Workflows',
'Instances' => 'Instances',
':istatus-1' => 'Started',
':istatus-2' => 'Suspended',
':istatus-3' => 'Canceled',
':istatus-4' => 'Done',
]];

View File

@ -27,6 +27,7 @@ echo $this->data['nav']->render(); ?>
<thead>
<td><?= $this->getHtml('Status'); ?>
<td class="wf-100"><?= $this->getHtml('Title'); ?>
<td><?= $this->getHtml('Date'); ?>
<tbody>
<?php
$c = 0;
@ -35,7 +36,8 @@ echo $this->data['nav']->render(); ?>
?>
<tr data-href="<?= $url; ?>">
<td><a href="<?= $url; ?>"><?= $this->printHtml((string) $instance->getStatus()); ?></a>
<td><a href="<?= $url; ?>"><?= $this->printHtml($instance->title); ?></a>
<td><a href="<?= $url; ?>"><?= $this->printHtml($instance->template->name); ?></a>
<td><a href="<?= $url; ?>"><?= $instance->createdAt->format('Y-m-d H:i:s'); ?></a>
<?php endforeach; if ($c == 0) : ?>
<tr><td colspan="6" class="empty"><?= $this->getHtml('Empty', '0', '0'); ?>
<?php endif; ?>

View File

@ -25,21 +25,23 @@ echo $this->data['nav']->render(); ?>
<div class="portlet-head"><?= $this->getHtml('Instances'); ?><i class="lni lni-download download btn end-xs"></i></div>
<table class="default">
<thead>
<td><?= $this->getHtml('Date'); ?>
<td><?= $this->getHtml('Status'); ?>
<td class="wf-100"><?= $this->getHtml('Title'); ?>
<tbody>
<?php
$c = 0;
foreach ($instances as $key => $instance) : ++$c;
$url = \phpOMS\Uri\UriFactory::build('workflow/instance/profile?{?}&id=' . $instance->id);
$url = \phpOMS\Uri\UriFactory::build('{/base}/workflow/instance/profile?{?}&id=' . $instance->id);
?>
<tr data-href="<?= $url; ?>">
<td><a href="<?= $url; ?>"><?= $this->printHtml((string) $instance->getStatus()); ?></a>
<td><a href="<?= $url; ?>"><?= $this->printHtml($instance->title); ?></a>
<td><a href="<?= $url; ?>"><?= $instance->createdAt->format('Y-m-d H:i:s'); ?></a>
<td><a href="<?= $url; ?>"><?= $this->getHtml(':istatus-' . $instance->getStatus()); ?></a>
<td><a href="<?= $url; ?>"><?= $this->printHtml($instance->template->name); ?></a>
<?php endforeach; if ($c == 0) : ?>
<tr><td colspan="6" class="empty"><?= $this->getHtml('Empty', '0', '0'); ?>
<?php endif; ?>
</table>
</div>
</div>
</div>
</div>

View File

@ -302,7 +302,7 @@ if (\defined('RESET') && RESET === '1') {
$db->exec('DROP DATABASE IF EXISTS ' . $CONFIG['db']['core']['masters']['admin']['database']);
$db->exec('CREATE DATABASE IF NOT EXISTS ' . $CONFIG['db']['core']['masters']['admin']['database']);
$db = null;
} catch (\Throwable $t) {
} catch (\Throwable $_) {
echo "\nCouldn't connect to MYSQL DB\n";
}
}
@ -317,7 +317,7 @@ if (\defined('RESET') && RESET === '1') {
$db->exec('DROP DATABASE IF EXISTS ' . $CONFIG['db']['core']['postgresql']['admin']['database']);
$db->exec('CREATE DATABASE ' . $CONFIG['db']['core']['postgresql']['admin']['database']);
$db = null;
} catch (\Throwable $t) {
} catch (\Throwable $_) {
echo "\nCouldn't connect to POSTGRESQL DB\n";
}
}
@ -332,7 +332,7 @@ if (\defined('RESET') && RESET === '1') {
$db->exec('DROP DATABASE IF EXISTS ' . $CONFIG['db']['core']['mssql']['admin']['database']);
$db->exec('CREATE DATABASE ' . $CONFIG['db']['core']['mssql']['admin']['database']);
$db = null;
} catch (\Throwable $t) {
} catch (\Throwable $_) {
echo "\nCouldn't connect to MSSQL DB\n";
}
}