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

feat: List messages in a conversation. #23

Merged
Show file tree
Hide file tree
Changes from 1 commit
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
31 changes: 31 additions & 0 deletions module/Olcs/src/Controller/ConversationsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Common\FeatureToggle;
use Common\Service\Helper\FlashMessengerHelperService;
use Common\Service\Table\TableFactory;
use Dvsa\Olcs\Transfer\Query\Messaging\Messages\ByConversation as ByConversationQuery;
use Dvsa\Olcs\Transfer\Query\Messaging\Conversations\ByOrganisation as ByOrganisationQuery;
use Dvsa\Olcs\Utils\Translation\NiTextTranslation;
use Laminas\View\Model\ViewModel;
Expand Down Expand Up @@ -69,4 +70,34 @@ public function indexAction(): ViewModel

return $view;
}

public function viewAction(): ViewModel
{
$params = [
'page' => $this->params()->fromQuery('page', 1),
'limit' => $this->params()->fromQuery('limit', 10),
'conversation' => $this->params()->fromRoute('conversationId'),
'query' => $this->params()->fromQuery(),
];

$response = $this->handleQuery(ByConversationQuery::create($params));
if ($response === null) {
jerotire marked this conversation as resolved.
Show resolved Hide resolved
return $this->notFoundAction();
}

if ($response->isOk()) {
$messages = $response->getResult();
} else {
$this->flashMessengerHelper->addErrorMessage('unknown-error');
$messages = [];
}

$table = $this->tableFactory
->buildTable('messages-view', $messages, $params);

$view = new ViewModel(['table' => $table]);
$view->setTemplate('messages-view');

return $view;
}
}
29 changes: 29 additions & 0 deletions module/Olcs/src/Table/Tables/messages-view.table.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

declare(strict_types=1);

use Common\Service\Table\Formatter\ExternalConversationMessage;

return [
'attributes' => [
'class' => 'no-row-border-separator'
],
'variables' => [
'id' => 'messages-list-table',
'title' => 'Messages',
'empty_message' => 'There are no message records linked to this conversation to display'
],
'settings' => [
'paginate' => [
'limit' => [
'options' => [10, 25, 50],
],
],
],
'columns' => [
[
'name' => 'id',
'formatter' => ExternalConversationMessage::class,
],
],
];
27 changes: 27 additions & 0 deletions module/Olcs/view/messages-view.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.view.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