Skip to content
This repository has been archived by the owner on Aug 16, 2024. It is now read-only.

Commit

Permalink
feat: Message conversation list page
Browse files Browse the repository at this point in the history
  • Loading branch information
wadedvsa committed Jan 22, 2024
1 parent c9c54e3 commit b984fc6
Show file tree
Hide file tree
Showing 5 changed files with 209 additions and 7 deletions.
48 changes: 41 additions & 7 deletions module/Olcs/config/module.config.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php

use Laminas\Mvc\Router\Http\Segment;
use Laminas\Router\Http\Segment;
use Laminas\Router\Http\HttpRouterFactory;
use Olcs\Auth\Adapter\CommandAdapter;
use Olcs\Auth\Adapter\CommandAdapterFactory;
use Olcs\Auth\Adapter\SelfserveCommandAdapter;
Expand All @@ -15,6 +16,7 @@
use Olcs\Controller\Factory\CorrespondenceControllerFactory;
use Olcs\Controller\Factory\Ebsr\UploadsControllerFactory;
use Olcs\Controller\Factory\IndexControllerFactory;
use Olcs\Controller\Factory\MessagesControllerFactory;
use Olcs\Controller\Factory\MyDetailsControllerFactory;
use Olcs\Controller\IndexController;
use Olcs\Controller\Licence\Vehicle\ListVehicleController;
Expand All @@ -41,6 +43,8 @@
use Olcs\Form\Element\SearchOrderFieldset;
use Olcs\Form\Element\SearchOrderFieldsetFactory;
use Olcs\FormService\Form\Lva as LvaFormService;
use Olcs\Logging\Log\Processor\CorrelationId;
use Olcs\Logging\Log\Processor\CorrelationIdFactory;
use Olcs\Service\Cookie as CookieService;
use Olcs\Service\Processing as ProcessingService;
use Olcs\Service\Qa as QaService;
Expand Down Expand Up @@ -434,6 +438,28 @@
]
]
],
'messages' => [
'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' => [
Expand Down Expand Up @@ -519,7 +545,7 @@
]
],
'govuk-account' => [
'type' => \Laminas\Mvc\Router\Http\Literal::class,
'type' => \Laminas\Router\Http\Literal::class,
'options' => [
'route' => '/govuk-account',
'defaults' => [
Expand All @@ -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' => [
Expand All @@ -540,7 +566,7 @@
],
],
'verify' => [
'type' => \Laminas\Mvc\Router\Http\Literal::class,
'type' => \Laminas\Router\Http\Literal::class,
'options' => [
'route' => '/verify',
'defaults' => [
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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 =>
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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'],

Expand Down
37 changes: 37 additions & 0 deletions module/Olcs/src/Controller/Factory/MessagesControllerFactory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php

declare(strict_types=1);

namespace Olcs\Controller\Factory;

use Common\Service\Helper\FlashMessengerHelperService;
use Common\Service\Table\TableFactory;
use Dvsa\Olcs\Utils\Translation\NiTextTranslation;
use Interop\Container\ContainerInterface;
use Laminas\ServiceManager\Factory\FactoryInterface;
use Laminas\ServiceManager\ServiceLocatorInterface;
use LmcRbacMvc\Service\AuthorizationService;
use Olcs\Controller\MessagesController;

class MessagesControllerFactory implements FactoryInterface
{
public function __invoke(ContainerInterface $container, $requestedName, array $options = null): MessagesController
{
$niTextTranslationUtil = $container->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);
}
}
72 changes: 72 additions & 0 deletions module/Olcs/src/Controller/MessagesController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<?php

declare(strict_types=1);

namespace Olcs\Controller;

use Common\Controller\Interfaces\ToggleAwareInterface;
use Common\Controller\Lva\AbstractController;
use Common\FeatureToggle;
use Common\Service\Helper\FlashMessengerHelperService;
use Common\Service\Table\TableFactory;
use Dvsa\Olcs\Transfer\Query\Messaging\Conversations\ByOrganisation as ByOrganisationQuery;
use Dvsa\Olcs\Utils\Translation\NiTextTranslation;
use Laminas\View\Model\ViewModel;
use LmcRbacMvc\Service\AuthorizationService;

class MessagesController extends AbstractController implements ToggleAwareInterface
{
use Lva\Traits\ExternalControllerTrait;

protected $toggleConfig = [
'default' => [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;
}
}
32 changes: 32 additions & 0 deletions module/Olcs/src/Table/Tables/messages.table.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

declare(strict_types=1);

use Common\Service\Table\Formatter\ExternalConversationLink;

return [
'variables' => [
'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,
],
],
];
27 changes: 27 additions & 0 deletions module/Olcs/view/messages.phtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php
echo $this->partial(
'partials/page-header-simple',
[
'pageTitle' => $this->translate('dashboard.messages.title'),
],
);
?>

<div class="row">
<div class="dashboard two-thirds js-body">
<?php
echo $this->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;
?>
</div>

<?php echo $this->partial('partials/dashboard-right-column'); ?>
</div>

0 comments on commit b984fc6

Please sign in to comment.