Commit f0286d04 authored by Stefan Busemann's avatar Stefan Busemann
Browse files

Merge branch '31-performance-at-voting' into 'master'

Resolve "Performance at voting"

Closes #31

See merge request t3o/election!16
parents fed21919 542bd9e2
...@@ -23,11 +23,13 @@ class Elector extends AbstractPerson ...@@ -23,11 +23,13 @@ class Elector extends AbstractPerson
{ {
/** /**
* @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\T3o\Election\Domain\Model\Electorate> * @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\T3o\Election\Domain\Model\Electorate>
* @lazy
*/ */
protected $electorates = ''; protected $electorates = '';
/** /**
* @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\T3o\Election\Domain\Model\ElectionInvitation> * @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\T3o\Election\Domain\Model\ElectionInvitation>
* @lazy
*/ */
protected $electionInvitations = []; protected $electionInvitations = [];
......
...@@ -26,6 +26,7 @@ class Electorate extends AbstractEntity ...@@ -26,6 +26,7 @@ class Electorate extends AbstractEntity
/** /**
* @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\T3o\Election\Domain\Model\Elector> * @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\T3o\Election\Domain\Model\Elector>
* @lazy
*/ */
protected $electors = null; protected $electors = null;
......
...@@ -14,6 +14,7 @@ namespace T3o\Election\Domain\Repository; ...@@ -14,6 +14,7 @@ namespace T3o\Election\Domain\Repository;
* The TYPO3 project - inspiring people to share! * The TYPO3 project - inspiring people to share!
*/ */
use TYPO3\CMS\Extbase\Persistence\QueryInterface;
use TYPO3\CMS\Extbase\Persistence\Repository; use TYPO3\CMS\Extbase\Persistence\Repository;
use T3o\Election\Domain\Model\Elector; use T3o\Election\Domain\Model\Elector;
...@@ -22,6 +23,14 @@ use T3o\Election\Domain\Model\Elector; ...@@ -22,6 +23,14 @@ use T3o\Election\Domain\Model\Elector;
*/ */
class ElectorRepository extends Repository class ElectorRepository extends Repository
{ {
/**
* @var array
*/
protected $defaultOrderings = [
'uid' => QueryInterface::ORDER_DESCENDING
];
/** /**
* @var \T3o\Election\Domain\Repository\ElectorateRepository * @var \T3o\Election\Domain\Repository\ElectorateRepository
* @inject * @inject
......
{namespace core=TYPO3\CMS\Core\ViewHelpers} {namespace core=TYPO3\CMS\Core\ViewHelpers}
<table class="table"> <f:widget.paginate as="paginatedElectors" objects="{electors}" configuration="{itemsPerPage: 500, insertAbove: 1, insertBelow: 1, maximumNumberOfLinks: 10}">
<thead> <table class="table">
<tr> <thead>
<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">
<tr> <tr>
<td> <th>
<f:link.action action="edit" controller="BeElector" arguments="{elector:elector}"> <f:translate key="model.abstract_person.field.full_name">Name</f:translate>
{elector.fullName} </th>
</f:link.action> <th>
</td> <f:translate key="model.abstract_person.field.email">Email</f:translate>
<td> </th>
{elector.email} <th>
</td> <f:translate key="model.elector.field.electorates_number"># Electorates</f:translate>
<td> </th>
{elector.electorates -> f:count()} <th>
</td> <f:translate key="view.be.anything.options">Options</f:translate>
<td> </th>
<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> </tr>
</f:for> </thead>
</tbody> <tbody>
</table> <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 @@ ...@@ -6,8 +6,15 @@
<div class="form-control-wrap" style="max-width: 480px"> <div class="form-control-wrap" style="max-width: 480px">
<f:if condition="{electors}"> <f:if condition="{electors}">
<f:then> <f:then>
<f:form.select class="form-control" property="electors" options="{electors}" size="3" <f:if condition="{electors->f:count()} < 500">
optionLabelField="fullName" optionValueField="uid" multiple="true"/> <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:then>
<f:else> <f:else>
<f:translate key="model.electorate.field.electors_empty">No electors available.</f:translate> <f:translate key="model.electorate.field.electors_empty">No electors available.</f:translate>
......
Supports Markdown
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