From 584fcaba39946b4a78cf758e1b99fec9efdaa9b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C5=91cze=20Bence?= Date: Mon, 1 May 2023 23:37:30 +0200 Subject: [PATCH] make community layout clearer --- src/Controller/CommunityController.php | 16 ++- src/Controller/TransactionController.php | 1 + views/communities/community.php | 35 ++---- views/communities/community_currencies.php | 1 + views/communities/community_members.php | 1 + views/communities/community_settings.php | 39 +++++++ views/communities/currency_exchange_rates.php | 1 + views/communities/transactions.php | 100 ++++++++++-------- views/home.php | 7 +- web.php | 1 + 10 files changed, 123 insertions(+), 79 deletions(-) create mode 100644 views/communities/community_settings.php diff --git a/src/Controller/CommunityController.php b/src/Controller/CommunityController.php index 239d47c..77b1aa3 100644 --- a/src/Controller/CommunityController.php +++ b/src/Controller/CommunityController.php @@ -71,8 +71,6 @@ class CommunityController implements IAuthenticationRequired return new HtmlContent('communities/community', [ 'community' => $community, - 'members' => $this->getMembers($community), - 'currencies' => $this->getCurrencies($community), 'upcomingEvents' => [], 'debtItems' => $debtItems, '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 { return new HtmlContent('communities/community_edit'); diff --git a/src/Controller/TransactionController.php b/src/Controller/TransactionController.php index c6b484d..3f075c9 100644 --- a/src/Controller/TransactionController.php +++ b/src/Controller/TransactionController.php @@ -86,6 +86,7 @@ class TransactionController implements IAuthenticationRequired, ISecured 'exchangeRateCalculator' => $exchangeRateCalculator, 'pages' => $pages, 'currentPage' => $currentPage, + 'numberOfTransactions' => $numberOfTransactions, 'transactions' => $transactions ]); } diff --git a/views/communities/community.php b/views/communities/community.php index 2e62a09..13ce2dc 100644 --- a/views/communities/community.php +++ b/views/communities/community.php @@ -1,35 +1,16 @@ @extends(templates/layout_normal) @section(main) -

getName() ?> [edit]

+

+ getName() ?> + + [edit] + +

+ +

Settings

-
-

Members

- -

getUser()->getDisplayName() ?>

- - -
-

Edit members

- -
-
-

Currencies

- -

- getId() === $community->getMainCurrencyId()): ?> - getCode() ?> - - getCode() ?> - -

- - -
-

Edit currencies

- -

Upcoming events

0): ?> diff --git a/views/communities/community_currencies.php b/views/communities/community_currencies.php index 36ad30c..ab19f0b 100644 --- a/views/communities/community_currencies.php +++ b/views/communities/community_currencies.php @@ -3,6 +3,7 @@ @section(main)

getName() ?> » + Settings » Edit currencies

diff --git a/views/communities/community_members.php b/views/communities/community_members.php index 4818b1b..0397cbd 100644 --- a/views/communities/community_members.php +++ b/views/communities/community_members.php @@ -7,6 +7,7 @@ @section(main)

getName() ?> » + Settings » Edit members

diff --git a/views/communities/community_settings.php b/views/communities/community_settings.php new file mode 100644 index 0000000..03b979a --- /dev/null +++ b/views/communities/community_settings.php @@ -0,0 +1,39 @@ +@extends(templates/layout_normal) + +@section(main) +

+ getName() ?> » + Settings +

+ +
+
+

+ Members + + [edit] + +

+ +

getUser()->getDisplayName() ?>

+ +
+
+

+ Currencies + + [edit] + +

+ +

+ getId() === $community->getMainCurrencyId()): ?> + getCode() ?> + + getCode() ?> + +

+ +
+
+@endsection diff --git a/views/communities/currency_exchange_rates.php b/views/communities/currency_exchange_rates.php index b3e73b0..e880d99 100644 --- a/views/communities/currency_exchange_rates.php +++ b/views/communities/currency_exchange_rates.php @@ -3,6 +3,7 @@ @section(main)

getName() ?> » + Settings » Exchange rates for getCode() ?>

diff --git a/views/communities/transactions.php b/views/communities/transactions.php index 3a7cf0f..216c52d 100644 --- a/views/communities/transactions.php +++ b/views/communities/transactions.php @@ -8,55 +8,61 @@

New transaction

- 1): ?> -

- « - - - - - - - - - - » -

- + 0): ?> + 1): ?> +

+ « + + + + + + + + + + » +

+ - - -
-
-

getDescription() ?>

-

getPayerUser()->getDisplayName() ?> ► getPayeeUser() ? $transaction->getPayeeUser()->getDisplayName() : '[common]' ?>

-

getTimeDate()->format('Y-m-d H:i') ?>

-
-
-

calculate($transaction->getSum(), $transaction->getCurrency(), $transaction->getTimeDate()), $community->getMainCurrency()->getRoundDigits()) ?> getMainCurrency()->getCode() ?>

- getMainCurrencyId() !== $transaction->getCurrencyId()): ?> -

getSum(), $transaction->getCurrency()->getRoundDigits()) ?> getCurrency()->getCode() ?>

- + +
+
+
+

getDescription() ?>

+

getPayerUser()->getDisplayName() ?> ► getPayeeUser() ? $transaction->getPayeeUser()->getDisplayName() : '[common]' ?>

+

getTimeDate()->format('Y-m-d H:i') ?>

+
+
+

calculate($transaction->getSum(), $transaction->getCurrency(), $transaction->getTimeDate()), $community->getMainCurrency()->getRoundDigits()) ?> getMainCurrency()->getCode() ?>

+ getMainCurrencyId() !== $transaction->getCurrencyId()): ?> +

getSum(), $transaction->getCurrency()->getRoundDigits()) ?> getCurrency()->getCode() ?>

+ +
+
+ + + 1): ?> +

+ « + + + + + + + + + + » +

+ + +

New transaction

+ +
+

There are no transactions yet.

- - - - 1): ?> -

- « - - - - - - - - - - » -

- -

New transaction

@endsection diff --git a/views/home.php b/views/home.php index cc3a6a6..f88aa66 100644 --- a/views/home.php +++ b/views/home.php @@ -3,7 +3,10 @@ @section(main)
-

Communities

+

+ Communities + [new] +

0): ?>

getName() ?>

@@ -11,8 +14,6 @@

You have no community.

-
-

New community

Upcoming events

diff --git a/web.php b/web.php index 4f2f758..e5b3421 100644 --- a/web.php +++ b/web.php @@ -61,6 +61,7 @@ Container::$routeCollection->group('communities', function (RouteCollection $rou $routeCollection->post('community-new-action', 'new', [CommunityController::class, 'saveCommunity']); $routeCollection->group('{communityId}', function (RouteCollection $routeCollection) { $routeCollection->get('community', '', [CommunityController::class, 'getCommunityHome']); + $routeCollection->get('community.settings', 'settings', [CommunityController::class, 'getCommunitySettings']); $routeCollection->get('community-edit', 'edit', [CommunityController::class, 'getCommunityEdit']); $routeCollection->post('community-edit-action', 'edit', [CommunityController::class, 'saveCommunity']); $routeCollection->get('community-members', 'members', [CommunityController::class, 'getMembersEdit']);