Compare commits

..

4 Commits

Author SHA1 Message Date
894ff2be48
RVRNEXT-5 make prepare-commit-msg accept fixup commits
All checks were successful
rvr-nextgen/pipeline/pr-master This commit looks good
2023-04-23 20:09:49 +02:00
50b8cb023d
RVRNEXT-5 fix layouts for communities 2023-04-23 20:09:49 +02:00
83cfec9d68
RVRNEXT-5 adjust table style 2023-04-23 20:09:49 +02:00
a9b22e2622
RVRNEXT-5 update CommunityController with currency operations 2023-04-23 20:09:49 +02:00
4 changed files with 21 additions and 24 deletions

View File

@ -49,7 +49,7 @@ var RVR = {
document.getElementById('loading').style.visibility = 'visible';
var formData = new FormData(form);
var formError = document.getElementsByClassName('formError')[0];
var formError = form.getElementsByClassName('formError')[0];
var pageLeaveOnSuccess = form.dataset.redirectOnSuccess || form.dataset.reloadOnSuccess;
RVR.httpRequest('POST', form.action, function () {

View File

@ -85,6 +85,15 @@ class CommunityController implements IAuthenticationRequired
]);
}
private function getMembers(Community $community): array
{
$members = iterator_to_array($this->communityMemberRepository->getAllByCommunity($community, true));
usort($members, function($a, $b) {
return strnatcmp($a->getUser()->getDisplayName(), $b->getUser()->getDisplayName());
});
return $members;
}
public function newMember(): ?IContent
{
if (!$this->checkPermission(\Container::$request->query('communityId'), true, $community, $ownCommunityMember)) {
@ -151,6 +160,15 @@ class CommunityController implements IAuthenticationRequired
]);
}
private function getCurrencies(Community $community): array
{
$currencies = iterator_to_array($this->currencyRepository->getAllByCommunity($community));
usort($currencies, function($a, $b) {
return strnatcmp($a->getCode(), $b->getCode());
});
return $currencies;
}
public function newCurrency(): ?IContent
{
if (!$this->checkPermission(\Container::$request->query('communityId'), true, $community, $ownCommunityMember)) {
@ -158,8 +176,7 @@ class CommunityController implements IAuthenticationRequired
}
$code = \Container::$request->post('code');
$roundDigits = (int)\Container::$request->post('round_digits');
if (strlen($code) === 0 || strlen($code) > 3 || $roundDigits < 0 || $roundDigits > 9) {
if (strlen($code) === 0 || strlen($code) > 3) {
return new JsonContent([
'error' => ['errorText' => 'Please fill all required fields!']
]);
@ -175,7 +192,7 @@ class CommunityController implements IAuthenticationRequired
$currency = new Currency();
$currency->setCommunity($community);
$currency->setCode($code);
$currency->setRoundDigits($roundDigits);
$currency->setRoundDigits((int)\Container::$request->post('round_digits'));
\Container::$persistentDataManager->saveToDb($currency);
return new JsonContent(['success' => true]);
@ -251,24 +268,6 @@ class CommunityController implements IAuthenticationRequired
]);
}
private function getMembers(Community $community): array
{
$members = iterator_to_array($this->communityMemberRepository->getAllByCommunity($community, true));
usort($members, function($a, $b) {
return strnatcmp($a->getUser()->getDisplayName(), $b->getUser()->getDisplayName());
});
return $members;
}
private function getCurrencies(Community $community): array
{
$currencies = iterator_to_array($this->currencyRepository->getAllByCommunity($community));
usort($currencies, function($a, $b) {
return strnatcmp($a->getCode(), $b->getCode());
});
return $currencies;
}
private function checkPermission(
int $communityId,
bool $needToBeOwner,

View File

@ -40,6 +40,5 @@
</td>
</tr>
</table>
<p class="formError justify marginTop"></p>
</div>
@endsection

View File

@ -47,7 +47,6 @@
</td>
</tr>
</table>
<p class="formError justify marginTop"></p>
</div>
@endsection