auto fixes + some impl.

This commit is contained in:
Dennis Eichhorn 2024-01-26 22:53:59 +00:00
parent dccf1df831
commit 6549ec0323
12 changed files with 107 additions and 96 deletions

View File

@ -20,7 +20,6 @@ use phpOMS\Message\Http\HttpRequest;
use phpOMS\Message\Http\HttpResponse;
use phpOMS\Module\InstallerAbstract;
use phpOMS\Module\ModuleInfo;
use phpOMS\Uri\HttpUri;
/**
* Installer class.
@ -83,7 +82,7 @@ final class Installer extends InstallerAbstract
foreach ($layouts as $layout) {
$response = new HttpResponse();
$request = new HttpRequest(new HttpUri(''));
$request = new HttpRequest();
$request->header->account = 1;
$request->setData('title', \reset($layout['l11n']));
@ -123,7 +122,7 @@ final class Installer extends InstallerAbstract
}
$response = new HttpResponse();
$request = new HttpRequest(new HttpUri(''));
$request = new HttpRequest();
$request->header->account = 1;
$request->setData('title', $l11n);

View File

@ -6,7 +6,7 @@ use phpOMS\Account\PermissionType;
use phpOMS\Router\RouteVerb;
return [
'^.*/warehouse/labeling/item/list.*$' => [
'^.*/warehouse/labeling/item/list(\?.*$|$)' => [
[
'dest' => '\Modules\Labeling\Controller\BackendController:viewItemList',
'verb' => RouteVerb::GET,
@ -17,7 +17,7 @@ return [
],
],
],
'^.*/warehouse/labeling/item\?.*$' => [
'^.*/warehouse/labeling/item(\?.*$|$)' => [
[
'dest' => '\Modules\Labeling\Controller\BackendController:viewItem',
'verb' => RouteVerb::GET,
@ -28,7 +28,7 @@ return [
],
],
],
'^.*/warehouse/labeling/layout\?.*$' => [
'^.*/warehouse/labeling/layout(\?.*$|$)' => [
[
'dest' => '\Modules\Labeling\Controller\BackendController:viewLayout',
'verb' => RouteVerb::GET,
@ -39,7 +39,7 @@ return [
],
],
],
'^.*/warehouse/labeling/layout/list.*$' => [
'^.*/warehouse/labeling/layout/list(\?.*$|$)' => [
[
'dest' => '\Modules\Labeling\Controller\BackendController:viewItemLabelList',
'verb' => RouteVerb::GET,

View File

@ -94,7 +94,10 @@ final class ApiController extends Controller
private function createLabelLayoutFromRequest(RequestAbstract $request) : LabelLayout
{
$labelLayout = new LabelLayout();
$labelLayout->setL11n($request->getDataString('title') ?? '', $request->getDataString('language') ?? ISO639x1Enum::_EN);
$labelLayout->setL11n(
$request->getDataString('title') ?? '',
ISO639x1Enum::tryFromValue($request->getDataString('language')) ?? ISO639x1Enum::_EN
);
$path = '/Modules/Labeling/Templates/' . $request->getDataString('title');
$uploadedFiles = $request->files;
@ -176,12 +179,10 @@ final class ApiController extends Controller
*/
private function createLabelLayoutL11nFromRequest(RequestAbstract $request) : BaseStringL11n
{
$labelLayoutL11n = new BaseStringL11n();
$labelLayoutL11n->ref = $request->getDataInt('layout') ?? 0;
$labelLayoutL11n->setLanguage(
$request->getDataString('language') ?? $request->header->l11n->language
);
$labelLayoutL11n->content = $request->getDataString('title') ?? '';
$labelLayoutL11n = new BaseStringL11n();
$labelLayoutL11n->ref = $request->getDataInt('layout') ?? 0;
$labelLayoutL11n->language = ISO639x1Enum::tryFromValue($request->getDataString('language')) ?? $request->header->l11n->language;
$labelLayoutL11n->content = $request->getDataString('title') ?? '';
return $labelLayoutL11n;
}

View File

@ -60,13 +60,13 @@ class LabelLayout implements \JsonSerializable
if ($l11n instanceof BaseStringL11n) {
$this->l11n = $l11n;
} elseif (isset($this->l11n) && $this->l11n instanceof BaseStringL11n) {
$this->l11n->content = $l11n;
$this->l11n->setLanguage($lang);
$this->l11n->content = $l11n;
$this->l11n->language = $lang;
} else {
$this->l11n = new BaseStringL11n();
$this->l11n->content = $l11n;
$this->l11n->ref = $this->id;
$this->l11n->setLanguage($lang);
$this->l11n = new BaseStringL11n();
$this->l11n->content = $l11n;
$this->l11n->ref = $this->id;
$this->l11n->language = $lang;
}
}
@ -90,7 +90,7 @@ class LabelLayout implements \JsonSerializable
public function toArray() : array
{
return [
'id' => $this->id,
'id' => $this->id,
];
}

View File

@ -37,10 +37,10 @@ final class LabelLayoutL11nMapper extends DataMapperFactory
* @since 1.0.0
*/
public const COLUMNS = [
'labeling_layout_l11n_id' => ['name' => 'labeling_layout_l11n_id', 'type' => 'int', 'internal' => 'id'],
'labeling_layout_l11n_name' => ['name' => 'labeling_layout_l11n_name', 'type' => 'string', 'internal' => 'content', 'autocomplete' => true],
'labeling_layout_l11n_type' => ['name' => 'labeling_layout_l11n_type', 'type' => 'int', 'internal' => 'ref'],
'labeling_layout_l11n_language' => ['name' => 'labeling_layout_l11n_language', 'type' => 'string', 'internal' => 'language'],
'labeling_layout_l11n_id' => ['name' => 'labeling_layout_l11n_id', 'type' => 'int', 'internal' => 'id'],
'labeling_layout_l11n_name' => ['name' => 'labeling_layout_l11n_name', 'type' => 'string', 'internal' => 'content', 'autocomplete' => true],
'labeling_layout_l11n_type' => ['name' => 'labeling_layout_l11n_type', 'type' => 'int', 'internal' => 'ref'],
'labeling_layout_l11n_language' => ['name' => 'labeling_layout_l11n_language', 'type' => 'string', 'internal' => 'language'],
];
/**

View File

@ -37,8 +37,8 @@ final class LabelLayoutMapper extends DataMapperFactory
* @since 1.0.0
*/
public const COLUMNS = [
'labeling_layout_id' => ['name' => 'labeling_layout_id', 'type' => 'int', 'internal' => 'id'],
'labeling_layout_template' => ['name' => 'labeling_layout_template', 'type' => 'int', 'internal' => 'template'],
'labeling_layout_id' => ['name' => 'labeling_layout_id', 'type' => 'int', 'internal' => 'id'],
'labeling_layout_template' => ['name' => 'labeling_layout_template', 'type' => 'int', 'internal' => 'template'],
];
/**
@ -49,11 +49,11 @@ final class LabelLayoutMapper extends DataMapperFactory
*/
public const HAS_MANY = [
'l11n' => [
'mapper' => LabelLayoutL11nMapper::class,
'table' => 'labeling_layout_l11n',
'self' => 'labeling_layout_l11n_type',
'column' => 'content',
'external' => null,
'mapper' => LabelLayoutL11nMapper::class,
'table' => 'labeling_layout_l11n',
'self' => 'labeling_layout_l11n_type',
'column' => 'content',
'external' => null,
],
];
@ -64,9 +64,9 @@ final class LabelLayoutMapper extends DataMapperFactory
* @since 1.0.0
*/
public const OWNS_ONE = [
'template' => [
'mapper' => CollectionMapper::class,
'external' => 'labeling_layout_template',
'template' => [
'mapper' => CollectionMapper::class,
'external' => 'labeling_layout_template',
],
];

View File

@ -15,6 +15,6 @@ declare(strict_types=1);
return ['Navigation' => [
'Labeling' => 'Etikettierung',
'List' => 'Liste',
'Layouts' => 'Designs',
'Layouts' => 'Designs',
'Name' => 'Name',
]];

View File

@ -15,6 +15,6 @@ declare(strict_types=1);
return ['Navigation' => [
'Labeling' => 'Labeling',
'List' => 'List',
'Layouts' => 'Layouts',
'Layouts' => 'Layouts',
'Name' => 'Name',
]];

View File

@ -25,53 +25,53 @@ echo $this->data['nav']->render(); ?>
<section class="portlet">
<div class="portlet-head"><?= $this->getHtml('Items', 'ItemManagement', 'Backend'); ?><i class="g-icon download btn end-xs">download</i></div>
<div class="slider">
<table id="iSalesItemList" class="default sticky">
<table id="iItemList" class="default sticky">
<thead>
<tr>
<td>
<td><?= $this->getHtml('Number', 'ItemManagement', 'Backend'); ?>
<label for="iSalesItemList-sort-1">
<input type="radio" name="iSalesItemList-sort" id="iSalesItemList-sort-1">
<label for="iItemList-sort-1">
<input type="radio" name="iItemList-sort" id="iItemList-sort-1">
<i class="sort-asc g-icon">expand_less</i>
</label>
<label for="iSalesItemList-sort-2">
<input type="radio" name="iSalesItemList-sort" id="iSalesItemList-sort-2">
<label for="iItemList-sort-2">
<input type="radio" name="iItemList-sort" id="iItemList-sort-2">
<i class="sort-desc g-icon">expand_more</i>
</label>
<label>
<i class="filter g-icon">filter_alt</i>
</label>
<td><?= $this->getHtml('Name', 'ItemManagement', 'Backend'); ?>
<label for="iSalesItemList-sort-3">
<input type="radio" name="iSalesItemList-sort" id="iSalesItemList-sort-3">
<label for="iItemList-sort-3">
<input type="radio" name="iItemList-sort" id="iItemList-sort-3">
<i class="sort-asc g-icon">expand_less</i>
</label>
<label for="iSalesItemList-sort-4">
<input type="radio" name="iSalesItemList-sort" id="iSalesItemList-sort-4">
<label for="iItemList-sort-4">
<input type="radio" name="iItemList-sort" id="iItemList-sort-4">
<i class="sort-desc g-icon">expand_more</i>
</label>
<label>
<i class="filter g-icon">filter_alt</i>
</label>
<td><?= $this->getHtml('Name', 'ItemManagement', 'Backend'); ?>
<label for="iSalesItemList-sort-5">
<input type="radio" name="iSalesItemList-sort" id="iSalesItemList-sort-5">
<label for="iItemList-sort-5">
<input type="radio" name="iItemList-sort" id="iItemList-sort-5">
<i class="sort-asc g-icon">expand_less</i>
</label>
<label for="iSalesItemList-sort-6">
<input type="radio" name="iSalesItemList-sort" id="iSalesItemList-sort-6">
<label for="iItemList-sort-6">
<input type="radio" name="iItemList-sort" id="iItemList-sort-6">
<i class="sort-desc g-icon">expand_more</i>
</label>
<label>
<i class="filter g-icon">filter_alt</i>
</label>
<td class="wf-100"><?= $this->getHtml('Name', 'ItemManagement', 'Backend'); ?>
<label for="iSalesItemList-sort-7">
<input type="radio" name="iSalesItemList-sort" id="iSalesItemList-sort-7">
<label for="iItemList-sort-7">
<input type="radio" name="iItemList-sort" id="iItemList-sort-7">
<i class="sort-asc g-icon">expand_less</i>
</label>
<label for="iSalesItemList-sort-8">
<input type="radio" name="iSalesItemList-sort" id="iSalesItemList-sort-8">
<label for="iItemList-sort-8">
<input type="radio" name="iItemList-sort" id="iItemList-sort-8">
<i class="sort-desc g-icon">expand_more</i>
</label>
<label>

View File

@ -25,29 +25,29 @@ echo $this->data['nav']->render(); ?>
<section class="portlet">
<div class="portlet-head"><?= $this->getHtml('Layouts'); ?><i class="g-icon download btn end-xs">download</i></div>
<div class="slider">
<table id="iSalesItemList" class="default sticky">
<table id="iLayoutList" class="default sticky">
<thead>
<tr>
<td>
<td><?= $this->getHtml('ID', '0', '0'); ?>
<label for="iSalesItemList-sort-1">
<input type="radio" name="iSalesItemList-sort" id="iSalesItemList-sort-1">
<label for="iLayoutList-sort-1">
<input type="radio" name="iLayoutList-sort" id="iLayoutList-sort-1">
<i class="sort-asc g-icon">expand_less</i>
</label>
<label for="iSalesItemList-sort-2">
<input type="radio" name="iSalesItemList-sort" id="iSalesItemList-sort-2">
<label for="iLayoutList-sort-2">
<input type="radio" name="iLayoutList-sort" id="iLayoutList-sort-2">
<i class="sort-desc g-icon">expand_more</i>
</label>
<label>
<i class="filter g-icon">filter_alt</i>
</label>
<td class="wf-100"><?= $this->getHtml('Name'); ?>
<label for="iSalesItemList-sort-1">
<input type="radio" name="iSalesItemList-sort" id="iSalesItemList-sort-1">
<label for="iLayoutList-sort-1">
<input type="radio" name="iLayoutList-sort" id="iLayoutList-sort-1">
<i class="sort-asc g-icon">expand_less</i>
</label>
<label for="iSalesItemList-sort-2">
<input type="radio" name="iSalesItemList-sort" id="iSalesItemList-sort-2">
<label for="iLayoutList-sort-2">
<input type="radio" name="iLayoutList-sort" id="iLayoutList-sort-2">
<i class="sort-desc g-icon">expand_more</i>
</label>
<label>
@ -55,7 +55,7 @@ echo $this->data['nav']->render(); ?>
</label>
<tbody>
<?php $count = 0; foreach ($layouts as $key => $value) : ++$count;
$url = UriFactory::build('{/base}/warehouse/labeling/layout?id=' . $value->id);
$url = UriFactory::build('{/base}/warehouse/labeling/layout?id=' . $value->id);
?>
<tr data-href="<?= $url; ?>">
<td>

View File

@ -75,8 +75,8 @@ final class Autoloader
*/
public static function defaultAutoloader(string $class) : void
{
$class = \ltrim($class, '\\');
$class = \strtr($class, '_\\', '//');
$class = \ltrim($class, '\\');
$class = \strtr($class, '_\\', '//');
if (\stripos($class, 'Web/Backend') !== false || \stripos($class, 'Web/Api') !== false) {
$class = \is_dir(__DIR__ . '/Web') ? $class : \str_replace('Web/', 'MainRepository/Web/', $class);

View File

@ -1,4 +1,15 @@
<?php
/**
* Jingga
*
* PHP Version 8.1
*
* @package Modules\Labeling\tests
* @copyright Dennis Eichhorn
* @license OMS License 2.0
* @version 1.0.0
* @link https://jingga.app
*/
declare(strict_types=1);
\ini_set('memory_limit', '2048M');
@ -67,10 +78,10 @@ $GLOBALS['is_github'] = $IS_GITHUB;
$tmp = FileLogger::getInstance(__DIR__ . '/../Logs');
$CONFIG = [
'db' => [
'db' => [
'core' => [
'masters' => [
'admin' => [
'admin' => [
'db' => 'mysql', /* db type */
'host' => '127.0.0.1', /* db host address */
'port' => '3306', /* db host port */
@ -80,7 +91,7 @@ $CONFIG = [
'weight' => 1000, /* db table prefix */
'datetimeformat' => 'Y-m-d H:i:s',
],
'insert' => [
'insert' => [
'db' => 'mysql', /* db type */
'host' => '127.0.0.1', /* db host address */
'port' => '3306', /* db host port */
@ -90,7 +101,7 @@ $CONFIG = [
'weight' => 1000, /* db table prefix */
'datetimeformat' => 'Y-m-d H:i:s',
],
'select' => [
'select' => [
'db' => 'mysql', /* db type */
'host' => '127.0.0.1', /* db host address */
'port' => '3306', /* db host port */
@ -100,7 +111,7 @@ $CONFIG = [
'weight' => 1000, /* db table prefix */
'datetimeformat' => 'Y-m-d H:i:s',
],
'update' => [
'update' => [
'db' => 'mysql', /* db type */
'host' => '127.0.0.1', /* db host address */
'port' => '3306', /* db host port */
@ -110,7 +121,7 @@ $CONFIG = [
'weight' => 1000, /* db table prefix */
'datetimeformat' => 'Y-m-d H:i:s',
],
'delete' => [
'delete' => [
'db' => 'mysql', /* db type */
'host' => '127.0.0.1', /* db host address */
'port' => '3306', /* db host port */
@ -120,7 +131,7 @@ $CONFIG = [
'weight' => 1000, /* db table prefix */
'datetimeformat' => 'Y-m-d H:i:s',
],
'schema' => [
'schema' => [
'db' => 'mysql', /* db type */
'host' => '127.0.0.1', /* db host address */
'port' => '3306', /* db host port */
@ -132,7 +143,7 @@ $CONFIG = [
],
],
'postgresql' => [
'admin' => [
'admin' => [
'db' => 'pgsql', /* db type */
'host' => '127.0.0.1', /* db host address */
'port' => '5432', /* db host port */
@ -142,7 +153,7 @@ $CONFIG = [
'weight' => 1000, /* db table prefix */
'datetimeformat' => 'Y-m-d H:i:s',
],
'insert' => [
'insert' => [
'db' => 'pgsql', /* db type */
'host' => '127.0.0.1', /* db host address */
'port' => '5432', /* db host port */
@ -152,7 +163,7 @@ $CONFIG = [
'weight' => 1000, /* db table prefix */
'datetimeformat' => 'Y-m-d H:i:s',
],
'select' => [
'select' => [
'db' => 'pgsql', /* db type */
'host' => '127.0.0.1', /* db host address */
'port' => '5432', /* db host port */
@ -162,7 +173,7 @@ $CONFIG = [
'weight' => 1000, /* db table prefix */
'datetimeformat' => 'Y-m-d H:i:s',
],
'update' => [
'update' => [
'db' => 'pgsql', /* db type */
'host' => '127.0.0.1', /* db host address */
'port' => '5432', /* db host port */
@ -172,7 +183,7 @@ $CONFIG = [
'weight' => 1000, /* db table prefix */
'datetimeformat' => 'Y-m-d H:i:s',
],
'delete' => [
'delete' => [
'db' => 'pgsql', /* db type */
'host' => '127.0.0.1', /* db host address */
'port' => '5432', /* db host port */
@ -182,7 +193,7 @@ $CONFIG = [
'weight' => 1000, /* db table prefix */
'datetimeformat' => 'Y-m-d H:i:s',
],
'schema' => [
'schema' => [
'db' => 'pgsql', /* db type */
'host' => '127.0.0.1', /* db host address */
'port' => '5432', /* db host port */
@ -194,37 +205,37 @@ $CONFIG = [
],
],
'sqlite' => [
'admin' => [
'admin' => [
'db' => 'sqlite', /* db type */
'database' => __DIR__ . '/../Karaka/phpOMS/Localization/Defaults/localization.sqlite', /* db name */
'weight' => 1000, /* db table prefix */
'datetimeformat' => 'Y-m-d H:i:s',
],
'insert' => [
'insert' => [
'db' => 'sqlite', /* db type */
'database' => __DIR__ . '/../Karaka/phpOMS/Localization/Defaults/localization.sqlite', /* db name */
'weight' => 1000, /* db table prefix */
'datetimeformat' => 'Y-m-d H:i:s',
],
'select' => [
'select' => [
'db' => 'sqlite', /* db type */
'database' => __DIR__ . '/../Karaka/phpOMS/Localization/Defaults/localization.sqlite', /* db name */
'weight' => 1000, /* db table prefix */
'datetimeformat' => 'Y-m-d H:i:s',
],
'update' => [
'update' => [
'db' => 'sqlite', /* db type */
'database' => __DIR__ . '/../Karaka/phpOMS/Localization/Defaults/localization.sqlite', /* db name */
'weight' => 1000, /* db table prefix */
'datetimeformat' => 'Y-m-d H:i:s',
],
'delete' => [
'delete' => [
'db' => 'sqlite', /* db type */
'database' => __DIR__ . '/../Karaka/phpOMS/Localization/Defaults/localization.sqlite', /* db name */
'weight' => 1000, /* db table prefix */
'datetimeformat' => 'Y-m-d H:i:s',
],
'schema' => [
'schema' => [
'db' => 'sqlite', /* db type */
'database' => __DIR__ . '/../Karaka/phpOMS/Localization/Defaults/localization.sqlite', /* db name */
'weight' => 1000, /* db table prefix */
@ -232,7 +243,7 @@ $CONFIG = [
],
],
'mssql' => [
'admin' => [
'admin' => [
'db' => 'mssql', /* db type */
'host' => '127.0.0.1', /* db host address */
'port' => '1433', /* db host port */
@ -242,7 +253,7 @@ $CONFIG = [
'weight' => 1000, /* db table prefix */
'datetimeformat' => 'Y-m-d H:i:s',
],
'insert' => [
'insert' => [
'db' => 'mssql', /* db type */
'host' => '127.0.0.1', /* db host address */
'port' => '1433', /* db host port */
@ -252,7 +263,7 @@ $CONFIG = [
'weight' => 1000, /* db table prefix */
'datetimeformat' => 'Y-m-d H:i:s',
],
'select' => [
'select' => [
'db' => 'mssql', /* db type */
'host' => '127.0.0.1', /* db host address */
'port' => '1433', /* db host port */
@ -262,7 +273,7 @@ $CONFIG = [
'weight' => 1000, /* db table prefix */
'datetimeformat' => 'Y-m-d H:i:s',
],
'update' => [
'update' => [
'db' => 'mssql', /* db type */
'host' => '127.0.0.1', /* db host address */
'port' => '1433', /* db host port */
@ -272,7 +283,7 @@ $CONFIG = [
'weight' => 1000, /* db table prefix */
'datetimeformat' => 'Y-m-d H:i:s',
],
'delete' => [
'delete' => [
'db' => 'mssql', /* db type */
'host' => '127.0.0.1', /* db host address */
'port' => '1433', /* db host port */
@ -282,7 +293,7 @@ $CONFIG = [
'weight' => 1000, /* db table prefix */
'datetimeformat' => 'Y-m-d H:i:s',
],
'schema' => [
'schema' => [
'db' => 'mssql', /* db type */
'host' => '127.0.0.1', /* db host address */
'port' => '1433', /* db host port */
@ -322,16 +333,16 @@ $CONFIG = [
'password' => '123456',
],
],
'log' => [
'log' => [
'file' => [
'path' => __DIR__ . '/Logs',
],
],
'page' => [
'page' => [
'root' => '/',
'https' => false,
],
'app' => [
'app' => [
'path' => __DIR__,
'default' => [
'app' => 'Backend',
@ -350,7 +361,7 @@ $CONFIG = [
],
],
],
'socket' => [
'socket' => [
'master' => [
'host' => '127.0.0.1',
'limit' => 300,
@ -360,7 +371,7 @@ $CONFIG = [
'language' => [
'en',
],
'apis' => [
'apis' => [
],
];