Commit a0d0aa20 authored by mabolek's avatar mabolek Committed by Thomas Löffler
Browse files

[FEATURE] Basic karma listing for user (without pagination)

parent dfe1d4df
......@@ -3,6 +3,7 @@
namespace T3o\Karma\Controller;
use T3o\Karma\Domain\Repository\KarmaSourceRepository;
use T3o\Karma\Domain\Repository\LedgerEntryRepository;
use T3o\Karma\Service\KarmaService;
use TYPO3\CMS\Extbase\Domain\Repository\FrontendUserRepository;
......@@ -46,6 +47,11 @@ class AbstractController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionControl
*/
protected $karmaSourceRepository;
/**
* @var LedgerEntryRepository
*/
protected $ledgerEntryRepository;
/**
* @param KarmaService $karmaService
*/
......@@ -70,4 +76,12 @@ class AbstractController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionControl
$this->karmaSourceRepository = $karmaSourceRepository;
}
/**
* @param LedgerEntryRepository $ledgerEntryRepository
*/
public function injectLedgerEntryRepository(LedgerEntryRepository $ledgerEntryRepository)
{
$this->ledgerEntryRepository = $ledgerEntryRepository;
}
}
......@@ -32,7 +32,9 @@ class UserDisplayController extends AbstractController
*/
public function listAction()
{
$entries = $this->ledgerEntryRepository->findByUser($GLOBALS['TSFE']->fe_user->user['uid']);
$this->view->assign('entries', $entries);
}
/*
......
......@@ -28,6 +28,16 @@ use T3o\Karma\Domain\Model\FrontendUser;
***************************************************************/
class LedgerEntry extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
{
/**
* @var \DateTime
*/
protected $crdate;
/**
* @var \DateTime
*/
protected $tstamp;
/**
* The date when the entry expired, if set.
*
......@@ -74,6 +84,46 @@ class LedgerEntry extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
*/
protected $user;
/**
* Get the creation date
*
* @return \DateTime
*/
public function getCrdate(): \DateTime
{
return $this->crdate;
}
/**
* Set the creation date
*
* @param \DateTime $crdate
*/
public function setCrdate(\DateTime $crdate)
{
$this->crdate = $crdate;
}
/**
* Get the last modified timestamp
*
* @return \DateTime
*/
public function getTstamp(): \DateTime
{
return $this->tstamp;
}
/**
* Set the last modified timestamp
*
* @param \DateTime $tstamp
*/
public function setTstamp(\DateTime $tstamp)
{
$this->tstamp = $tstamp;
}
/**
* Return the expired timestamp or zero if not yet expired
*
......
<section class="container">
<table class="table table-striped">
<thead>
<tr>
<th>Date</th>
<th>Description</th>
<th>Karma Points</th>
<th>Karma Cash</th>
</tr>
</thead>
<tbody>
<f:for each="{entries}" as="entry">
<tr id="entry-{entry.uid}">
<td>{entry.crdate -> f:format.date(format:'j F, Y')}</td>
<td>{entry.karmaSource.title}</td>
<td>{entry.immutableValue}</td>
<td>{entry.mutableValue}</td>
</tr>
</f:for>
</tbody>
</table>
</section>
\ No newline at end of file
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