mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2024-12-25 16:31:15 -06:00
Edit works again
This commit is contained in:
parent
fdffed636f
commit
9bb2f1cfd3
@ -89,7 +89,7 @@ class CreateController extends Controller
|
||||
|
||||
$preFilled = [
|
||||
'auto_budget_period' => $hasOldInput ? (bool)$request->old('auto_budget_period') : 'monthly',
|
||||
'transaction_currency_id' => $hasOldInput ? (int)$request->old('transaction_currency_id') : $currency->id,
|
||||
'auto_budget_currency_id' => $hasOldInput ? (int)$request->old('auto_budget_currency_id') : $currency->id,
|
||||
];
|
||||
|
||||
$request->session()->flash('preFilled', $preFilled);
|
||||
|
@ -24,9 +24,9 @@ declare(strict_types=1);
|
||||
namespace FireflyIII\Http\Controllers\Budget;
|
||||
|
||||
|
||||
use FireflyIII\Models\AutoBudget;
|
||||
use FireflyIII\Http\Controllers\Controller;
|
||||
use FireflyIII\Http\Requests\BudgetFormUpdateRequest;
|
||||
use FireflyIII\Models\AutoBudget;
|
||||
use FireflyIII\Models\Budget;
|
||||
use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
@ -72,8 +72,9 @@ class EditController extends Controller
|
||||
{
|
||||
$subTitle = (string)trans('firefly.edit_budget', ['name' => $budget->name]);
|
||||
$autoBudget = $this->repository->getAutoBudget($budget);
|
||||
// auto budget options
|
||||
$autoBudgetOptions = [
|
||||
|
||||
// auto budget types
|
||||
$autoBudgetTypes = [
|
||||
0 => (string)trans('firefly.auto_budget_none'),
|
||||
AutoBudget::AUTO_BUDGET_RESET => (string)trans('firefly.auto_budget_reset'),
|
||||
AutoBudget::AUTO_BUDGET_ROLLOVER => (string)trans('firefly.auto_budget_rollover'),
|
||||
@ -89,15 +90,13 @@ class EditController extends Controller
|
||||
|
||||
// code to handle active-checkboxes
|
||||
$hasOldInput = null !== $request->old('_token');
|
||||
$currency = app('amount')->getDefaultCurrency();
|
||||
$preFilled = [
|
||||
'active' => $hasOldInput ? (bool)$request->old('active') : $budget->active,
|
||||
'active' => $hasOldInput ? (bool)$request->old('active') : $budget->active,
|
||||
'auto_budget_currency_id' => $hasOldInput ? (int)$request->old('auto_budget_currency_id') : $currency->id,
|
||||
];
|
||||
if($autoBudget) {
|
||||
$preFilled['auto_budget_amount'] = $hasOldInput ? $request->old('auto_budget_amount') : $autoBudget->amount;
|
||||
//'auto_budget_option' => $request->,
|
||||
//'transaction_currency_id' => 'required|exists:transaction_currencies,id',
|
||||
//'auto_budget_amount' => $request->old('auto_budget_amount'),
|
||||
//'auto_budget_period' => 'in:daily,weekly,monthly,quarterly,half_year,yearly',
|
||||
}
|
||||
|
||||
// put previous url in session if not redirect from store (not "return_to_edit").
|
||||
@ -107,7 +106,7 @@ class EditController extends Controller
|
||||
$request->session()->forget('budgets.edit.fromUpdate');
|
||||
$request->session()->flash('preFilled', $preFilled);
|
||||
|
||||
return view('budgets.edit', compact('budget', 'subTitle', 'autoBudgetOptions', 'autoBudgetPeriods', 'autoBudget'));
|
||||
return view('budgets.edit', compact('budget', 'subTitle', 'autoBudgetTypes', 'autoBudgetPeriods', 'autoBudget'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -51,8 +51,8 @@ class BudgetFormUpdateRequest extends Request
|
||||
return [
|
||||
'name' => $this->string('name'),
|
||||
'active' => $this->boolean('active'),
|
||||
'auto_budget_option' => $this->integer('auto_budget_option'),
|
||||
'transaction_currency_id' => $this->integer('transaction_currency_id'),
|
||||
'auto_budget_type' => $this->integer('auto_budget_type'),
|
||||
'transaction_currency_id' => $this->integer('auto_budget_currency_id'),
|
||||
'auto_budget_amount' => $this->string('auto_budget_amount'),
|
||||
'auto_budget_period' => $this->string('auto_budget_period'),
|
||||
];
|
||||
@ -78,7 +78,7 @@ class BudgetFormUpdateRequest extends Request
|
||||
'name' => $nameRule,
|
||||
'active' => 'numeric|between:0,1',
|
||||
'auto_budget_option' => 'numeric|between:0,2',
|
||||
'transaction_currency_id' => 'required|exists:transaction_currencies,id',
|
||||
'auto_budget_currency_id' => 'required|exists:transaction_currencies,id',
|
||||
'auto_budget_amount' => 'min:0|max:1000000000',
|
||||
'auto_budget_period' => 'in:daily,weekly,monthly,quarterly,half_year,yearly',
|
||||
];
|
||||
|
@ -348,7 +348,6 @@ class BudgetRepository implements BudgetRepositoryInterface
|
||||
if ('none' === $autoBudgetType) {
|
||||
$autoBudgetType = 0;
|
||||
}
|
||||
|
||||
if (0 !== $autoBudgetType) {
|
||||
$autoBudget = $this->getAutoBudget($budget);
|
||||
if (null === $autoBudget) {
|
||||
|
@ -28,8 +28,8 @@
|
||||
<h3 class="box-title">{{ 'optionalFields'|_ }}</h3>
|
||||
</div>
|
||||
<div class="box-body">
|
||||
{{ ExpandedForm.select('auto_budget_option', autoBudgetOptions, autoBudget.auto_budget_type) }}
|
||||
{{ CurrencyForm.currencyList('transaction_currency_id', autoBudget.transaction_currency_id) }}
|
||||
{{ ExpandedForm.select('auto_budget_type', autoBudgetTypes, autoBudget.auto_budget_type) }}
|
||||
{{ CurrencyForm.currencyList('auto_budget_currency_id', autoBudget.transaction_currency_id) }}
|
||||
{{ ExpandedForm.amountNoCurrency('auto_budget_amount', preFilled.auto_budget_amount) }}
|
||||
{{ ExpandedForm.select('auto_budget_period', autoBudgetPeriods, autoBudget.period) }}
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user