Commit 542bd9e2 authored by Marco Huber's avatar Marco Huber

Performance optimizations if there are a lot of electors

parent fed21919
......@@ -23,11 +23,13 @@ class Elector extends AbstractPerson
{
/**
* @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\T3o\Election\Domain\Model\Electorate>
* @lazy
*/
protected $electorates = '';
/**
* @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\T3o\Election\Domain\Model\ElectionInvitation>
* @lazy
*/
protected $electionInvitations = [];
......
......@@ -26,6 +26,7 @@ class Electorate extends AbstractEntity
/**
* @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\T3o\Election\Domain\Model\Elector>
* @lazy
*/
protected $electors = null;
......
......@@ -14,6 +14,7 @@ namespace T3o\Election\Domain\Repository;
* The TYPO3 project - inspiring people to share!
*/
use TYPO3\CMS\Extbase\Persistence\QueryInterface;
use TYPO3\CMS\Extbase\Persistence\Repository;
use T3o\Election\Domain\Model\Elector;
......@@ -22,6 +23,14 @@ use T3o\Election\Domain\Model\Elector;
*/
class ElectorRepository extends Repository
{
/**
* @var array
*/
protected $defaultOrderings = [
'uid' => QueryInterface::ORDER_DESCENDING
];
/**
* @var \T3o\Election\Domain\Repository\ElectorateRepository
* @inject
......
{namespace core=TYPO3\CMS\Core\ViewHelpers}
<table class="table">
<thead>
<tr>
<th>
<f:translate key="model.abstract_person.field.full_name">Name</f:translate>
</th>
<th>
<f:translate key="model.abstract_person.field.email">Email</f:translate>
</th>
<th>
<f:translate key="model.elector.field.electorates_number"># Electorates</f:translate>
</th>
<th>
<f:translate key="view.be.anything.options">Options</f:translate>
</th>
</tr>
</thead>
<tbody>
<f:for each="{electors}" as="elector">
<f:widget.paginate as="paginatedElectors" objects="{electors}" configuration="{itemsPerPage: 500, insertAbove: 1, insertBelow: 1, maximumNumberOfLinks: 10}">
<table class="table">
<thead>
<tr>
<td>
<f:link.action action="edit" controller="BeElector" arguments="{elector:elector}">
{elector.fullName}
</f:link.action>
</td>
<td>
{elector.email}
</td>
<td>
{elector.electorates -> f:count()}
</td>
<td>
<div class="btn-group">
<f:link.action class="btn btn-default" action="edit" controller="BeElector" arguments="{elector:elector}">
<core:icon identifier="actions-edit-rename"/>
</f:link.action>
<f:link.action class="btn btn-default" action="delete" controller="BeElector" arguments="{elector:elector}">
<core:icon identifier="actions-edit-delete"/>
</f:link.action>
</div>
</td>
<th>
<f:translate key="model.abstract_person.field.full_name">Name</f:translate>
</th>
<th>
<f:translate key="model.abstract_person.field.email">Email</f:translate>
</th>
<th>
<f:translate key="model.elector.field.electorates_number"># Electorates</f:translate>
</th>
<th>
<f:translate key="view.be.anything.options">Options</f:translate>
</th>
</tr>
</f:for>
</tbody>
</table>
</thead>
<tbody>
<f:for each="{paginatedElectors}" as="elector">
<tr>
<td>
<f:link.action action="edit" controller="BeElector" arguments="{elector:elector}">
{elector.fullName}
</f:link.action>
</td>
<td>
{elector.email}
</td>
<td>
{elector.electorates -> f:count()}
</td>
<td>
<div class="btn-group">
<f:link.action class="btn btn-default" action="edit" controller="BeElector" arguments="{elector:elector}">
<core:icon identifier="actions-edit-rename"/>
</f:link.action>
<f:link.action class="btn btn-default" action="delete" controller="BeElector" arguments="{elector:elector}">
<core:icon identifier="actions-edit-delete"/>
</f:link.action>
</div>
</td>
</tr>
</f:for>
</tbody>
</table>
</f:widget.paginate>
......@@ -6,8 +6,15 @@
<div class="form-control-wrap" style="max-width: 480px">
<f:if condition="{electors}">
<f:then>
<f:form.select class="form-control" property="electors" options="{electors}" size="3"
optionLabelField="fullName" optionValueField="uid" multiple="true"/>
<f:if condition="{electors->f:count()} < 500">
<f:then>
<f:form.select class="form-control" property="electors" options="{electors}" size="3"
optionLabelField="fullName" optionValueField="uid" multiple="true"/>
</f:then>
<f:else>
<f:translate key="model.electorate.field.electors_tomany">More than 500 electors make this select field unusable. I't disabled.</f:translate>
</f:else>
</f:if>
</f:then>
<f:else>
<f:translate key="model.electorate.field.electors_empty">No electors available.</f:translate>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment