From ed7035c1922a6ffa0ed4378443d2883565d7e1f6 Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Wed, 17 Apr 2024 17:45:07 +0000 Subject: [PATCH] fix templates --- Admin/Routes/Web/Backend.php | 4 +- Controller/BackendController.php | 82 ++++++++++++++++------ Models/Equipment.php | 2 +- Theme/Backend/Lang/de.lang.php | 7 +- Theme/Backend/Lang/en.lang.php | 6 +- Theme/Backend/equipment-view.tpl.php | 17 +++-- Theme/Backend/inspection-type-list.tpl.php | 54 +++++++++++++- 7 files changed, 139 insertions(+), 33 deletions(-) diff --git a/Admin/Routes/Web/Backend.php b/Admin/Routes/Web/Backend.php index 8b8f58a..3d37dfc 100755 --- a/Admin/Routes/Web/Backend.php +++ b/Admin/Routes/Web/Backend.php @@ -142,7 +142,7 @@ return [ ], '^/equipment/inspection/create(\?.*$|$)' => [ [ - 'dest' => '\Modules\EquipmentManagement\Controller\BackendController:viewEquipmentManagementEquipmentCreate', + 'dest' => '\Modules\EquipmentManagement\Controller\BackendController:viewEquipmentManagementInspectionCreate', 'verb' => RouteVerb::GET, 'active' => true, 'permission' => [ @@ -154,7 +154,7 @@ return [ ], '^/equipment/inspection/view(\?.*$|$)' => [ [ - 'dest' => '\Modules\EquipmentManagement\Controller\BackendController:viewEquipmentManagementEquipmentView', + 'dest' => '\Modules\EquipmentManagement\Controller\BackendController:viewEquipmentManagementInspectionView', 'verb' => RouteVerb::GET, 'active' => true, 'permission' => [ diff --git a/Controller/BackendController.php b/Controller/BackendController.php index 2f4f9fb..1a3dd6a 100755 --- a/Controller/BackendController.php +++ b/Controller/BackendController.php @@ -14,6 +14,8 @@ declare(strict_types=1); namespace Modules\EquipmentManagement\Controller; +use Modules\Attribute\Models\NullAttributeType; +use Modules\Attribute\Models\NullAttributeValue; use Modules\EquipmentManagement\Models\Attribute\EquipmentAttributeTypeL11nMapper; use Modules\EquipmentManagement\Models\Attribute\EquipmentAttributeTypeMapper; use Modules\EquipmentManagement\Models\Attribute\EquipmentAttributeValueL11nMapper; @@ -216,7 +218,7 @@ final class BackendController extends Controller $view->data['nav'] = $this->app->moduleManager->get('Navigation')->createNavigationMid(1008402001, $request, $response); // @todo This langauge filtering doesn't work. But it was working with the old mappers. Maybe there is a bug in the where() definition. Need to inspect the actual query. - $equipment = EquipmentMapper::get() + $view->data['equipment'] = EquipmentMapper::get() ->with('attributes') ->with('attributes/type') ->with('attributes/value') @@ -235,17 +237,13 @@ final class BackendController extends Controller ->where('attributes/value/l11n/language', [$response->header->l11n->language, null]) ->execute(); - $view->data['equipment'] = $equipment; - - $inspections = InspectionMapper::getAll() + $view->data['inspections'] = InspectionMapper::getAll() ->with('type') ->with('type/l11n') - ->where('reference', $equipment->id) + ->where('reference', $view->data['equipment']->id) ->where('type/l11n/language', $response->header->l11n->language) ->executeGetArray(); - $view->data['inspections'] = $inspections; - // @feature Create a new read mapper function that returns relation models instead of its own model // https://github.com/Karaka-Management/phpOMS/issues/320 $query = new Builder($this->app->dbPool->get()); @@ -259,29 +257,23 @@ final class BackendController extends Controller ->on(MediaMapper::TABLE . '.' . MediaMapper::PRIMARYFIELD, '=', MediaMapper::HAS_MANY['types']['table'] . '.' . MediaMapper::HAS_MANY['types']['self']) ->leftJoin(MediaTypeMapper::TABLE) ->on(MediaMapper::HAS_MANY['types']['table'] . '.' . MediaMapper::HAS_MANY['types']['external'], '=', MediaTypeMapper::TABLE . '.' . MediaTypeMapper::PRIMARYFIELD) - ->where(EquipmentMapper::HAS_MANY['files']['self'], '=', $equipment->id) + ->where(EquipmentMapper::HAS_MANY['files']['self'], '=', $view->data['equipment']->id) ->where(MediaTypeMapper::TABLE . '.' . MediaTypeMapper::getColumnByMember('name'), '=', 'equipment_profile_image'); - $equipmentImage = MediaMapper::get() + $view->data['equipmentImage'] = MediaMapper::get() ->with('types') ->where('id', $results) ->limit(1) ->execute(); - $view->data['equipmentImage'] = $equipmentImage; - - $equipmentTypes = EquipmentTypeMapper::getAll() + $view->data['types'] = EquipmentTypeMapper::getAll() ->with('l11n') ->where('l11n/language', $response->header->l11n->language) ->executeGetArray(); - $view->data['types'] = $equipmentTypes; - - $units = UnitMapper::getAll() + $view->data['units'] = UnitMapper::getAll() ->executeGetArray(); - $view->data['units'] = $units; - $view->data['attributeView'] = new \Modules\Attribute\Theme\Backend\Components\AttributeView($this->app->l11nManager, $request, $response); $view->data['attributeView']->data['default_localization'] = $this->app->l11nServer; @@ -341,15 +333,63 @@ final class BackendController extends Controller public function viewEquipmentManagementInspectionTypeList(RequestAbstract $request, ResponseAbstract $response, array $data = []) : RenderableInterface { $view = new View($this->app->l11nManager, $request, $response); - $view->setTemplate('/Modules/EquipmentManagement/Theme/Backend/inspection-type-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 = InspectionTypeMapper::getAll() + $view->data['types'] = InspectionTypeMapper::getAll() + ->with('l11n') + ->where('l11n/language', $response->header->l11n->language) ->sort('id', 'DESC') ->executeGetArray(); - $view->data['inspections'] = $list; + 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 viewEquipmentManagementAttributeTypeCreate(RequestAbstract $request, ResponseAbstract $response, array $data = []) : RenderableInterface + { + $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); + + $view->attribute = new NullAttributeType(); + + $view->path = 'equipment'; + + 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 viewEquipmentManagementAttributeValueCreate(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->type = EquipmentAttributeTypeMapper::get()->where('id', (int) $request->getData('type'))->execute(); + $view->attribute = new NullAttributeValue(); + + $view->path = 'equipment'; return $view; } diff --git a/Models/Equipment.php b/Models/Equipment.php index 809b61c..e2eb721 100755 --- a/Models/Equipment.php +++ b/Models/Equipment.php @@ -19,7 +19,7 @@ use phpOMS\Localization\BaseStringL11nType; /** * Equipment class. * - * @package Modules\Attribute\Models + * @package Modules\EquipmentManagement\Models * @license OMS License 2.0 * @link https://jingga.app * @since 1.0.0 diff --git a/Theme/Backend/Lang/de.lang.php b/Theme/Backend/Lang/de.lang.php index 0d9735d..269e396 100755 --- a/Theme/Backend/Lang/de.lang.php +++ b/Theme/Backend/Lang/de.lang.php @@ -20,14 +20,17 @@ return ['EquipmentManagement' => [ 'Attributes' => 'Attribute', 'Costs' => 'Kosten', 'Date' => 'Datum', - 'Driver' => '', - 'EIN' => '', + 'Driver' => 'Fahrer', + 'EIN' => 'WKN', 'Ein' => 'Ein', 'End' => 'Ende', + 'Number' => 'Nummer', 'Equipments' => 'Equipment', + 'Equipment' => 'Equipment', 'Files' => 'Dateien', 'History' => 'Historie', 'Inspections' => 'Inspectionen', + 'InspectionTypes' => 'Inspektionsarten', 'LeasingFee' => 'Leasingkosten', 'Make' => 'Marke', 'Model' => 'Modell', diff --git a/Theme/Backend/Lang/en.lang.php b/Theme/Backend/Lang/en.lang.php index 068144c..2fd260d 100755 --- a/Theme/Backend/Lang/en.lang.php +++ b/Theme/Backend/Lang/en.lang.php @@ -20,14 +20,16 @@ return ['EquipmentManagement' => [ 'Attributes' => 'Attributes', 'Costs' => 'Costs', 'Date' => 'Date', - 'Driver' => '', - 'EIN' => '', + 'EIN' => 'EIN', 'Ein' => 'Ein', 'End' => 'End', 'Equipments' => 'Equipments', + 'Equipment' => 'Equipment', + 'Number' => 'Number', 'Files' => 'Files', 'History' => 'History', 'Inspections' => 'Inspections', + 'InspectionTypes' => 'Inspection Types', 'LeasingFee' => 'Leasing Fee', 'Make' => 'Make', 'Model' => 'Model', diff --git a/Theme/Backend/equipment-view.tpl.php b/Theme/Backend/equipment-view.tpl.php index ace2d6c..23e6645 100755 --- a/Theme/Backend/equipment-view.tpl.php +++ b/Theme/Backend/equipment-view.tpl.php @@ -4,7 +4,7 @@ * * PHP Version 8.2 * - * @package Modules\ClientManagement + * @package Modules\EquipmentManagement * @copyright Dennis Eichhorn * @license OMS License 2.0 * @version 1.0.0 @@ -36,9 +36,10 @@ $isNew = $equipment->id === 0; echo $this->data['nav']->render(); ?>
+
+
- request->uri->fragment === 'c-tab-1' ? ' checked' : ''; ?>> + request->uri->fragment === 'c-tab-1' ? ' checked' : ''; ?>>
-
getHtml('Profile'); ?>
+
getHtml('Equipment'); ?>
+
+ + +
+
request->uri->fragment === 'c-tab-2' ? ' checked' : ''; ?>>
@@ -213,5 +221,6 @@ echo $this->data['nav']->render();
+
\ No newline at end of file diff --git a/Theme/Backend/inspection-type-list.tpl.php b/Theme/Backend/inspection-type-list.tpl.php index ceb8b89..4856f86 100755 --- a/Theme/Backend/inspection-type-list.tpl.php +++ b/Theme/Backend/inspection-type-list.tpl.php @@ -12,4 +12,56 @@ */ declare(strict_types=1); -echo $this->data['nav']->render(); +use phpOMS\Uri\UriFactory; + +echo $this->data['nav']->render(); ?> +
+
+
+
getHtml('InspectionTypes'); ?>download
+
+ + + + + data['types'] as $key => $value) : ++$count; + $url = UriFactory::build('{/base}/equipment/inspection/type/view?{?}&id=' . $value->id); + ?> + +
getHtml('ID', '0', '0'); ?> + + + + getHtml('Name'); ?> + + + +
id; ?> + printHtml($value->getL11n()); ?> + + +
getHtml('Empty', '0', '0'); ?> + +
+
+
+
+