make community layout clearer
All checks were successful
rvr-nextgen/pipeline/pr-master This commit looks good

This commit is contained in:
Bence Pőcze 2023-05-01 23:37:30 +02:00
parent b5dc96f98b
commit 584fcaba39
Signed by: bence
GPG Key ID: DC5BD6E95A333E6D
10 changed files with 123 additions and 79 deletions

View File

@ -71,8 +71,6 @@ class CommunityController implements IAuthenticationRequired
return new HtmlContent('communities/community', [ return new HtmlContent('communities/community', [
'community' => $community, 'community' => $community,
'members' => $this->getMembers($community),
'currencies' => $this->getCurrencies($community),
'upcomingEvents' => [], 'upcomingEvents' => [],
'debtItems' => $debtItems, 'debtItems' => $debtItems,
'debtBalance' => $debtBalance, 'debtBalance' => $debtBalance,
@ -83,6 +81,20 @@ class CommunityController implements IAuthenticationRequired
]); ]);
} }
public function getCommunitySettings(): ?IContent
{
if (!$this->checkPermission(\Container::$request->query('communityId'), false, $community, $ownCommunityMember)) {
return null;
}
return new HtmlContent('communities/community_settings', [
'community' => $community,
'members' => $this->getMembers($community),
'currencies' => $this->getCurrencies($community),
'editPermission' => $ownCommunityMember->getOwner()
]);
}
public function getCommunityNew(): IContent public function getCommunityNew(): IContent
{ {
return new HtmlContent('communities/community_edit'); return new HtmlContent('communities/community_edit');

View File

@ -86,6 +86,7 @@ class TransactionController implements IAuthenticationRequired, ISecured
'exchangeRateCalculator' => $exchangeRateCalculator, 'exchangeRateCalculator' => $exchangeRateCalculator,
'pages' => $pages, 'pages' => $pages,
'currentPage' => $currentPage, 'currentPage' => $currentPage,
'numberOfTransactions' => $numberOfTransactions,
'transactions' => $transactions 'transactions' => $transactions
]); ]);
} }

View File

@ -1,35 +1,16 @@
@extends(templates/layout_normal) @extends(templates/layout_normal)
@section(main) @section(main)
<h2><?= $community->getName() ?> <span class="small">[<a href="<?= Container::$routeCollection->getRoute('community-edit')->generateLink(['communityId' => $community->getId()]) ?>">edit</a>]</span></h2> <h2>
<?= $community->getName() ?>
<?php if ($editPermission): ?>
<span class="small">[<a href="<?= Container::$routeCollection->getRoute('community-edit')->generateLink(['communityId' => $community->getId()]) ?>">edit</a>]</span>
<?php endif; ?>
</h2>
<p class="marginTop"><a href="<?= Container::$routeCollection->getRoute('community.settings')->generateLink(['communityId' => $community->getId()]) ?>">Settings</a></p>
<div class="gridContainer marginTop"> <div class="gridContainer marginTop">
<div>
<h3 class="marginBottom">Members</h3>
<?php foreach ($members as $member): ?>
<p><?= $member->getUser()->getDisplayName() ?></p>
<?php endforeach; ?>
<?php if ($editPermission): ?>
<hr>
<p><a href="<?= Container::$routeCollection->getRoute('community-members')->generateLink(['communityId' => $community->getId()]) ?>">Edit members</a></p>
<?php endif; ?>
</div>
<div>
<h3 class="marginBottom">Currencies</h3>
<?php foreach ($currencies as $currency): ?>
<p>
<?php if ($currency->getId() === $community->getMainCurrencyId()): ?>
<b><?= $currency->getCode() ?></b>
<?php else: ?>
<a href="<?= Container::$routeCollection->getRoute('community-currency-exchange-rates')->generateLink(['communityId' => $community->getId(), 'code' => $currency->getCode()]) ?>"><?= $currency->getCode() ?></a>
<?php endif; ?>
</p>
<?php endforeach; ?>
<?php if ($editPermission): ?>
<hr>
<p><a href="<?= Container::$routeCollection->getRoute('community-currencies')->generateLink(['communityId' => $community->getId()]) ?>">Edit currencies</a></p>
<?php endif; ?>
</div>
<div> <div>
<h3 class="marginBottom">Upcoming events</h3> <h3 class="marginBottom">Upcoming events</h3>
<?php if (count($upcomingEvents) > 0): ?> <?php if (count($upcomingEvents) > 0): ?>

View File

@ -3,6 +3,7 @@
@section(main) @section(main)
<h2> <h2>
<a href="<?= Container::$routeCollection->getRoute('community')->generateLink(['communityId' => $community->getId()]) ?>"><?= $community->getName() ?></a> » <a href="<?= Container::$routeCollection->getRoute('community')->generateLink(['communityId' => $community->getId()]) ?>"><?= $community->getName() ?></a> »
<a href="<?= Container::$routeCollection->getRoute('community.settings')->generateLink(['communityId' => $community->getId()]) ?>">Settings</a> »
Edit currencies Edit currencies
</h2> </h2>
<div class="box compactBox"> <div class="box compactBox">

View File

@ -7,6 +7,7 @@
@section(main) @section(main)
<h2> <h2>
<a href="<?= Container::$routeCollection->getRoute('community')->generateLink(['communityId' => $community->getId()]) ?>"><?= $community->getName() ?></a> » <a href="<?= Container::$routeCollection->getRoute('community')->generateLink(['communityId' => $community->getId()]) ?>"><?= $community->getName() ?></a> »
<a href="<?= Container::$routeCollection->getRoute('community.settings')->generateLink(['communityId' => $community->getId()]) ?>">Settings</a> »
Edit members Edit members
</h2> </h2>
<div class="box compactBox"> <div class="box compactBox">

View File

@ -0,0 +1,39 @@
@extends(templates/layout_normal)
@section(main)
<h2>
<a href="<?= Container::$routeCollection->getRoute('community')->generateLink(['communityId' => $community->getId()]) ?>"><?= $community->getName() ?></a> »
Settings
</h2>
<div class="gridContainer marginTop">
<div>
<h3 class="marginBottom">
Members
<?php if ($editPermission): ?>
<span class="small">[<a href="<?= Container::$routeCollection->getRoute('community-members')->generateLink(['communityId' => $community->getId()]) ?>">edit</a>]</span>
<?php endif; ?>
</h3>
<?php foreach ($members as $member): ?>
<p><?= $member->getUser()->getDisplayName() ?></p>
<?php endforeach; ?>
</div>
<div>
<h3 class="marginBottom">
Currencies
<?php if ($editPermission): ?>
<span class="small">[<a href="<?= Container::$routeCollection->getRoute('community-currencies')->generateLink(['communityId' => $community->getId()]) ?>">edit</a>]</span>
<?php endif; ?>
</h3>
<?php foreach ($currencies as $currency): ?>
<p>
<?php if ($currency->getId() === $community->getMainCurrencyId()): ?>
<b><?= $currency->getCode() ?></b>
<?php else: ?>
<a href="<?= Container::$routeCollection->getRoute('community-currency-exchange-rates')->generateLink(['communityId' => $community->getId(), 'code' => $currency->getCode()]) ?>"><?= $currency->getCode() ?></a>
<?php endif; ?>
</p>
<?php endforeach; ?>
</div>
</div>
@endsection

View File

@ -3,6 +3,7 @@
@section(main) @section(main)
<h2> <h2>
<a href="<?= Container::$routeCollection->getRoute('community')->generateLink(['communityId' => $community->getId()]) ?>"><?= $community->getName() ?></a> » <a href="<?= Container::$routeCollection->getRoute('community')->generateLink(['communityId' => $community->getId()]) ?>"><?= $community->getName() ?></a> »
<a href="<?= Container::$routeCollection->getRoute('community.settings')->generateLink(['communityId' => $community->getId()]) ?>">Settings</a> »
Exchange rates for <?= $currency->getCode() ?> Exchange rates for <?= $currency->getCode() ?>
</h2> </h2>
<div class="box compactBox"> <div class="box compactBox">

View File

@ -8,6 +8,7 @@
<p class="marginTop"><a href="<?= Container::$routeCollection->getRoute('community.transactions.new')->generateLink(['communityId' => $community->getId()]) ?>">New transaction</a></p> <p class="marginTop"><a href="<?= Container::$routeCollection->getRoute('community.transactions.new')->generateLink(['communityId' => $community->getId()]) ?>">New transaction</a></p>
<?php if ($numberOfTransactions > 0): ?>
<?php if ($pages > 1): ?> <?php if ($pages > 1): ?>
<p class="paginateContainer marginTop"> <p class="paginateContainer marginTop">
<a href="<?= Container::$routeCollection->getRoute('community.transactions')->generateLink(['communityId' => $community->getId(), 'page' => 0]) ?>">«</a> <a href="<?= Container::$routeCollection->getRoute('community.transactions')->generateLink(['communityId' => $community->getId(), 'page' => 0]) ?>">«</a>
@ -59,4 +60,9 @@
<?php endif; ?> <?php endif; ?>
<p class="marginTop"><a href="<?= Container::$routeCollection->getRoute('community.transactions.new')->generateLink(['communityId' => $community->getId()]) ?>">New transaction</a></p> <p class="marginTop"><a href="<?= Container::$routeCollection->getRoute('community.transactions.new')->generateLink(['communityId' => $community->getId()]) ?>">New transaction</a></p>
<?php else: ?>
<div class="box">
<p>There are no transactions yet.</p>
</div>
<?php endif; ?>
@endsection @endsection

View File

@ -3,7 +3,10 @@
@section(main) @section(main)
<div class="gridContainer"> <div class="gridContainer">
<div> <div>
<h3 class="marginBottom">Communities</h3> <h3 class="marginBottom">
Communities
<span class="small">[<a href="<?= Container::$routeCollection->getRoute('community-new')->generateLink() ?>">new</a>]</span>
</h3>
<?php if (count($communities) > 0): ?> <?php if (count($communities) > 0): ?>
<?php foreach ($communities as $community): ?> <?php foreach ($communities as $community): ?>
<p><a href="<?= Container::$routeCollection->getRoute('community')->generateLink(['communityId' => $community->getId()]) ?>"><?= $community->getName() ?></a></p> <p><a href="<?= Container::$routeCollection->getRoute('community')->generateLink(['communityId' => $community->getId()]) ?>"><?= $community->getName() ?></a></p>
@ -11,8 +14,6 @@
<?php else: ?> <?php else: ?>
<p>You have no community.</p> <p>You have no community.</p>
<?php endif; ?> <?php endif; ?>
<hr>
<p><a href="<?= Container::$routeCollection->getRoute('community-new')->generateLink() ?>">New community</a></p>
</div> </div>
<div> <div>
<h3 class="marginBottom">Upcoming events</h3> <h3 class="marginBottom">Upcoming events</h3>

View File

@ -61,6 +61,7 @@ Container::$routeCollection->group('communities', function (RouteCollection $rou
$routeCollection->post('community-new-action', 'new', [CommunityController::class, 'saveCommunity']); $routeCollection->post('community-new-action', 'new', [CommunityController::class, 'saveCommunity']);
$routeCollection->group('{communityId}', function (RouteCollection $routeCollection) { $routeCollection->group('{communityId}', function (RouteCollection $routeCollection) {
$routeCollection->get('community', '', [CommunityController::class, 'getCommunityHome']); $routeCollection->get('community', '', [CommunityController::class, 'getCommunityHome']);
$routeCollection->get('community.settings', 'settings', [CommunityController::class, 'getCommunitySettings']);
$routeCollection->get('community-edit', 'edit', [CommunityController::class, 'getCommunityEdit']); $routeCollection->get('community-edit', 'edit', [CommunityController::class, 'getCommunityEdit']);
$routeCollection->post('community-edit-action', 'edit', [CommunityController::class, 'saveCommunity']); $routeCollection->post('community-edit-action', 'edit', [CommunityController::class, 'saveCommunity']);
$routeCollection->get('community-members', 'members', [CommunityController::class, 'getMembersEdit']); $routeCollection->get('community-members', 'members', [CommunityController::class, 'getMembersEdit']);