Skip to content

Commit

Permalink
[BUGFIX] Fix pagination in module for email list
Browse files Browse the repository at this point in the history
Related: #1119
  • Loading branch information
vnc-jboe authored and mschwemer committed Sep 18, 2024
1 parent 2ddcd84 commit a3cead4
Show file tree
Hide file tree
Showing 2 changed files with 93 additions and 44 deletions.
9 changes: 2 additions & 7 deletions Classes/Controller/ModuleController.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,8 @@ public function listAction(): ResponseInterface
$formUids = $this->mailRepository->findGroupedFormUidsToGivenPageUid((int)$this->id);
$mails = $this->mailRepository->findAllInPid((int)$this->id, $this->settings, $this->piVars);

$currentPage = 1;
if ($this->request->hasArgument('tx_powermail_web_powermailm1')) {
$moduleArguments = $this->request->getArgument('tx_powermail_web_powermailm1');
if (array_key_exists('currentPage', $moduleArguments)) {
$currentPage = (int)$moduleArguments['currentPage'];
}
}
$currentPage = (int)($this->request->getQueryParams()['currentPage'] ?? 1);
$currentPage = $currentPage > 0 ? $currentPage : 1;

$itemsPerPage = (int)($this->settings['perPage'] ?? 10);
$paginator = GeneralUtility::makeInstance(QueryResultPaginator::class, $mails, $currentPage, $itemsPerPage);
Expand Down
128 changes: 91 additions & 37 deletions Resources/Private/Partials/Module/Pagination.html
Original file line number Diff line number Diff line change
@@ -1,39 +1,93 @@
<nav aria-label="Powermail navigation">
<ul class="pagination">
<f:if condition="{pagination.previousPageNumber} && {pagination.previousPageNumber} >= {pagination.firstPageNumber}">
<f:then>
<li class="page-item previous">
<a href="{f:uri.action(action:actionName, arguments:{currentPage: pagination.previousPageNumber})}"
title="{f:translate(key:'pagination.previous')}" class="page-link">
{f:translate(key:'widget.pagination.previous', extensionName: 'fluid')}
</a>
</li>
</f:then>
<f:else>
</f:else>
</f:if>
<f:if condition="{pagination.hasLessPages}">
<li class="page-item"></li>
</f:if>
<f:for each="{pagination.allPageNumbers}" as="page">
<li class="page-item {f:if(condition: '{page} == {paginator.currentPageNumber}', then:'active')}">
<a href="{f:uri.action(action:actionName, arguments:{currentPage: page})}" class="page-link">{page}</a>
</li>
</f:for>
<f:if condition="{pagination.hasMorePages}">
<li class="page-item"></li>
</f:if>
<f:if condition="{pagination.nextPageNumber} && {pagination.nextPageNumber} <= {pagination.lastPageNumber}">
<f:then>
<li class="page-item next">
<a href="{f:uri.action(action:actionName, arguments:{currentPage: pagination.nextPageNumber})}"
title="{f:translate(key:'pagination.next')}" class="page-link">
{f:translate(key:'widget.pagination.next', extensionName: 'fluid')}
</a>
</li>
</f:then>
<f:else>
</f:else>
</f:if>
</ul>
<style>
._pagination {
--bs-pagination-padding-x: 0.75rem;
--bs-pagination-padding-y: 0.375rem;
--bs-pagination-font-size: 0.75rem;
--bs-pagination-color: var(--bs-link-color);
--bs-pagination-bg: #fff;
--bs-pagination-border-width: 1px;
--bs-pagination-border-color: #d7d7d7;
--bs-pagination-border-radius: 0.125rem;
--bs-pagination-hover-color: var(--bs-link-hover-color);
--bs-pagination-hover-bg: #eeeeee;
--bs-pagination-hover-border-color: #d7d7d7;
--bs-pagination-focus-color: var(--bs-link-hover-color);
--bs-pagination-focus-bg: #eeeeee;
--bs-pagination-focus-box-shadow: 0 0 0 0.25rem rgba(0, 120, 230, 0.25);
--bs-pagination-active-color: #fff;
--bs-pagination-active-bg: #0078e6;
--bs-pagination-active-border-color: #0078e6;
--bs-pagination-disabled-color: #737373;
--bs-pagination-disabled-bg: #fff;
--bs-pagination-disabled-border-color: #d7d7d7;
display: flex;
padding-left: 0;
list-style: none;
}

._pagination>li {display:inline-block;}

._pagination > li > a {
position: relative;
float: left;
padding: 6px 12px;
margin-left: -1px;
line-height: 1.42857143;
color: #337ab7;
text-decoration: none;
background-color: #fff;
border: 1px solid #ddd;
}

._pagination>.active>a,
._pagination>.active>span,
._pagination>.active>a:hover,
._pagination>.active>span:hover,
._pagination>.active>a:focus,
._pagination>.active>span:focus {
z-index: 3;
color: #fff;
cursor: default;
background-color: #337ab7;
border-color: #337ab7;
}
</style>
<ul class="_pagination" style="display: inline-block; padding-left: 0;margin: 20px 0; border-radius: 4px;">
<f:if condition="{pagination.previousPageNumber} && {pagination.previousPageNumber} >= {pagination.firstPageNumber}">
<f:then>
<li class="page-item previous">
<a href="{f:uri.action(action:actionName, arguments:{currentPage: pagination.previousPageNumber})}"
title="{f:translate(key:'pagination.previous')}" class="page-link">
{f:translate(key:'widget.pagination.previous', extensionName: 'fluid')}
</a>
</li>
</f:then>
<f:else>
</f:else>
</f:if>
<f:if condition="{pagination.hasLessPages}">
<li class="page-item"></li>
</f:if>
<f:for each="{pagination.allPageNumbers}" as="page">
<li class="page-item {f:if(condition: '{page} == {paginator.currentPageNumber}', then:'active')}">
<a href="{f:uri.action(action:actionName, arguments:{currentPage: page})}" class="page-link">{page}</a>
</li>
</f:for>
<f:if condition="{pagination.hasMorePages}">
<li class="page-item"></li>
</f:if>
<f:if condition="{pagination.nextPageNumber} && {pagination.nextPageNumber} <= {pagination.lastPageNumber}">
<f:then>
<li class="page-item next">
<a href="{f:uri.action(action:actionName, arguments:{currentPage: pagination.nextPageNumber})}"
title="{f:translate(key:'pagination.next')}" class="page-link">
{f:translate(key:'widget.pagination.next', extensionName: 'fluid')}
</a>
</li>
</f:then>
<f:else>
</f:else>
</f:if>
</ul>
</nav>

0 comments on commit a3cead4

Please sign in to comment.