Commit 78aff044 authored by Tomas Norre Mikkelsen's avatar Tomas Norre Mikkelsen

Resolve "Add list of liked extensions to "My Extensions" view"

parent 149cea23
......@@ -36,7 +36,7 @@ class RegisterkeyController extends \T3o\TerFe2\Controller\AbstractTerBasedContr
protected $versionRepository;
/**
* @var \TYPO3\CMS\Extbase\Domain\Repository\FrontendUserRepository
* @var \T3o\TerFe2\Domain\Repository\FrontendUserRepository
*/
protected $userRepository;
......@@ -63,9 +63,9 @@ class RegisterkeyController extends \T3o\TerFe2\Controller\AbstractTerBasedContr
/**
* inject userRepository
*
* @param \TYPO3\CMS\Extbase\Domain\Repository\FrontendUserRepository $userRepository
* @param \T3o\TerFe2\Domain\Repository\FrontendUserRepository $userRepository
*/
public function injectUserRepository(\TYPO3\CMS\Extbase\Domain\Repository\FrontendUserRepository $userRepository)
public function injectUserRepository(\T3o\TerFe2\Domain\Repository\FrontendUserRepository $userRepository)
{
$this->userRepository = $userRepository;
}
......@@ -79,11 +79,14 @@ class RegisterkeyController extends \T3o\TerFe2\Controller\AbstractTerBasedContr
{
// get extensions by user if a user is logged in
if ($GLOBALS['TSFE']->fe_user->user['uid']) {
$this->frontendUser = $this->userRepository->findByUid($GLOBALS['TSFE']->fe_user->user['uid']);
$extensions = $this->extensionRepository->findByFrontendUser($this->frontendUser->getUsername());
$expiringExtensions = $this->extensionRepository->findByFrontendUserAndExpiring($this->frontendUser->getUsername());
/** @var \T3o\TerFe2\Domain\Model\FrontendUser $frontendUser */
$frontendUser = $this->userRepository->findByUid($GLOBALS['TSFE']->fe_user->user['uid']);
$extensions = $this->extensionRepository->findByFrontendUser($frontendUser->getUsername());
$expiringExtensions = $this->extensionRepository->findByFrontendUserAndExpiring($frontendUser->getUsername());
$likedExtensions = $frontendUser->getLikedExtensions();
$this->view->assign('extensions', $extensions);
$this->view->assign('expiringExtensions', $expiringExtensions);
$this->view->assign('likedExtensions', $likedExtensions);
$this->view->assign('uploaded', $uploaded);
}
}
......
<html xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers" data-namespace-typo3-fluid="true">
<span class="ml-3">
<f:security.ifAuthenticated>
<f:then>
<f:if condition="{hasLiked}">
<f:if condition="{showOnly}">
<f:then>
<f:format.number decimals="0" thousandsSeparator=",">{extension.likes}</f:format.number>
</f:then>
<f:else>
<span class="ml-3">
<f:security.ifAuthenticated>
<f:then>
<button class="btn btn-primary" data-rating-type="dislike" data-rating-extension="{extension.uid}" title="Click to dislike">
<i class="fa fa-heart"></i>&nbsp;<f:format.number decimals="0" thousandsSeparator=".">{extension.likes}</f:format.number>
</button>
<f:if condition="{hasLiked}">
<f:then>
<button class="btn btn-primary" data-rating-type="dislike" data-rating-extension="{extension.uid}" title="Click to dislike">
<i class="fa fa-heart"></i>&nbsp;<f:format.number decimals="0" thousandsSeparator=",">{extension.likes}</f:format.number>
</button>
</f:then>
<f:else>
<button class="btn btn-outline-primary" data-rating-type="like" data-rating-extension="{extension.uid}" title="Click to like">
<i class="fa fa-heart-o"></i>&nbsp;<f:format.number decimals="0" thousandsSeparator=",">{extension.likes}</f:format.number>
</button>
</f:else>
</f:if>
</f:then>
<f:else>
<button class="btn btn-outline-primary" data-rating-type="like" data-rating-extension="{extension.uid}" title="Click to like">
<i class="fa fa-heart-o"></i>&nbsp;<f:format.number decimals="0" thousandsSeparator=".">{extension.likes}</f:format.number>
<button class="btn btn-outline-primary" data-login="1" title="Login to like">
<i class="fa fa-heart-o"></i>&nbsp;<f:format.number decimals="0" thousandsSeparator=",">{extension.likes}</f:format.number>
</button>
</f:else>
</f:if>
</f:then>
<f:else>
<button class="btn btn-outline-primary" data-login="1" title="Login to like">
<i class="fa fa-heart-o"></i>&nbsp;<f:format.number decimals="0" thousandsSeparator=".">{extension.likes}</f:format.number>
</button>
</f:else>
</f:security.ifAuthenticated>
</span>
</f:security.ifAuthenticated>
</span>
</f:else>
</f:if>
</html>
......@@ -29,6 +29,11 @@
<a class="nav-link" id="expiretab" data-toggle="tab" href="#expiring" role="tab">Expiring extension keys</a>
</li>
</f:if>
<f:if condition="{likedExtensions -> f:count()}">
<li class="nav-item">
<a class="nav-link" data-toggle="tab" href="#liked" role="tab">My liked extensions</a>
</li>
</f:if>
<li class="nav-item">
<a class="nav-link" data-toggle="tab" href="#register" role="tab">Register extension key</a>
</li>
......@@ -47,9 +52,15 @@
<table class="table table-striped">
<thead>
<tr>
<th colspan="2">
<th>
<f:translate key="extensionKey" />
</th>
<th>
Likes
</th>
<th class="text-right">
Actions
</th>
</tr>
</thead>
<tbody>
......@@ -85,6 +96,9 @@
</f:if>
</small>
</td>
<td>
<f:render partial="Like" arguments="{extension: extension, showOnly: 1}" />
</td>
<td class="text-right">
<f:if condition="{extension.versionCount} < 1">
<f:then>
......@@ -168,6 +182,47 @@
</table>
</div>
</f:if>
<f:if condition="{likedExtensions}">
<f:variable name="hasLiked" value="1" />
<div class="tab-pane" id="liked" role="tabpanel">
<table class="table table-striped">
<thead>
<tr>
<th>
Extension key
</th>
<th>
Download latest version
</th>
<th class="text-right">
Likes
</th>
</tr>
</thead>
<tbody>
<f:for each="{likedExtensions}" as="extension">
<tr>
<td class="text-middle">
<f:link.action controller="Extension" action="show" arguments="{extension: extension}">{extension.extKey}</f:link.action>
</td>
<td>
<f:if condition="{extension.lastVersion.reviewState} != -1">
<f:link.action class="btn btn-primary" controller="Extension" action="download" arguments="{extension : extension, versionString : extension.lastVersion.versionString, format : 'zip'}">
<strong>Download <span itemprop="softwareVersion">{extension.lastVersion.versionString}</span></strong>
</f:link.action>
</f:if>
</td>
<td class="text-right">
<f:render partial="Like" arguments="{extension: extension,showOnly: 1}" />
</td>
</tr>
</f:for>
</tbody>
</table>
</div>
</f:if>
<div class="tab-pane" id="register" role="tabpanel">
<f:form action="create" controller="Registerkey" class="form-inline mt-3" method="post">
......
......@@ -61,7 +61,7 @@ jQuery(document).ready(function ($) {
let pageType = 0;
let removeClass = '';
let addClass = '';
let likes = $(item).text().trim();
let likes = $(item).text().trim().replace(',', '');
let newRatingType = '';
let ratingType = $(item).data('rating-type');
if (ratingType === 'like') {
......@@ -87,7 +87,7 @@ jQuery(document).ready(function ($) {
success: function (returnData) {
$(item).removeClass(removeClass).addClass(addClass);
$(item).data('rating-type', newRatingType);
item.lastChild.nodeValue = " " + likes;
item.lastChild.nodeValue = " " + likes.toLocaleString('en');
}
});
})
......
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