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

feat: Message conversation list page #21

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions module/Olcs/config/module.config.php
Original file line number Diff line number Diff line change
Expand Up @@ -1194,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\ConvictionsPenaltiesControllerFactory::class,

Check failure on line 1197 in module/Olcs/config/module.config.php

View workflow job for this annotation

GitHub Actions / static-analysis / PHPStan - 7.4

Class Olcs\Controller\Lva\DirectorChange\ConvictionsPenaltiesControllerFactory not found.

Check failure on line 1197 in module/Olcs/config/module.config.php

View workflow job for this annotation

GitHub Actions / static-analysis / Psalm - 7.4

UndefinedClass

module/Olcs/config/module.config.php:1197:57: UndefinedClass: Class, interface or enum named Olcs\Controller\Lva\DirectorChange\ConvictionsPenaltiesControllerFactory does not exist (see https://psalm.dev/019)
'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 @@ -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,

Check failure on line 1310 in module/Olcs/config/module.config.php

View workflow job for this annotation

GitHub Actions / static-analysis / Psalm - 7.4

MissingDependency

module/Olcs/config/module.config.php:1310:58: MissingDependency: Olcs\Controller\Factory\MessagesControllerFactory depends on class or interface laminas\servicemanager\factory\factoryinterface that does not exist (see https://psalm.dev/157)
PromptController::class => \Olcs\Controller\PromptControllerFactory::class,
// Process Signature from GOV.UK Account
\Olcs\Controller\SignatureVerificationController::class => \Olcs\Controller\SignatureVerificationControllerFactory::class,
Expand Down Expand Up @@ -1469,7 +1470,7 @@
),
'invokables' => array(
'generatePeopleList' => \Olcs\View\Helper\GeneratePeopleList::class,
'tmCheckAnswersChangeLink' => \Olcs\View\Helper\TmCheckAnswersChangeLink::class,

Check failure on line 1473 in module/Olcs/config/module.config.php

View workflow job for this annotation

GitHub Actions / static-analysis / PHPStan - 7.4

Class Olcs\View\Helper\TmCheckAnswersChangeLink not found.

Check failure on line 1473 in module/Olcs/config/module.config.php

View workflow job for this annotation

GitHub Actions / static-analysis / Psalm - 7.4

UndefinedClass

module/Olcs/config/module.config.php:1473:43: UndefinedClass: Class, interface or enum named Olcs\View\Helper\TmCheckAnswersChangeLink does not exist (see https://psalm.dev/019)
)
),
'view_manager' => array(
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

Check failure on line 16 in module/Olcs/src/Controller/Factory/MessagesControllerFactory.php

View workflow job for this annotation

GitHub Actions / static-analysis / PHPStan - 7.4

Class Olcs\Controller\Factory\MessagesControllerFactory implements unknown interface Laminas\ServiceManager\Factory\FactoryInterface.

Check failure on line 16 in module/Olcs/src/Controller/Factory/MessagesControllerFactory.php

View workflow job for this annotation

GitHub Actions / static-analysis / Psalm - 7.4

UndefinedClass

module/Olcs/src/Controller/Factory/MessagesControllerFactory.php:16:44: UndefinedClass: Class, interface or enum named Laminas\ServiceManager\Factory\FactoryInterface does not exist (see https://psalm.dev/019)
{
public function __invoke(ContainerInterface $container, $requestedName, array $options = null): MessagesController
{
$niTextTranslationUtil = $container->get(NiTextTranslation::class);
$authService = $container->get(AuthorizationService::class);

Check failure on line 21 in module/Olcs/src/Controller/Factory/MessagesControllerFactory.php

View workflow job for this annotation

GitHub Actions / static-analysis / PHPStan - 7.4

Class LmcRbacMvc\Service\AuthorizationService not found.
$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>
Loading