mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-25 14:58:40 +00:00
Fix view issues when user has multiple pages of budgets #1111
This commit is contained in:
@@ -198,13 +198,13 @@ class BudgetController extends Controller
|
||||
$prev->subDay();
|
||||
$prev = app('navigation')->startOfPeriod($prev, $range);
|
||||
$this->repository->cleanupBudgets();
|
||||
$budgets = $this->repository->getActiveBudgets();
|
||||
$total = $budgets->count();
|
||||
$budgets = $budgets->slice(($page - 1) * $pageSize, $pageSize);
|
||||
$allBudgets = $this->repository->getActiveBudgets();
|
||||
$total = $allBudgets->count();
|
||||
$budgets = $allBudgets->slice(($page - 1) * $pageSize, $pageSize);
|
||||
$inactive = $this->repository->getInactiveBudgets();
|
||||
$periodStart = $start->formatLocalized($this->monthAndDayFormat);
|
||||
$periodEnd = $end->formatLocalized($this->monthAndDayFormat);
|
||||
$budgetInformation = $this->repository->collectBudgetInformation($budgets, $start, $end);
|
||||
$budgetInformation = $this->repository->collectBudgetInformation($allBudgets, $start, $end);
|
||||
$defaultCurrency = app('amount')->getDefaultCurrency();
|
||||
$available = $this->repository->getAvailableBudget($defaultCurrency, $start, $end);
|
||||
$spent = array_sum(array_column($budgetInformation, 'spent'));
|
||||
@@ -252,7 +252,7 @@ class BudgetController extends Controller
|
||||
'currentMonth',
|
||||
'next',
|
||||
'nextText',
|
||||
'prev',
|
||||
'prev', 'allBudgets',
|
||||
'prevText',
|
||||
'periodStart',
|
||||
'periodEnd',
|
||||
@@ -420,11 +420,12 @@ class BudgetController extends Controller
|
||||
$end = Carbon::createFromFormat('Y-m-d', $request->string('end'));
|
||||
$defaultCurrency = app('amount')->getDefaultCurrency();
|
||||
$amount = $request->get('amount');
|
||||
$page = $request->integer('page') === 0 ? 1 : $request->integer('page');
|
||||
|
||||
$this->repository->setAvailableBudget($defaultCurrency, $start, $end, $amount);
|
||||
Preferences::mark();
|
||||
|
||||
return redirect(route('budgets.index', [$start->format('Y-m-d')]));
|
||||
return redirect(route('budgets.index', [$start->format('Y-m-d')]) . '?page=' . $page);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -549,13 +550,14 @@ class BudgetController extends Controller
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
*/
|
||||
public function updateIncome(Carbon $start, Carbon $end)
|
||||
public function updateIncome(Request $request, Carbon $start, Carbon $end)
|
||||
{
|
||||
$defaultCurrency = app('amount')->getDefaultCurrency();
|
||||
$available = $this->repository->getAvailableBudget($defaultCurrency, $start, $end);
|
||||
$available = round($available, $defaultCurrency->decimal_places);
|
||||
$page = intval($request->get('page'));
|
||||
|
||||
return view('budgets.income', compact('available', 'start', 'end'));
|
||||
return view('budgets.income', compact('available', 'start', 'end', 'page'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
4
public/js/ff/budgets/index.js
vendored
4
public/js/ff/budgets/index.js
vendored
@@ -18,7 +18,7 @@
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/** global: infoIncomeUri, token, spent, budgeted, available, currencySymbol, budgetIndexUri, updateIncomeUri, periodStart, periodEnd, budgetAmountUri, accounting */
|
||||
/** global: infoIncomeUri, page, token, spent, budgeted, available, currencySymbol, budgetIndexUri, updateIncomeUri, periodStart, periodEnd, budgetAmountUri, accounting */
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@@ -44,7 +44,7 @@ $(function () {
|
||||
var sel = $(e.target).val();
|
||||
if (sel !== "x") {
|
||||
var newUri = budgetIndexUri.replace("REPLACE", sel);
|
||||
window.location.assign(newUri);
|
||||
window.location.assign(newUri + "?page=" + page);
|
||||
}
|
||||
});
|
||||
|
||||
|
@@ -14,6 +14,7 @@
|
||||
<input type="hidden" name="_token" value="{{ csrf_token() }}"/>
|
||||
<input type="hidden" name="start" value="{{ start.format('Y-m-d') }}"/>
|
||||
<input type="hidden" name="end" value="{{ end.format('Y-m-d') }}"/>
|
||||
<input type="hidden" name="page" value="{{ page }}" />
|
||||
|
||||
<div class="input-group">
|
||||
<div class="input-group-addon">{{ getCurrencySymbol()|raw }}</div>
|
||||
|
@@ -108,9 +108,9 @@
|
||||
</div>
|
||||
<div class="col-lg-8 col-md-4 col-sm-12 col-xs-12 text-center">
|
||||
<div class="btn btn-group btn-group-lg" style="padding-top:0;">
|
||||
<a href="{{ route('budgets.index', [prev.format('Y-m-d')]) }}" class="btn btn-default" title="{{ prevText }}">←</a>
|
||||
<a href="{{ route('budgets.index', [start.format('Y-m-d')]) }}" class="btn btn-default">{{ currentMonth }}</a>
|
||||
<a href="{{ route('budgets.index', [next.format('Y-m-d')]) }}" class="btn btn-default" title="{{ nextText }}">→</a>
|
||||
<a href="{{ route('budgets.index', [prev.format('Y-m-d')]) }}?page={{ page }}" class="btn btn-default" title="{{ prevText }}">←</a>
|
||||
<a href="{{ route('budgets.index', [start.format('Y-m-d')]) }}?page={{ page }}" class="btn btn-default">{{ currentMonth }}</a>
|
||||
<a href="{{ route('budgets.index', [next.format('Y-m-d')]) }}?page={{ page }}" class="btn btn-default" title="{{ nextText }}">→</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-2 col-md-4 col-sm-12 col-xs-12 text-right">
|
||||
@@ -237,13 +237,13 @@
|
||||
<script type="text/javascript">
|
||||
// actually spent bar data:
|
||||
var spent = {{ spent * -1 }}; // must be positive for the calculation to work.
|
||||
|
||||
var page = {{ page }};
|
||||
// budgeted data:
|
||||
var budgeted = {{ budgeted }};
|
||||
var available = {{ available }};
|
||||
var budgetIndexUri = "{{ route('budgets.index','REPLACE') }}";
|
||||
var budgetAmountUri = "{{ route('budgets.amount','REPLACE') }}";
|
||||
var updateIncomeUri = "{{ route('budgets.income',[start.format('Y-m-d'),end.format('Y-m-d')]) }}";
|
||||
var updateIncomeUri = "{{ route('budgets.income',[start.format('Y-m-d'),end.format('Y-m-d')]) }}?page={{ page }}";
|
||||
var infoIncomeUri = "{{ route('budgets.income.info',[start.format('Y-m-d'),end.format('Y-m-d')]) }}";
|
||||
var periodStart = "{{ start.format('Y-m-d') }}";
|
||||
var periodEnd = "{{ end.format('Y-m-d') }}";
|
||||
|
Reference in New Issue
Block a user