diff --git a/module/Olcs/config/module.config.php b/module/Olcs/config/module.config.php index bea950396..b6e778e7c 100644 --- a/module/Olcs/config/module.config.php +++ b/module/Olcs/config/module.config.php @@ -1307,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, 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'); ?> +