From 2c3551854c587b2638079012e1f349f0ba754053 Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Wed, 17 Apr 2024 17:45:07 +0000 Subject: [PATCH] fix templates --- Controller/BackendController.php | 209 +++++++++++++++++++++++++++- Theme/Backend/Lang/de.lang.php | 1 + Theme/Backend/Lang/en.lang.php | 3 +- Theme/Backend/contract-list.tpl.php | 4 +- Theme/Backend/contract-type.tpl.php | 58 ++++++++ Theme/Backend/contract-view.tpl.php | 20 ++- 6 files changed, 282 insertions(+), 13 deletions(-) diff --git a/Controller/BackendController.php b/Controller/BackendController.php index 07e309e..eb78524 100755 --- a/Controller/BackendController.php +++ b/Controller/BackendController.php @@ -14,8 +14,14 @@ declare(strict_types=1); namespace Modules\ContractManagement\Controller; +use Modules\Attribute\Models\NullAttributeType; +use Modules\Attribute\Models\NullAttributeValue; +use Modules\ContractManagement\Models\Attribute\ContractAttributeTypeL11nMapper; use Modules\ContractManagement\Models\Attribute\ContractAttributeTypeMapper; +use Modules\ContractManagement\Models\Attribute\ContractAttributeValueL11nMapper; +use Modules\ContractManagement\Models\Attribute\ContractAttributeValueMapper; use Modules\ContractManagement\Models\ContractMapper; +use Modules\ContractManagement\Models\ContractTypeL11nMapper; use Modules\ContractManagement\Models\ContractTypeMapper; use Modules\Organization\Models\UnitMapper; use phpOMS\Contract\RenderableInterface; @@ -90,7 +96,7 @@ final class BackendController extends Controller $view->data['types'] = ContractTypeMapper::getAll() ->with('l11n') ->where('l11n/language', $response->header->l11n->language) - ->limit(25) + ->limit(50) ->paginate( 'id', $request->getDataString('ptype') ?? '', @@ -119,13 +125,65 @@ final class BackendController extends Controller $view->setTemplate('/Modules/ContractManagement/Theme/Backend/contract-type'); $view->data['nav'] = $this->app->moduleManager->get('Navigation')->createNavigationMid(1007901001, $request, $response); - $type = ContractTypeMapper::get() + $view->data['type'] = ContractTypeMapper::get() ->with('l11n') ->where('l11n/language', $response->header->l11n->language) ->where('id', (int) $request->getData('id')) ->execute(); - $view->data['type'] = $type; + $view->data['l11nView'] = new \Web\Backend\Views\L11nView($this->app->l11nManager, $request, $response); + $view->data['l11nValues'] = ContractTypeL11nMapper::getAll() + ->where('ref', $view->data['type']->id) + ->executeGetArray(); + + 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 viewContractTypeCreate(RequestAbstract $request, ResponseAbstract $response, array $data = []) : RenderableInterface + { + $view = new View($this->app->l11nManager, $request, $response); + + $view->setTemplate('/Modules/ContractManagement/Theme/Backend/contract-type'); + $view->data['nav'] = $this->app->moduleManager->get('Navigation')->createNavigationMid(1007901001, $request, $response); + + 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 viewContractCreate(RequestAbstract $request, ResponseAbstract $response, array $data = []) : RenderableInterface + { + $view = new View($this->app->l11nManager, $request, $response); + + $view->setTemplate('/Modules/ContractManagement/Theme/Backend/contract-view'); + $view->data['nav'] = $this->app->moduleManager->get('Navigation')->createNavigationMid(1007901001, $request, $response); + + $view->data['contractTypes'] = ContractTypeMapper::getAll() + ->with('l11n') + ->where('l11n/language', $response->header->l11n->language) + ->executeGetArray(); return $view; } @@ -192,4 +250,149 @@ final class BackendController extends Controller 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 viewContractManagementAttributeTypeList(RequestAbstract $request, ResponseAbstract $response, array $data = []) : RenderableInterface + { + $view = new \Modules\Attribute\Theme\Backend\Components\AttributeTypeListView($this->app->l11nManager, $request, $response); + $view->data['nav'] = $this->app->moduleManager->get('Navigation')->createNavigationMid(1007901001, $request, $response); + + $view->attributes = ContractAttributeTypeMapper::getAll() + ->with('l11n') + ->where('l11n/language', $response->header->l11n->language) + ->executeGetArray(); + + $view->path = 'contract'; + + 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 viewContractManagementAttributeType(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(1007901001, $request, $response); + + $view->attribute = ContractAttributeTypeMapper::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(); + + $view->l11ns = ContractAttributeTypeL11nMapper::getAll() + ->where('ref', $view->attribute->id) + ->executeGetArray(); + + $view->path = 'contract'; + + 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 viewContractManagementAttributeTypeCreate(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(1007901001, $request, $response); + + $view->attribute = new NullAttributeType(); + + $view->path = 'contract'; + + 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 viewContractManagementAttributeValueCreate(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(1007901001, $request, $response); + + $view->type = ContractAttributeTypeMapper::get()->where('id', (int) $request->getData('type'))->execute(); + $view->attribute = new NullAttributeValue(); + + $view->path = 'contract'; + + 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 viewContractManagementAttributeValue(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(1004802001, $request, $response); + + $view->type = ContractAttributeTypeMapper::get()->where('id', (int) $request->getData('type'))->execute(); + + $view->attribute = ContractAttributeValueMapper::get() + ->with('l11n') + ->where('id', (int) $request->getData('id')) + ->where('l11n/language', [$response->header->l11n->language, null]) + ->execute(); + + $view->l11ns = ContractAttributeValueL11nMapper::getAll() + ->where('ref', $view->attribute->id) + ->executeGetArray(); + + // @todo Also find the ContractAttributeType + + return $view; + } } diff --git a/Theme/Backend/Lang/de.lang.php b/Theme/Backend/Lang/de.lang.php index 7c7279b..3ef9d35 100755 --- a/Theme/Backend/Lang/de.lang.php +++ b/Theme/Backend/Lang/de.lang.php @@ -22,6 +22,7 @@ return ['ContractManagement' => [ 'End' => 'Ende', 'Files' => 'Dateien', 'Name' => 'Name', + 'ContractType' => 'Vertragsart', 'Overview' => 'Übersicht', 'Parties' => 'Parteien', 'Start' => 'Start', diff --git a/Theme/Backend/Lang/en.lang.php b/Theme/Backend/Lang/en.lang.php index 0a3d7a0..2978dd4 100755 --- a/Theme/Backend/Lang/en.lang.php +++ b/Theme/Backend/Lang/en.lang.php @@ -21,7 +21,8 @@ return ['ContractManagement' => [ 'Description' => 'Description', 'End' => 'End', 'Files' => 'Files', - 'Name' => '', + 'Name' => 'Name', + 'ContractType' => 'Contract Type', 'Overview' => 'Overview', 'Parties' => 'Parties', 'Start' => 'Start', diff --git a/Theme/Backend/contract-list.tpl.php b/Theme/Backend/contract-list.tpl.php index c9b3dff..27587a8 100755 --- a/Theme/Backend/contract-list.tpl.php +++ b/Theme/Backend/contract-list.tpl.php @@ -29,7 +29,7 @@ echo $this->data['nav']->render(); ?>
-
+
getHtml('Contracts'); ?>download
@@ -105,6 +105,6 @@ echo $this->data['nav']->render(); ?> getHtml('Next', '0', '0'); ?> --> - + diff --git a/Theme/Backend/contract-type.tpl.php b/Theme/Backend/contract-type.tpl.php index e69de29..58cecd7 100644 --- a/Theme/Backend/contract-type.tpl.php +++ b/Theme/Backend/contract-type.tpl.php @@ -0,0 +1,58 @@ +data['type'] ?? new NullBaseStringL11nType(); +$isNew = $type->id === 0; + +/** @var \phpOMS\Views\View $this */ +echo $this->data['nav']->render(); ?> +
+
+
+
+
getHtml('ContractType'); ?>
+
+
+ + +
+
+ +
+ + + + + + +
+ +
+
+
+ + +
+ data['l11nView']->render( + $this->data['l11nValues'], + [], + '{/api}contract/type/l11n?csrf={$CSRF}' + ); + ?> +
+ \ No newline at end of file diff --git a/Theme/Backend/contract-view.tpl.php b/Theme/Backend/contract-view.tpl.php index 8ca6bb9..3e2ee49 100644 --- a/Theme/Backend/contract-view.tpl.php +++ b/Theme/Backend/contract-view.tpl.php @@ -12,17 +12,20 @@ */ declare(strict_types=1); +use Modules\ContractManagement\Models\NullContract; use phpOMS\Uri\UriFactory; /** * @var \phpOMS\Views\View $this * @var \Modules\ContractManagement\Models\Contract $contract */ -$contract = $this->data['contract']; +$contract = $this->data['contract'] ?? new NullContract(); +$isNew = $contract->id === 0; echo $this->data['nav']->render(); ?>
+
+
- request->uri->fragment === 'c-tab-1' ? ' checked' : ''; ?>> + request->uri->fragment === 'c-tab-1' ? ' checked' : ''; ?>>
@@ -56,7 +60,7 @@ echo $this->data['nav']->render(); ?> data['contractTypes'] ?? []; foreach ($types as $type) : ?> -
@@ -68,12 +72,12 @@ echo $this->data['nav']->render(); ?>
- +
- +
@@ -114,6 +118,7 @@ echo $this->data['nav']->render(); ?>
+ request->uri->fragment === 'c-tab-2' ? ' checked' : ''; ?>>
data['media-upload']->render('contract-file', 'files', '', $contract->files); ?> @@ -142,7 +147,7 @@ echo $this->data['nav']->render(); ?>
-
+
getHtml('Contracts'); ?>download
@@ -213,9 +218,10 @@ echo $this->data['nav']->render(); ?>
-
+
+