started with template fixes

This commit is contained in:
Dennis Eichhorn 2024-03-29 15:26:00 +00:00
parent 6d8e4ee44d
commit 868255f65c
12 changed files with 164 additions and 199 deletions

View File

@ -93,7 +93,7 @@
"pid": "/equipment/inspection",
"type": 3,
"subtype": 1,
"name": "EquipmentInspectionTypes",
"name": "InspectionTypes",
"uri": "{/base}/equipment/inspection/type/list?{?}",
"target": "self",
"icon": null,
@ -110,7 +110,7 @@
"pid": "/",
"type": 2,
"subtype": 1,
"name": "EquipmentAttributes",
"name": "Attributes",
"uri": "{/base}/equipment/attribute/type/list?{?}",
"target": "self",
"icon": null,

View File

@ -22,6 +22,7 @@ return [
[
'dest' => '\Modules\EquipmentManagement\Controller\ApiController:apiEquipmentFind',
'verb' => RouteVerb::GET,
'csrf' => true,
'permission' => [
'module' => Controller::NAME,
'type' => PermissionType::READ,
@ -34,6 +35,7 @@ return [
[
'dest' => '\Modules\EquipmentManagement\Controller\ApiEquipmentAttributeController:apiEquipmentAttributeCreate',
'verb' => RouteVerb::PUT,
'csrf' => true,
'permission' => [
'module' => Controller::NAME,
'type' => PermissionType::READ,
@ -43,6 +45,7 @@ return [
[
'dest' => '\Modules\EquipmentManagement\Controller\ApiEquipmentAttributeController:apiEquipmentAttributeUpdate',
'verb' => RouteVerb::SET,
'csrf' => true,
'permission' => [
'module' => Controller::NAME,
'type' => PermissionType::READ,
@ -55,6 +58,7 @@ return [
[
'dest' => '\Modules\EquipmentManagement\Controller\ApiController:apiNoteCreate',
'verb' => RouteVerb::PUT,
'csrf' => true,
'permission' => [
'module' => Controller::NAME,
'type' => PermissionType::READ,
@ -64,6 +68,7 @@ return [
[
'dest' => '\Modules\EquipmentManagement\Controller\ApiController:apiNoteUpdate',
'verb' => RouteVerb::SET,
'csrf' => true,
'permission' => [
'module' => Controller::NAME,
'type' => PermissionType::READ,

View File

@ -25,18 +25,51 @@ return [
'permission' => [
'module' => BackendController::NAME,
'type' => PermissionType::READ,
'state' => PermissionCategory::EQUIPMENT,
'state' => PermissionCategory::ATTRIBUTE,
],
],
],
'^.*/equipment/attribute/type(\?.*$|$)' => [
'^.*/equipment/attribute/type/view(\?.*$|$)' => [
[
'dest' => '\Modules\EquipmentManagement\Controller\BackendController:viewEquipmentManagementAttributeType',
'verb' => RouteVerb::GET,
'permission' => [
'module' => BackendController::NAME,
'type' => PermissionType::READ,
'state' => PermissionCategory::EQUIPMENT,
'state' => PermissionCategory::ATTRIBUTE,
],
],
],
'^.*/equipment/attribute/type/create(\?.*$|$)' => [
[
'dest' => '\Modules\EquipmentManagement\Controller\BackendController:viewEquipmentManagementAttributeTypeCreate',
'verb' => RouteVerb::GET,
'permission' => [
'module' => BackendController::NAME,
'type' => PermissionType::CREATE,
'state' => PermissionCategory::ATTRIBUTE,
],
],
],
'^.*/equipment/attribute/value/view(\?.*$|$)' => [
[
'dest' => '\Modules\EquipmentManagement\Controller\BackendController:viewEquipmentManagementAttributeValue',
'verb' => RouteVerb::GET,
'permission' => [
'module' => BackendController::NAME,
'type' => PermissionType::READ,
'state' => PermissionCategory::ATTRIBUTE,
],
],
],
'^.*/equipment/attribute/value/create(\?.*$|$)' => [
[
'dest' => '\Modules\EquipmentManagement\Controller\BackendController:viewEquipmentManagementAttributeValueCreate',
'verb' => RouteVerb::GET,
'permission' => [
'module' => BackendController::NAME,
'type' => PermissionType::CREATE,
'state' => PermissionCategory::ATTRIBUTE,
],
],
],

View File

@ -16,6 +16,8 @@ namespace Modules\EquipmentManagement\Controller;
use Modules\EquipmentManagement\Models\Attribute\EquipmentAttributeTypeL11nMapper;
use Modules\EquipmentManagement\Models\Attribute\EquipmentAttributeTypeMapper;
use Modules\EquipmentManagement\Models\Attribute\EquipmentAttributeValueL11nMapper;
use Modules\EquipmentManagement\Models\Attribute\EquipmentAttributeValueMapper;
use Modules\EquipmentManagement\Models\EquipmentMapper;
use Modules\EquipmentManagement\Models\EquipmentTypeMapper;
use Modules\EquipmentManagement\Models\InspectionMapper;
@ -54,17 +56,15 @@ final class BackendController extends Controller
*/
public function viewEquipmentManagementAttributeTypeList(RequestAbstract $request, ResponseAbstract $response, array $data = []) : RenderableInterface
{
$view = new View($this->app->l11nManager, $request, $response);
$view->setTemplate('/Modules/EquipmentManagement/Theme/Backend/attribute-type-list');
$view = new \Modules\Attribute\Theme\Backend\Components\AttributeTypeListView($this->app->l11nManager, $request, $response);
$view->data['nav'] = $this->app->moduleManager->get('Navigation')->createNavigationMid(1008405001, $request, $response);
/** @var \Modules\Attribute\Models\AttributeType[] $attributes */
$attributes = EquipmentAttributeTypeMapper::getAll()
$view->attributes = EquipmentAttributeTypeMapper::getAll()
->with('l11n')
->where('l11n/language', $response->header->l11n->language)
->execute();
$view->data['attributes'] = $attributes;
$view->path = 'equipment';
return $view;
}
@ -114,23 +114,55 @@ final class BackendController extends Controller
*/
public function viewEquipmentManagementAttributeType(RequestAbstract $request, ResponseAbstract $response, array $data = []) : RenderableInterface
{
$view = new View($this->app->l11nManager, $request, $response);
$view->setTemplate('/Modules/EquipmentManagement/Theme/Backend/attribute-type');
$view->data['nav'] = $this->app->moduleManager->get('Navigation')->createNavigationMid(1004801001, $request, $response);
$view = new \Modules\Attribute\Theme\Backend\Components\AttributeTypeView($this->app->l11nManager, $request, $response);
$view->data['nav'] = $this->app->moduleManager->get('Navigation')->createNavigationMid(1008405001, $request, $response);
/** @var \Modules\Attribute\Models\AttributeType $attribute */
$attribute = EquipmentAttributeTypeMapper::get()
$view->attribute = EquipmentAttributeTypeMapper::get()
->with('l11n')
->with('defaults')
->with('defaults/l11n')
->where('id', (int) $request->getData('id'))
->where('l11n/language', $response->header->l11n->language)
->where('defaults/l11n/language', [$response->header->l11n->language, null])
->execute();
$l11ns = EquipmentAttributeTypeL11nMapper::getAll()
->where('ref', $attribute->id)
$view->l11ns = EquipmentAttributeTypeL11nMapper::getAll()
->where('ref', $view->attribute->id)
->execute();
$view->data['attribute'] = $attribute;
$view->data['l11ns'] = $l11ns;
$view->path = 'fleet/vehicle';
return $view;
}
/**
* Routing end-point for application behavior.
*
* @param RequestAbstract $request Request
* @param ResponseAbstract $response Response
* @param array $data Generic data
*
* @return RenderableInterface
*
* @since 1.0.0
* @codeCoverageIgnore
*/
public function viewEquipmentManagementAttributeValue(RequestAbstract $request, ResponseAbstract $response, array $data = []) : RenderableInterface
{
$view = new \Modules\Attribute\Theme\Backend\Components\AttributeValueView($this->app->l11nManager, $request, $response);
$view->data['nav'] = $this->app->moduleManager->get('Navigation')->createNavigationMid(1008405001, $request, $response);
$view->attribute = EquipmentAttributeValueMapper::get()
->with('l11n')
->where('id', (int) $request->getData('id'))
->where('l11n/language', [$response->header->l11n->language, null])
->execute();
$view->l11ns = EquipmentAttributeValueL11nMapper::getAll()
->where('ref', $view->attribute->id)
->execute();
// @todo Also find the ItemAttributeType
return $view;
}
@ -275,13 +307,11 @@ final class BackendController extends Controller
$view = new View($this->app->l11nManager, $request, $response);
$view->setTemplate('/Modules/EquipmentManagement/Theme/Backend/inspection-list');
$view->data['nav'] = $this->app->moduleManager->get('Navigation')->createNavigationMid(1008401001, $request, $response);
$view->data['nav'] = $this->app->moduleManager->get('Navigation')->createNavigationMid(1008404001, $request, $response);
$list = InspectionMapper::getAll()
$view->data['inspections'] = InspectionMapper::getAll()
->sort('id', 'DESC')
->execute();
$view->data['inspections'] = $list;
->executeGetArray();
return $view;
}

View File

@ -37,4 +37,6 @@ abstract class PermissionCategory extends Enum
public const EQUIPMENT_ATTRIBUTE_TYPE = 6;
public const EQUIPMENT_NOTE = 7;
public const ATTRIBUTE = 8;
}

View File

@ -13,8 +13,8 @@
declare(strict_types=1);
return ['Navigation' => [
'EquipmentAttributes' => 'Equipment Attribute',
'EquipmentInspectionTypes' => 'Equipment Inspektionstypen',
'Attributes' => 'Attribute',
'InspectionTypes' => 'Inspektionsarten',
'EquipmentManagement' => 'Equipment Management',
'Equipments' => 'Equipments',
'Inspections' => 'Inspektionen',

View File

@ -13,8 +13,8 @@
declare(strict_types=1);
return ['Navigation' => [
'EquipmentAttributes' => 'Equipment Attributes',
'EquipmentInspectionTypes' => 'Equipment Inspection Types',
'Attributes' => 'Attributes',
'InspectionTypes' => 'Inspection Types',
'EquipmentManagement' => 'Equipment Management',
'Equipments' => 'Equipments',
'Inspections' => 'Inspections',

View File

@ -1,71 +0,0 @@
<?php
/**
* Jingga
*
* PHP Version 8.2
*
* @package Modules\ItemManagement
* @copyright Dennis Eichhorn
* @license OMS License 2.0
* @version 1.0.0
* @link https://jingga.app
*/
declare(strict_types=1);
use phpOMS\Uri\UriFactory;
/** @var \phpOMS\Views\View $this */
$attributes = $this->data['attributes'];
echo $this->data['nav']->render(); ?>
<div class="row">
<div class="col-xs-12">
<section class="portlet">
<div class="portlet-head"><?= $this->getHtml('AttributeTypes', 'Attribute', 'Backend'); ?><i class="g-icon download btn end-xs">download</i></div>
<div class="slider">
<table id="iAttributeTypeList" class="default sticky">
<thead>
<tr>
<td><?= $this->getHtml('ID', '0', '0'); ?>
<label for="iAttributeTypeList-sort-1">
<input type="radio" name="iAttributeTypeList-sort" id="iAttributeTypeList-sort-1">
<i class="sort-asc g-icon">expand_less</i>
</label>
<label for="iAttributeTypeList-sort-2">
<input type="radio" name="iAttributeTypeList-sort" id="iAttributeTypeList-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="iAttributeTypeList-sort-2">
<input type="radio" name="iAttributeTypeList-sort" id="iAttributeTypeList-sort-2">
<i class="sort-asc g-icon">expand_less</i>
</label>
<label for="iAttributeTypeList-sort-3">
<input type="radio" name="iAttributeTypeList-sort" id="iAttributeTypeList-sort-3">
<i class="sort-desc g-icon">expand_more</i>
</label>
<label>
<i class="filter g-icon">filter_alt</i>
</label>
<tbody>
<?php
$count = 0;
foreach ($attributes as $key => $value) : ++$count;
$url = UriFactory::build('{/base}/fleet/equipment/attribute/type?{?}&id=' . $value->id);
?>
<tr data-href="<?= $url; ?>">
<td><a href="<?= $url; ?>"><?= $value->id; ?></a>
<td><a href="<?= $url; ?>"><?= $this->printHtml($value->getL11n()); ?></a>
<?php endforeach; ?>
<?php if ($count === 0) : ?>
<tr><td colspan="2" class="empty"><?= $this->getHtml('Empty', '0', '0'); ?>
<?php endif; ?>
</table>
</div>
</section>
</div>
</div>

View File

@ -1,98 +0,0 @@
<?php
/**
* Jingga
*
* PHP Version 8.2
*
* @package Modules\Tasks
* @copyright Dennis Eichhorn
* @license OMS License 2.0
* @version 1.0.0
* @link https://jingga.app
*/
declare(strict_types=1);
use Modules\Attribute\Models\AttributeValueType;
use phpOMS\Localization\ISO639Enum;
$types = AttributeValueType::getConstants();
$attribute = $this->data['attribute'];
$l11ns = $this->data['l11ns'];
echo $this->data['nav']->render(); ?>
<div class="row">
<div class="col-md-6 col-xs-12">
<section id="task" class="portlet">
<div class="portlet-head"><?= $this->getHtml('Attribute', 'Attribute', 'Backend'); ?></div>
<div class="portlet-body">
<div class="form-group">
<label for="iId"><?= $this->getHtml('ID', '0', '0'); ?></label>
<input type="text" value="<?= $this->printHtml((string) $attribute->id); ?>" disabled>
</div>
<div class="form-group">
<label for="iName"><?= $this->getHtml('Name', 'Attribute', 'Backend'); ?></label>
<input id="iNAme" type="text" value="<?= $this->printHtml($attribute->name); ?>" disabled>
</div>
<div class="form-group">
<label for="iType"><?= $this->getHtml('Datatype', 'Attribute', 'Backend'); ?></label>
<select id="iType" name="type" disabled>
<?php foreach ($types as $key => $type) : ?>
<option value="<?= $type; ?>"<?= $type === $attribute->datatype ? ' selected' : ''; ?>><?= $this->printHtml($key); ?>
<?php endforeach; ?>
</select>
</div>
<div class="form-group">
<label for="iPattern"><?= $this->getHtml('Pattern', 'Attribute', 'Backend'); ?></label>
<input id="iPattern" type="text" value="<?= $this->printHtml($attribute->validationPattern); ?>">
</div>
<div class="form-group">
<label class="checkbox" for="iRequired">
<input id="iRequired" type="checkbox" name="required" value="1"<?= $attribute->isRequired ? ' checked' : ''; ?>>
<span class="checkmark"></span>
<?= $this->getHtml('IsRequired', 'Attribute', 'Backend'); ?>
</label>
</div>
<div class="form-group">
<label class="checkbox" for="iCustom">
<input id="iCustom" type="checkbox" name="custom" value="1" <?= $attribute->custom ? ' checked' : ''; ?>>
<span class="checkmark"></span>
<?= $this->getHtml('CustomValue', 'Attribute', 'Backend'); ?>
</label>
</div>
</div>
</section>
</div>
<div class="col-xs-12 col-md-6">
<div class="portlet">
<div class="portlet-head"><?= $this->getHtml('Language', '0', '0'); ?><i class="g-icon download btn end-xs">download</i></div>
<table class="default sticky">
<thead>
<tr>
<td>
<td>
<td><?= $this->getHtml('Language', '0', '0'); ?>
<td class="wf-100"><?= $this->getHtml('Title', 'Attribute', 'Backend'); ?>
<tbody>
<?php $c = 0; foreach ($l11ns as $key => $value) : ++$c; ?>
<tr>
<td><a href="#"><i class="g-icon">close</i></a>
<td><a href="#"><i class="g-icon">settings</i></a>
<td><?= ISO639Enum::getByName('_' . \strtoupper($value->language)); ?>
<td><?= $value->content; ?>
<?php endforeach; ?>
<?php if ($c === 0) : ?>
<tr><td colspan="3" class="empty"><?= $this->getHtml('Empty', '0', '0'); ?>
<?php endif; ?>
</table>
</div>
</div>
</div>

View File

@ -85,7 +85,7 @@ echo $this->data['nav']->render(); ?>
?>
<tr data-href="<?= $url; ?>">
<td>
<td data-label="<?= $this->getHtml('ID', '0', '0'); ?>"><a href="<?= $url; ?>"><?= $this->printHtml((string) $value->id); ?></a>
<td data-label="<?= $this->getHtml('ID', '0', '0'); ?>"><a href="<?= $url; ?>"><?= $value->id; ?></a>
<td data-label="<?= $this->getHtml('Status'); ?>"><a href="<?= $url; ?>"><?= $this->getHtml(':status' . $value->status); ?></a>
<td data-label="<?= $this->getHtml('Name'); ?>"><a href="<?= $url; ?>"><?= $this->printHtml($value->name); ?></a>
<td data-label="<?= $this->getHtml('Type'); ?>"><a href="<?= $url; ?>"><?= $this->printHtml($value->type->getL11n()); ?></a>

View File

@ -136,7 +136,7 @@ echo $this->data['nav']->render();
$equipment->attributes,
$this->data['attributeTypes'] ?? [],
$this->data['units'] ?? [],
'{/api}fleet/equipment/attribute',
'{/api}fleet/equipment/attribute?csrf={$CSRF}',
$equipment->id
);
?>

View File

@ -13,3 +13,67 @@
declare(strict_types=1);
echo $this->data['nav']->render();
?>
<div class="row">
<div class="col-xs-12">
<section class="portlet">
<div class="portlet-head"><?= $this->getHtml('Upcoming'); ?></div>
<table id="upcomingInspections" class="default sticky">
<thead>
<tr>
<td><?= $this->getHtml('Date'); ?>
<td class="wf-100"><?= $this->getHtml('Type'); ?>
<td><?= $this->getHtml('Responsible'); ?>
<tbody>
<?php
$count = 0;
foreach (($this->data['inspections'] ?? []) as $inspection) :
// @todo handle old inspections in the past? maybe use a status?!
if ($inspection->next === null) {
continue;
}
++$count;
?>
<tr>
<td><?= $inspection->next->format('Y-m-d H:i'); ?>
<td><?= $this->printHtml($inspection->type->getL11n()); ?>
<td>
<?php endforeach; ?>
<?php if ($count === 0) : ?>
<tr><td colspan="3" class="empty"><?= $this->getHtml('Empty', '0', '0'); ?>
<?php endif; ?>
</table>
</section>
</div>
</div>
<div class="row">
<div class="col-xs-12">
<section class="portlet">
<div class="portlet-head"><?= $this->getHtml('History'); ?></div>
<table id="historicInspections" class="default sticky">
<thead>
<tr>
<td><?= $this->getHtml('Date'); ?>
<td class="wf-100"><?= $this->getHtml('Type'); ?>
<td><?= $this->getHtml('Responsible'); ?>
<tbody>
<?php
$count = 0;
foreach (($this->data['inspections'] ?? []) as $inspection) :
++$count;
?>
<tr>
<td><?= $inspection->date->format('Y-m-d H:i'); ?>
<td><?= $this->printHtml($inspection->type->getL11n()); ?>
<td>
<?php endforeach; ?>
<?php if ($count === 0) : ?>
<tr><td colspan="3" class="empty"><?= $this->getHtml('Empty', '0', '0'); ?>
<?php endif; ?>
</table>
</section>
</div>
</div>