Skip to content

Commit

Permalink
Merge pull request #71 from deanblackborough/main
Browse files Browse the repository at this point in the history
Minor fixes
  • Loading branch information
deanblackborough authored Mar 1, 2023
2 parents 5c070aa + d7e5af4 commit ae24fb6
Show file tree
Hide file tree
Showing 18 changed files with 294 additions and 281 deletions.
2 changes: 1 addition & 1 deletion app/Http/Controllers/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ protected function getBudgetItems(): array
$this->resource_type_id,
$this->resource_id,
[
'limit' => 50,
'limit' => 100,
'sort' => 'amount:desc|created:asc',
]
);
Expand Down
421 changes: 213 additions & 208 deletions composer.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions config/app/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
'item_subtype_id' => env('ITEM_SUBTYPE_ID'),
'cookie_user' => env('SESSION_NAME_USER'),
'cookie_bearer' => env('SESSION_NAME_BEARER'),
'version' => 'v1.10.1',
'release_date' => '16th February 2023',
'version' => 'v1.10.2',
'release_date' => '1st March 2023',
'exception_notification_email' => env('EXCEPTION_NOTIFICATION_EMAIL'),
'timezone' => 'UTC', // We can allow users to override this later
];
28 changes: 0 additions & 28 deletions public/js/filter-budget-by-account.js

This file was deleted.

80 changes: 64 additions & 16 deletions public/js/toggle-paid.js → public/js/view-controls.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,20 @@
'use strict'

let show_paid = localStorage.getItem('show_paid');
let account_id = localStorage.getItem('account_id');

if (show_paid === null) {
if (show_paid === null)
{
show_paid = 'true';
}

let toggleVisibility = function() {
if (account_id === null)
{
account_id = '';
}

let togglePaidStatus = function()
{
if (show_paid === 'true') {
show_paid = 'false';
localStorage.setItem('show_paid', show_paid);
Expand All @@ -16,21 +24,48 @@
localStorage.setItem('show_paid', show_paid);
}

setItemVisibility(show_paid);
setVisibleItems(show_paid, account_id);
setToggleButtonText(show_paid);
}

const setItemVisibility = function(show_paid) {
document.querySelectorAll('a.budget-item[data-item-paid]').forEach(function (budget_item) {
if (show_paid === 'true') {
budget_item.style.display = 'block';
} else {
budget_item.style.display = 'none';
}
});
let toggleAccountId = function()
{
account_id = this.value;
localStorage.setItem('account_id', account_id);

setVisibleItems(show_paid, account_id);
}

const setVisibleItems = function(show_paid, account_id)
{
const items = document.querySelectorAll('a.budget-item');

if (account_id === '') {
items.forEach(function (budget_item) {
if (show_paid === 'false' && budget_item.dataset.itemPaid === 'true') {
budget_item.style.display = 'none';
} else {
budget_item.style.display = 'block';
}
});
} else {
items.forEach(function (budget_item) {

if (budget_item.dataset.itemAccount === account_id) {
if (show_paid === 'false' && budget_item.dataset.itemPaid === 'true') {
budget_item.style.display = 'none';
} else {
budget_item.style.display = 'block';
}
} else {
budget_item.style.display = 'none';
}
});
}
}

const setToggleButtonText = function(show_paid) {
const setToggleButtonText = function(show_paid)
{
let eye = '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-eye" viewBox="0 0 16 16">\n' +
'<path d="M16 8s-3-5.5-8-5.5S0 8 0 8s3 5.5 8 5.5S16 8 16 8zM1.173 8a13.133 13.133 0 0 1 1.66-2.043C4.12 4.668 5.88 3.5 8 3.5c2.12 0 3.879 1.168 5.168 2.457A13.133 13.133 0 0 1 14.828 8c-.058.087-.122.183-.195.288-.335.48-.83 1.12-1.465 1.755C11.879 11.332 10.119 12.5 8 12.5c-2.12 0-3.879-1.168-5.168-2.457A13.134 13.134 0 0 1 1.172 8z"/>\n' +
'<path d="M8 5.5a2.5 2.5 0 1 0 0 5 2.5 2.5 0 0 0 0-5zM4.5 8a3.5 3.5 0 1 1 7 0 3.5 3.5 0 0 1-7 0z"/>\n' +
Expand All @@ -49,10 +84,23 @@
}
}

const toggle_control = document.querySelector('button[name="toggle-paid"]');
if (toggle_control !== null) {
setItemVisibility(show_paid)
const setAccountFilterValue = function(account_id)
{
document.querySelector('select[name="account-filter"]').value = account_id;
}

const toggle_paid_status = document.querySelector('button[name="toggle-paid"]');
if (toggle_paid_status !== null)
{
setToggleButtonText(show_paid);
toggle_control.addEventListener('click', toggleVisibility)
setVisibleItems(show_paid, account_id);
toggle_paid_status.addEventListener('click', togglePaidStatus);
}
const account_filter = document.querySelector('select[name="account-filter"]');
if (account_filter !== null)
{
setAccountFilterValue(account_id);
setVisibleItems(show_paid, account_id);
account_filter.addEventListener('change', toggleAccountId);
}
})();
3 changes: 1 addition & 2 deletions resources/views/budget/account/create.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,6 @@
<script src="{{ asset('node_modules/bootstrap/dist/js/bootstrap.js') }}" defer></script>
<script src="{{ asset('js/auto-format-numbers.js') }}" defer></script>
<script src="{{ asset('js/filter-budget.js') }}" defer></script>
<script src="{{ asset('js/toggle-paid.js') }}" defer></script>
<script src="{{ asset('js/filter-budget-by-account.js') }}" defer></script>
<script src="{{ asset('js/view-controls.js') }}" defer></script>
</body>
</html>
3 changes: 1 addition & 2 deletions resources/views/budget/account/set-balances.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@
<script src="{{ asset('node_modules/bootstrap/dist/js/bootstrap.js') }}" defer></script>
<script src="{{ asset('js/auto-format-numbers.js') }}" defer></script>
<script src="{{ asset('js/filter-budget.js') }}" defer></script>
<script src="{{ asset('js/toggle-paid.js') }}" defer></script>
<script src="{{ asset('js/filter-budget-by-account.js') }}" defer></script>
<script src="{{ asset('js/view-controls.js') }}" defer></script>
</body>
</html>
3 changes: 1 addition & 2 deletions resources/views/budget/account/update.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,6 @@
<script src="{{ asset('node_modules/bootstrap/dist/js/bootstrap.js') }}" defer></script>
<script src="{{ asset('js/auto-format-numbers.js') }}" defer></script>
<script src="{{ asset('js/filter-budget.js') }}" defer></script>
<script src="{{ asset('js/toggle-paid.js') }}" defer></script>
<script src="{{ asset('js/filter-budget-by-account.js') }}" defer></script>
<script src="{{ asset('js/view-controls.js') }}" defer></script>
</body>
</html>
3 changes: 1 addition & 2 deletions resources/views/budget/item/confirm-delete.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,6 @@
</div>
<script src="{{ asset('node_modules/bootstrap/dist/js/bootstrap.js') }}" defer></script>
<script src="{{ asset('js/filter-budget.js') }}" defer></script>
<script src="{{ asset('js/toggle-paid.js') }}" defer></script>
<script src="{{ asset('js/filter-budget-by-account.js') }}" defer></script>
<script src="{{ asset('js/view-controls.js') }}" defer></script>
</body>
</html>
3 changes: 1 addition & 2 deletions resources/views/budget/item/confirm-disable.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,6 @@
</div>
<script src="{{ asset('node_modules/bootstrap/dist/js/bootstrap.js') }}" defer></script>
<script src="{{ asset('js/filter-budget.js') }}" defer></script>
<script src="{{ asset('js/toggle-paid.js') }}" defer></script>
<script src="{{ asset('js/filter-budget-by-account.js') }}" defer></script>
<script src="{{ asset('js/view-controls.js') }}" defer></script>
</body>
</html>
3 changes: 1 addition & 2 deletions resources/views/budget/item/confirm-enable.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,6 @@
</div>
<script src="{{ asset('node_modules/bootstrap/dist/js/bootstrap.js') }}" defer></script>
<script src="{{ asset('js/filter-budget.js') }}" defer></script>
<script src="{{ asset('js/toggle-paid.js') }}" defer></script>
<script src="{{ asset('js/filter-budget-by-account.js') }}" defer></script>
<script src="{{ asset('js/view-controls.js') }}" defer></script>
</body>
</html>
3 changes: 1 addition & 2 deletions resources/views/budget/item/create-expense.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,6 @@
<script src="{{ asset('js/create-budget-item.js') }}" defer></script>
<script src="{{ asset('js/auto-format-numbers.js') }}" defer></script>
<script src="{{ asset('js/filter-budget.js') }}" defer></script>
<script src="{{ asset('js/toggle-paid.js') }}" defer></script>
<script src="{{ asset('js/filter-budget-by-account.js') }}" defer></script>
<script src="{{ asset('js/view-controls.js') }}" defer></script>
</body>
</html>
3 changes: 1 addition & 2 deletions resources/views/budget/item/create-income.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,6 @@
<script src="{{ asset('js/create-budget-item.js') }}" defer></script>
<script src="{{ asset('js/auto-format-numbers.js') }}" defer></script>
<script src="{{ asset('js/filter-budget.js') }}" defer></script>
<script src="{{ asset('js/toggle-paid.js') }}" defer></script>
<script src="{{ asset('js/filter-budget-by-account.js') }}" defer></script>
<script src="{{ asset('js/view-controls.js') }}" defer></script>
</body>
</html>
3 changes: 1 addition & 2 deletions resources/views/budget/item/create-saving.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,6 @@
<script src="{{ asset('js/create-budget-item.js') }}" defer></script>
<script src="{{ asset('js/auto-format-numbers.js') }}" defer></script>
<script src="{{ asset('js/filter-budget.js') }}" defer></script>
<script src="{{ asset('js/toggle-paid.js') }}" defer></script>
<script src="{{ asset('js/filter-budget-by-account.js') }}" defer></script>
<script src="{{ asset('js/view-controls.js') }}" defer></script>
</body>
</html>
5 changes: 2 additions & 3 deletions resources/views/budget/item/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

<x-offcanvas active="home"/>

<div class="col-lg-8 col-xl-6 mx-auto p-3">
<div class="col-lg-10 col-xl-8 col-xxl-8 mx-auto p-3">

<div class="row">
<div class="col-12 col-lg-5 mx-auto p-2">
Expand Down Expand Up @@ -265,7 +265,6 @@
<script src="{{ asset('node_modules/bootstrap/dist/js/bootstrap.js') }}" defer></script>
<script src="{{ asset('js/auto-format-numbers.js') }}" defer></script>
<script src="{{ asset('js/filter-budget.js') }}" defer></script>
<script src="{{ asset('js/toggle-paid.js') }}" defer></script>
<script src="{{ asset('js/filter-budget-by-account.js') }}" defer></script>
<script src="{{ asset('js/view-controls.js') }}" defer></script>
</body>
</html>
3 changes: 1 addition & 2 deletions resources/views/budget/item/update.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,6 @@
<script src="{{ asset('js/create-budget-item.js') }}" defer></script>
<script src="{{ asset('js/auto-format-numbers.js') }}" defer></script>
<script src="{{ asset('js/filter-budget.js') }}" defer></script>
<script src="{{ asset('js/toggle-paid.js') }}" defer></script>
<script src="{{ asset('js/filter-budget-by-account.js') }}" defer></script>
<script src="{{ asset('js/view-controls.js') }}" defer></script>
</body>
</html>
2 changes: 1 addition & 1 deletion resources/views/components/budget.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
'item-month' => $__month->month(),
'month'=> $__month->month(),
'year'=> $__month->year()
]) }}" class="budget-item" data-item-account="{{ $__item->accountId() }}" data-item-name="{{ $__item->name() }}" @if($__month->now() === true && $__item->paid() === true) data-item-paid=true @endif>
]) }}" class="budget-item" data-item-account="{{ $__item->accountId() }}" data-item-name="{{ $__item->name() }}" @if($__month->now() === true && $__item->paid() === true) data-item-paid=true @else data-item-paid=false @endif>
<div class="col-12 expense @if ($active_item === $__item->id() && $__month->year() === $active_item_year && $__month->month() === $active_item_month) active shadow @endif" @if($__item->disabled() === true) title="Disabled expense" @endif>
<div class="name text-grey" title="{{ $__item->name() }}">
<p class="mb-1">
Expand Down
3 changes: 1 addition & 2 deletions resources/views/home.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@
</div>
<script src="{{ asset('node_modules/bootstrap/dist/js/bootstrap.js') }}" defer></script>
<script src="{{ asset('js/filter-budget.js') }}" defer></script>
<script src="{{ asset('js/toggle-paid.js') }}" defer></script>
<script src="{{ asset('js/filter-budget-by-account.js') }}" defer></script>
<script src="{{ asset('js/view-controls.js') }}" defer></script>
</body>
</html>

0 comments on commit ae24fb6

Please sign in to comment.