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