From b984fc6bcda11579a36d232097ca2497d72cd63a Mon Sep 17 00:00:00 2001 From: wadedvsa <155439365+wadedvsa@users.noreply.github.com> Date: Mon, 22 Jan 2024 14:54:33 +0000 Subject: [PATCH 1/2] feat: Message conversation list page --- module/Olcs/config/module.config.php | 48 +++++++++++-- .../Factory/MessagesControllerFactory.php | 37 ++++++++++ .../src/Controller/MessagesController.php | 72 +++++++++++++++++++ .../Olcs/src/Table/Tables/messages.table.php | 32 +++++++++ module/Olcs/view/messages.phtml | 27 +++++++ 5 files changed, 209 insertions(+), 7 deletions(-) create mode 100644 module/Olcs/src/Controller/Factory/MessagesControllerFactory.php create mode 100644 module/Olcs/src/Controller/MessagesController.php create mode 100644 module/Olcs/src/Table/Tables/messages.table.php create mode 100644 module/Olcs/view/messages.phtml diff --git a/module/Olcs/config/module.config.php b/module/Olcs/config/module.config.php index bea950396..77709e1bc 100644 --- a/module/Olcs/config/module.config.php +++ b/module/Olcs/config/module.config.php @@ -1,6 +1,7 @@ [ + 'type' => Segment::class, + 'options' => [ + 'route' => '/messages[/]', + 'defaults' => [ + 'controller' => Olcs\Controller\MessagesController::class, + 'action' => 'index', + ], + ], + 'may_terminate' => true, + 'child_routes' => [ + 'view' => [ + 'type' => Segment::class, + 'options' => [ + 'route' => ':conversationId[/]', + 'defaults' => [ + 'action' => 'view', + ], + ], + ], + ], + ], 'create_variation' => [ 'type' => 'segment', 'options' => [ @@ -519,7 +545,7 @@ ] ], 'govuk-account' => [ - 'type' => \Laminas\Mvc\Router\Http\Literal::class, + 'type' => \Laminas\Router\Http\Literal::class, 'options' => [ 'route' => '/govuk-account', 'defaults' => [ @@ -529,7 +555,7 @@ 'may_terminate' => false, 'child_routes' => [ 'process' => [ - 'type' => \Laminas\Mvc\Router\Http\Literal::class, + 'type' => \Laminas\Router\Http\Literal::class, 'options' => [ 'route' => '/process', 'defaults' => [ @@ -540,7 +566,7 @@ ], ], 'verify' => [ - 'type' => \Laminas\Mvc\Router\Http\Literal::class, + 'type' => \Laminas\Router\Http\Literal::class, 'options' => [ 'route' => '/verify', 'defaults' => [ @@ -1194,7 +1220,7 @@ 'LvaDirectorChange/People' => \Olcs\Controller\Lva\DirectorChange\PeopleController::class, 'LvaDirectorChange/FinancialHistory' => Olcs\Controller\Lva\DirectorChange\FinancialHistoryController::class, 'LvaDirectorChange/LicenceHistory' => \Olcs\Controller\Lva\DirectorChange\LicenceHistoryController::class, - 'LvaDirectorChange/ConvictionsPenalties' => \Olcs\Controller\Lva\DirectorChange\ConvictionsPenaltiesControllerFactory::class, + 'LvaDirectorChange/ConvictionsPenalties' => \Olcs\Controller\Lva\DirectorChange\ConvictionsPenaltiesController::class, 'LvaTransportManager/CheckAnswers' => \Olcs\Controller\Lva\TransportManager\CheckAnswersController::class, 'LvaTransportManager/Confirmation' => \Olcs\Controller\Lva\TransportManager\ConfirmationController::class, 'LvaTransportManager/OperatorDeclaration' => \Olcs\Controller\Lva\TransportManager\OperatorDeclarationController::class, @@ -1283,6 +1309,8 @@ Olcs\Controller\GdsVerifyController::class => \Olcs\Controller\Factory\GdsVerifyControllerFactory::class, + Olcs\Controller\MessagesController::class => MessagesControllerFactory::class, + // License - Surrender Olcs\Controller\Licence\Surrender\ReviewContactDetailsController::class => Olcs\Controller\Licence\Surrender\ReviewContactDetailsControllerFactory::class, Olcs\Controller\Licence\Surrender\AddressDetailsController::class => @@ -1422,8 +1450,14 @@ LicenceTransportManagerAdapter::class => LicenceTransportManagerAdapterFactory::class, VariationTransportManagerAdapter::class => VariationTransportManagerAdapterFactory::class, VariationPeopleAdapter::class => VariationPeopleAdapterFactory::class, + \Olcs\Logging\Log\Processor\CorrelationId::class => \Olcs\Logging\Log\Processor\CorrelationIdFactory::class, ] ), + 'log_processors' => [ + 'factories' => [ + CorrelationId::class => CorrelationIdFactory::class, + ], + ], 'search' => [ 'invokables' => [ 'operator' => Common\Data\Object\Search\LicenceSelfserve::class, // Selfserve licence search @@ -1576,12 +1610,12 @@ 'lva-variation-overview-submission' => LvaFormService\VariationOverviewSubmissionFactory::class, ] ], - 'zfc_rbac' => [ + 'lmc_rbac' => [ 'assertion_map' => [ 'selfserve-ebsr-list' => \Olcs\Assertion\Ebsr\EbsrList::class, ], 'guards' => [ - 'ZfcRbac\Guard\RoutePermissionsGuard' => [ + 'LmcRbacMvc\Guard\RoutePermissionsGuard' => [ // Dashboard Page 'dashboard' => ['selfserve-nav-dashboard'], diff --git a/module/Olcs/src/Controller/Factory/MessagesControllerFactory.php b/module/Olcs/src/Controller/Factory/MessagesControllerFactory.php new file mode 100644 index 000000000..77a098ef4 --- /dev/null +++ b/module/Olcs/src/Controller/Factory/MessagesControllerFactory.php @@ -0,0 +1,37 @@ +get(NiTextTranslation::class); + $authService = $container->get(AuthorizationService::class); + $flashMessengerHelper = $container->get(FlashMessengerHelperService::class); + $tableFactory = $container->get(TableFactory::class); + + return new MessagesController( + $niTextTranslationUtil, + $authService, + $flashMessengerHelper, + $tableFactory, + ); + } + + public function createService(ServiceLocatorInterface $serviceLocator): MessagesController + { + return $this->__invoke($serviceLocator, MessagesController::class); + } +} diff --git a/module/Olcs/src/Controller/MessagesController.php b/module/Olcs/src/Controller/MessagesController.php new file mode 100644 index 000000000..366b8f8d5 --- /dev/null +++ b/module/Olcs/src/Controller/MessagesController.php @@ -0,0 +1,72 @@ + [FeatureToggle::MESSAGING], + ]; + + protected FlashMessengerHelperService $flashMessengerHelper; + protected TableFactory $tableFactory; + + public function __construct( + NiTextTranslation $niTextTranslationUtil, + AuthorizationService $authService, + FlashMessengerHelperService $flashMessengerHelper, + TableFactory $tableFactory + ) + { + $this->flashMessengerHelper = $flashMessengerHelper; + $this->tableFactory = $tableFactory; + + parent::__construct($niTextTranslationUtil, $authService); + } + + public function indexAction(): ViewModel + { + $params = [ + 'page' => $this->params()->fromQuery('page', 1), + 'limit' => $this->params()->fromQuery('limit', 10), + 'sort' => $this->params()->fromQuery('sort', 'd.issuedDate'), + 'order' => $this->params()->fromQuery('order', 'DESC'), + 'organisation' => $this->getCurrentOrganisationId(), + 'query' => $this->params()->fromQuery(), + ]; + + $response = $this->handleQuery(ByOrganisationQuery::create($params)); + if ($response === null) { + return $this->notFoundAction(); + } + + if ($response->isOk()) { + $messages = $response->getResult(); + } else { + $this->flashMessengerHelper->addErrorMessage('unknown-error'); + $messages = []; + } + + $table = $this->tableFactory + ->buildTable('messages', $messages, $params); + + $view = new ViewModel(['table' => $table]); + $view->setTemplate('messages'); + + return $view; + } +} diff --git a/module/Olcs/src/Table/Tables/messages.table.php b/module/Olcs/src/Table/Tables/messages.table.php new file mode 100644 index 000000000..225b8b025 --- /dev/null +++ b/module/Olcs/src/Table/Tables/messages.table.php @@ -0,0 +1,32 @@ + [ + 'title' => 'dashboard-messages.table.title', + 'titleSingular' => 'dashboard-messages.table.title', + 'empty_message' => 'dashboard-messages.empty-message', + ], + 'settings' => [ + 'crud' => [ + 'formName' => 'messages', + 'actions' => [], + ], + 'paginate' => [ + 'limit' => [ + 'default' => 10, + 'options' => [10, 25, 50], + ], + ], + ], + 'attributes' => [], + 'columns' => [ + [ + 'name' => 'id', + 'formatter' => ExternalConversationLink::class, + ], + ], +]; diff --git a/module/Olcs/view/messages.phtml b/module/Olcs/view/messages.phtml new file mode 100644 index 000000000..99c35b586 --- /dev/null +++ b/module/Olcs/view/messages.phtml @@ -0,0 +1,27 @@ +partial( + 'partials/page-header-simple', + [ + 'pageTitle' => $this->translate('dashboard.messages.title'), + ], +); +?> + +
+
+ flashMessengerAll(); + + /* @var \Laminas\View\Helper\Navigation\Menu $menu */ + $menu = $this->navigation($this->navigation('navigation')->getContainer()->findBy('id', 'dashboard-licences-applications'))->menu(); + + echo $menu->setMinDepth(0) + ->setMaxDepth(0) + ->setPartial('partials/tabs-nav'); + + echo $this->table; + ?> +
+ + partial('partials/dashboard-right-column'); ?> +
From 3c56fb0b50869abfb66541b1b955c1075bd3f649 Mon Sep 17 00:00:00 2001 From: wadedvsa <155439365+wadedvsa@users.noreply.github.com> Date: Mon, 22 Jan 2024 14:58:58 +0000 Subject: [PATCH 2/2] fix: modules.config.php --- module/Olcs/config/module.config.php | 49 +++++----------------------- 1 file changed, 8 insertions(+), 41 deletions(-) diff --git a/module/Olcs/config/module.config.php b/module/Olcs/config/module.config.php index 77709e1bc..b6e778e7c 100644 --- a/module/Olcs/config/module.config.php +++ b/module/Olcs/config/module.config.php @@ -1,7 +1,6 @@ [ - 'type' => Segment::class, - 'options' => [ - 'route' => '/messages[/]', - 'defaults' => [ - 'controller' => Olcs\Controller\MessagesController::class, - 'action' => 'index', - ], - ], - 'may_terminate' => true, - 'child_routes' => [ - 'view' => [ - 'type' => Segment::class, - 'options' => [ - 'route' => ':conversationId[/]', - 'defaults' => [ - 'action' => 'view', - ], - ], - ], - ], - ], 'create_variation' => [ 'type' => 'segment', 'options' => [ @@ -545,7 +519,7 @@ ] ], 'govuk-account' => [ - 'type' => \Laminas\Router\Http\Literal::class, + 'type' => \Laminas\Mvc\Router\Http\Literal::class, 'options' => [ 'route' => '/govuk-account', 'defaults' => [ @@ -555,7 +529,7 @@ 'may_terminate' => false, 'child_routes' => [ 'process' => [ - 'type' => \Laminas\Router\Http\Literal::class, + 'type' => \Laminas\Mvc\Router\Http\Literal::class, 'options' => [ 'route' => '/process', 'defaults' => [ @@ -566,7 +540,7 @@ ], ], 'verify' => [ - 'type' => \Laminas\Router\Http\Literal::class, + 'type' => \Laminas\Mvc\Router\Http\Literal::class, 'options' => [ 'route' => '/verify', 'defaults' => [ @@ -1220,7 +1194,7 @@ 'LvaDirectorChange/People' => \Olcs\Controller\Lva\DirectorChange\PeopleController::class, 'LvaDirectorChange/FinancialHistory' => Olcs\Controller\Lva\DirectorChange\FinancialHistoryController::class, 'LvaDirectorChange/LicenceHistory' => \Olcs\Controller\Lva\DirectorChange\LicenceHistoryController::class, - 'LvaDirectorChange/ConvictionsPenalties' => \Olcs\Controller\Lva\DirectorChange\ConvictionsPenaltiesController::class, + 'LvaDirectorChange/ConvictionsPenalties' => \Olcs\Controller\Lva\DirectorChange\ConvictionsPenaltiesControllerFactory::class, 'LvaTransportManager/CheckAnswers' => \Olcs\Controller\Lva\TransportManager\CheckAnswersController::class, 'LvaTransportManager/Confirmation' => \Olcs\Controller\Lva\TransportManager\ConfirmationController::class, 'LvaTransportManager/OperatorDeclaration' => \Olcs\Controller\Lva\TransportManager\OperatorDeclarationController::class, @@ -1309,8 +1283,6 @@ Olcs\Controller\GdsVerifyController::class => \Olcs\Controller\Factory\GdsVerifyControllerFactory::class, - Olcs\Controller\MessagesController::class => MessagesControllerFactory::class, - // License - Surrender Olcs\Controller\Licence\Surrender\ReviewContactDetailsController::class => Olcs\Controller\Licence\Surrender\ReviewContactDetailsControllerFactory::class, Olcs\Controller\Licence\Surrender\AddressDetailsController::class => @@ -1335,6 +1307,7 @@ \Olcs\Controller\Licence\Vehicle\TransferVehicleConfirmationController::class => \Olcs\Controller\Licence\Vehicle\TransferVehicleConfirmationControllerFactory::class, \Olcs\Controller\Licence\Vehicle\Reprint\ReprintLicenceVehicleDiscController::class => \Olcs\Controller\Licence\Vehicle\Reprint\ReprintLicenceVehicleDiscControllerFactory::class, \Olcs\Controller\Licence\Vehicle\Reprint\ReprintLicenceVehicleDiscConfirmationController::class => \Olcs\Controller\Licence\Vehicle\Reprint\ReprintLicenceVehicleDiscConfirmationControllerFactory::class, + Olcs\Controller\MessagesController::class => Olcs\Controller\Factory\MessagesControllerFactory::class, PromptController::class => \Olcs\Controller\PromptControllerFactory::class, // Process Signature from GOV.UK Account \Olcs\Controller\SignatureVerificationController::class => \Olcs\Controller\SignatureVerificationControllerFactory::class, @@ -1450,14 +1423,8 @@ LicenceTransportManagerAdapter::class => LicenceTransportManagerAdapterFactory::class, VariationTransportManagerAdapter::class => VariationTransportManagerAdapterFactory::class, VariationPeopleAdapter::class => VariationPeopleAdapterFactory::class, - \Olcs\Logging\Log\Processor\CorrelationId::class => \Olcs\Logging\Log\Processor\CorrelationIdFactory::class, ] ), - 'log_processors' => [ - 'factories' => [ - CorrelationId::class => CorrelationIdFactory::class, - ], - ], 'search' => [ 'invokables' => [ 'operator' => Common\Data\Object\Search\LicenceSelfserve::class, // Selfserve licence search @@ -1610,12 +1577,12 @@ 'lva-variation-overview-submission' => LvaFormService\VariationOverviewSubmissionFactory::class, ] ], - 'lmc_rbac' => [ + 'zfc_rbac' => [ 'assertion_map' => [ 'selfserve-ebsr-list' => \Olcs\Assertion\Ebsr\EbsrList::class, ], 'guards' => [ - 'LmcRbacMvc\Guard\RoutePermissionsGuard' => [ + 'ZfcRbac\Guard\RoutePermissionsGuard' => [ // Dashboard Page 'dashboard' => ['selfserve-nav-dashboard'],