mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-17 09:51:40 +00:00
Code cleanup.
This commit is contained in:
@@ -68,31 +68,29 @@ class EditController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* todo move to repository
|
||||
* todo handle old repetition type as well.
|
||||
*
|
||||
* @param Request $request
|
||||
* @param Recurrence $recurrence
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
* @throws \FireflyIII\Exceptions\FireflyException
|
||||
*
|
||||
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
|
||||
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
|
||||
*/
|
||||
public function edit(Request $request, Recurrence $recurrence)
|
||||
{
|
||||
|
||||
|
||||
// use transformer:
|
||||
$transformer = new RecurrenceTransformer(new ParameterBag);
|
||||
$array = $transformer->transform($recurrence);
|
||||
$budgets = app('expandedform')->makeSelectListWithEmpty($this->budgets->getActiveBudgets());
|
||||
|
||||
// get recurrence type:
|
||||
// todo move to repository
|
||||
// todo handle old repetition type as well.
|
||||
|
||||
|
||||
/** @var RecurrenceRepetition $repetition */
|
||||
$repetition = $recurrence->recurrenceRepetitions()->first();
|
||||
$currentRepetitionType = $repetition->repetition_type;
|
||||
$currentRepType = $repetition->repetition_type;
|
||||
if ('' !== $repetition->repetition_moment) {
|
||||
$currentRepetitionType .= ',' . $repetition->repetition_moment;
|
||||
$currentRepType .= ',' . $repetition->repetition_moment;
|
||||
}
|
||||
|
||||
// put previous url in session if not redirect from store (not "return_to_edit").
|
||||
@@ -101,9 +99,7 @@ class EditController extends Controller
|
||||
}
|
||||
$request->session()->forget('recurrences.edit.fromUpdate');
|
||||
|
||||
// assume repeats forever:
|
||||
$repetitionEnd = 'forever';
|
||||
// types of repetitions:
|
||||
$repetitionEnd = 'forever';
|
||||
$repetitionEnds = [
|
||||
'forever' => (string)trans('firefly.repeat_forever'),
|
||||
'until_date' => (string)trans('firefly.repeat_until_date'),
|
||||
@@ -116,7 +112,6 @@ class EditController extends Controller
|
||||
$repetitionEnd = 'times';
|
||||
}
|
||||
|
||||
// what to do in the weekend?
|
||||
$weekendResponses = [
|
||||
RecurrenceRepetition::WEEKEND_DO_NOTHING => (string)trans('firefly.do_nothing'),
|
||||
RecurrenceRepetition::WEEKEND_SKIP_CREATION => (string)trans('firefly.skip_transaction'),
|
||||
@@ -124,10 +119,8 @@ class EditController extends Controller
|
||||
RecurrenceRepetition::WEEKEND_TO_MONDAY => (string)trans('firefly.jump_to_monday'),
|
||||
];
|
||||
|
||||
// code to handle active-checkboxes
|
||||
$hasOldInput = null !== $request->old('_token');
|
||||
// $hasOldInput = false;
|
||||
$preFilled = [
|
||||
$preFilled = [
|
||||
'transaction_type' => strtolower($recurrence->transactionType->type),
|
||||
'active' => $hasOldInput ? (bool)$request->old('active') : $recurrence->active,
|
||||
'apply_rules' => $hasOldInput ? (bool)$request->old('apply_rules') : $recurrence->apply_rules,
|
||||
@@ -135,7 +128,7 @@ class EditController extends Controller
|
||||
|
||||
return view(
|
||||
'recurring.edit',
|
||||
compact('recurrence', 'array', 'weekendResponses', 'budgets', 'preFilled', 'currentRepetitionType', 'repetitionEnd', 'repetitionEnds')
|
||||
compact('recurrence', 'array', 'weekendResponses', 'budgets', 'preFilled', 'currentRepType', 'repetitionEnd', 'repetitionEnds')
|
||||
);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user