This repository has been archived by the owner on Aug 16, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Message conversation list page
- Loading branch information
Showing
5 changed files
with
209 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
module/Olcs/src/Controller/Factory/MessagesControllerFactory.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
], | ||
], | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |