Commit e4d36514 authored by Oliver Eglseder's avatar Oliver Eglseder
Browse files

[TASK] Add quick hide/show buttons to nominees (property public)

parent ed345da6
......@@ -28,6 +28,8 @@ class BeNomineeController extends AbstractProtectedBeController
const ACTION_CREATE = 'create';
const ACTION_EDIT = 'edit';
const ACTION_UPDATE = 'update';
const ACTION_HIDE = 'hide';
const ACTION_SHOW = 'show';
/**
* @var \TYPO3\Election\Domain\Repository\NomineeRepository
......@@ -85,6 +87,26 @@ class BeNomineeController extends AbstractProtectedBeController
$this->redirect(self::ACTION_LIST);
}
/**
* @param Nominee $nominee
*/
public function hideAction(Nominee $nominee)
{
$nominee->setPublic(false);
$this->nomineeRepository->update($nominee);
$this->redirect(self::ACTION_LIST);
}
/**
* @param Nominee $nominee
*/
public function showAction(Nominee $nominee)
{
$nominee->setPublic(true);
$this->nomineeRepository->update($nominee);
$this->redirect(self::ACTION_LIST);
}
/**
* @return string
*/
......@@ -98,6 +120,8 @@ class BeNomineeController extends AbstractProtectedBeController
self::ACTION_CREATE,
self::ACTION_EDIT,
self::ACTION_UPDATE,
self::ACTION_HIDE,
self::ACTION_SHOW,
]
);
}
......
......@@ -14,6 +14,7 @@ namespace TYPO3\Election\Domain\Repository;
* The TYPO3 project - inspiring people to share!
*/
use TYPO3\CMS\Extbase\Persistence\QueryInterface;
use TYPO3\CMS\Extbase\Persistence\Repository;
/**
......@@ -21,4 +22,11 @@ use TYPO3\CMS\Extbase\Persistence\Repository;
*/
class NomineeRepository extends Repository
{
/**
* @var array
*/
protected $defaultOrderings = [
'public' => QueryInterface::ORDER_DESCENDING,
'lastName' => QueryInterface::ORDER_ASCENDING,
];
}
......@@ -246,6 +246,12 @@
<trans-unit id="view.be.nominee.edit.welcome">
<source>Edit a Nominee</source>
</trans-unit>
<trans-unit id="view.be.nominee.list.hide_link_title">
<source>Hide this nominee from public</source>
</trans-unit>
<trans-unit id="view.be.nominee.list.show_link_title">
<source>Make this nominee public</source>
</trans-unit>
<!-- MODEL NOMINEE -->
......
......@@ -22,12 +22,12 @@
</thead>
<tbody>
<f:for each="{nominees}" as="nominee">
<tr>
<tr {f:if(condition:'{nominee.public}',else:'style="background-color:#ddd;"')}>
<td>
<f:image image="{nominee.image}" width="50c" height="50c"/>
</td>
<td>
<f:link.action action="edit" controller="BeElector" arguments="{elector:elector}">
<f:link.action action="edit" controller="BeNominee" arguments="{nominee:nominee}">
{nominee.fullName}
</f:link.action>
</td>
......@@ -47,6 +47,20 @@
arguments="{nominee:nominee}">
<core:icon identifier="actions-edit-delete"/>
</f:link.action>
<f:if condition="{nominee.public}">
<f:then>
<f:link.action class="btn btn-default" action="hide" controller="BeNominee"
arguments="{nominee:nominee}" title="{f:translate(key:'view.be.nominee.list.hide_link_title')}">
<core:icon identifier="actions-edit-hide"/>
</f:link.action>
</f:then>
<f:else>
<f:link.action class="btn btn-default" action="show" controller="BeNominee"
arguments="{nominee:nominee}" title="{f:translate(key:'view.be.nominee.list.show_link_title')}">
<core:icon identifier="actions-edit-unhide"/>
</f:link.action>
</f:else>
</f:if>
</div>
</td>
</tr>
......
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