mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +00:00
Various code to fix checkboxes.
This commit is contained in:
@@ -184,7 +184,9 @@ class AccountController extends Controller
|
||||
$currency = $default;
|
||||
}
|
||||
|
||||
$preFilled = [
|
||||
// code to handle active-checkboxes
|
||||
$hasOldInput = null !== $request->old('_token');
|
||||
$preFilled = [
|
||||
'accountNumber' => $repository->getMetaValue($account, 'accountNumber'),
|
||||
'accountRole' => $repository->getMetaValue($account, 'accountRole'),
|
||||
'ccType' => $repository->getMetaValue($account, 'ccType'),
|
||||
@@ -195,7 +197,7 @@ class AccountController extends Controller
|
||||
'virtualBalance' => $account->virtual_balance,
|
||||
'currency_id' => $currency->id,
|
||||
'notes' => '',
|
||||
'active' => $account->active,
|
||||
'active' => $hasOldInput ? (bool)$request->old('active') : $account->active,
|
||||
];
|
||||
/** @var Note $note */
|
||||
$note = $this->repository->getNote($account);
|
||||
@@ -203,7 +205,6 @@ class AccountController extends Controller
|
||||
$preFilled['notes'] = $note->text;
|
||||
}
|
||||
|
||||
|
||||
$request->session()->flash('preFilled', $preFilled);
|
||||
|
||||
return view('accounts.edit', compact('account', 'currency', 'subTitle', 'subTitleIcon', 'what', 'roles', 'preFilled'));
|
||||
|
@@ -161,10 +161,13 @@ class BillController extends Controller
|
||||
$bill->amount_max = round($bill->amount_max, $currency->decimal_places);
|
||||
$defaultCurrency = app('amount')->getDefaultCurrency();
|
||||
|
||||
// code to handle active-checkboxes
|
||||
$hasOldInput = null !== $request->old('_token');
|
||||
|
||||
$preFilled = [
|
||||
'notes' => $this->billRepository->getNoteText($bill),
|
||||
'transaction_currency_id' => $bill->transaction_currency_id,
|
||||
'active' => $bill->active,
|
||||
'active' => $hasOldInput ? (bool)$request->old('active') : $bill->active,
|
||||
];
|
||||
|
||||
$request->session()->flash('preFilled', $preFilled);
|
||||
|
@@ -216,11 +216,18 @@ class BudgetController extends Controller
|
||||
{
|
||||
$subTitle = trans('firefly.edit_budget', ['name' => $budget->name]);
|
||||
|
||||
// code to handle active-checkboxes
|
||||
$hasOldInput = null !== $request->old('_token');
|
||||
$preFilled = [
|
||||
'active' => $hasOldInput ? (bool)$request->old('active') : $budget->active,
|
||||
];
|
||||
|
||||
// put previous url in session if not redirect from store (not "return_to_edit").
|
||||
if (true !== session('budgets.edit.fromUpdate')) {
|
||||
$this->rememberPreviousUri('budgets.edit.uri');
|
||||
}
|
||||
$request->session()->forget('budgets.edit.fromUpdate');
|
||||
$request->session()->flash('preFilled', $preFilled);
|
||||
|
||||
return view('budgets.edit', compact('budget', 'subTitle'));
|
||||
}
|
||||
|
@@ -106,13 +106,17 @@ class EditController extends Controller
|
||||
$repetitionEnd = 'times';
|
||||
}
|
||||
|
||||
// flash some data:
|
||||
$preFilled = [
|
||||
// code to handle active-checkboxes
|
||||
$hasOldInput = null !== $request->old('_token');
|
||||
$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,
|
||||
|
||||
];
|
||||
$request->flash('preFilled', $preFilled);
|
||||
|
||||
return view('recurring.edit', compact('recurrence', 'array','budgets', 'preFilled', 'currentRepetitionType', 'repetitionEnd', 'repetitionEnds'));
|
||||
return view('recurring.edit', compact('recurrence', 'array', 'budgets', 'preFilled', 'currentRepetitionType', 'repetitionEnd', 'repetitionEnds'));
|
||||
}
|
||||
|
||||
|
||||
|
@@ -229,6 +229,14 @@ class RuleController extends Controller
|
||||
$actionCount = \count($oldActions);
|
||||
}
|
||||
|
||||
$hasOldInput = null !== $request->old('_token');
|
||||
$preFilled = [
|
||||
'active' => $hasOldInput ? (bool)$request->old('active') : $rule->active,
|
||||
'stop_processing' => $hasOldInput ? (bool)$request->old('stop_processing') : $rule->stop_processing,
|
||||
'strict' => $hasOldInput ? (bool)$request->old('strict') : $rule->strict,
|
||||
|
||||
];
|
||||
|
||||
// get rule trigger for update / store-journal:
|
||||
$primaryTrigger = $this->ruleRepos->getPrimaryTrigger($rule);
|
||||
$subTitle = trans('firefly.edit_rule', ['title' => $rule->title]);
|
||||
@@ -239,6 +247,8 @@ class RuleController extends Controller
|
||||
}
|
||||
session()->forget('rules.edit.fromUpdate');
|
||||
|
||||
$request->session()->flash('preFilled', $preFilled);
|
||||
|
||||
return view('rules.rule.edit', compact('rule', 'subTitle', 'primaryTrigger', 'oldTriggers', 'oldActions', 'triggerCount', 'actionCount'));
|
||||
}
|
||||
|
||||
|
@@ -121,16 +121,18 @@ class RuleGroupController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param RuleGroup $ruleGroup
|
||||
*
|
||||
* @return View
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
*/
|
||||
public function edit(RuleGroup $ruleGroup)
|
||||
public function edit(Request $request, RuleGroup $ruleGroup)
|
||||
{
|
||||
$subTitle = trans('firefly.edit_rule_group', ['title' => $ruleGroup->title]);
|
||||
|
||||
$preFilled = [
|
||||
'active' => $ruleGroup->active,
|
||||
$hasOldInput = null !== $request->old('_token');
|
||||
$preFilled = [
|
||||
'active' => $hasOldInput ? (bool)$request->old('active') : $ruleGroup->active,
|
||||
];
|
||||
|
||||
|
||||
|
@@ -151,7 +151,6 @@ class RecurrenceFormRequest extends Request
|
||||
'destination_account_name' => 'between:1,255|nullable',
|
||||
|
||||
// foreign amount data:
|
||||
'foreign_currency_id' => 'exists:transaction_currencies,id',
|
||||
'foreign_amount' => 'nullable|more:0',
|
||||
|
||||
// optional fields:
|
||||
@@ -159,6 +158,9 @@ class RecurrenceFormRequest extends Request
|
||||
'category' => 'between:1,255|nullable',
|
||||
'tags' => 'between:1,255|nullable',
|
||||
];
|
||||
if ($this->integer('foreign_currency_id') > 0) {
|
||||
$rules['foreign_currency_id'] = 'exists:transaction_currencies,id';
|
||||
}
|
||||
|
||||
// if ends after X repetitions, set another rule
|
||||
if ($this->string('repetition_end') === 'times') {
|
||||
|
@@ -42,6 +42,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
* @property string $name
|
||||
* @property string $iban
|
||||
* @property AccountType $accountType
|
||||
* @property bool $active
|
||||
*/
|
||||
class Account extends Model
|
||||
{
|
||||
|
@@ -33,6 +33,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
* Class Budget.
|
||||
* @property int $id
|
||||
* @property string $name
|
||||
* @property bool $active
|
||||
*/
|
||||
class Budget extends Model
|
||||
{
|
||||
|
@@ -33,6 +33,8 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
* @property bool $stop_processing
|
||||
* @property int $id
|
||||
* @property \Illuminate\Support\Collection $ruleTriggers
|
||||
* @property bool $active
|
||||
* @property bool $strict
|
||||
*/
|
||||
class Rule extends Model
|
||||
{
|
||||
|
@@ -247,6 +247,33 @@ class ExpandedForm
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @param null $value
|
||||
* @param array $options
|
||||
*
|
||||
* @return string
|
||||
* @throws \Throwable
|
||||
*/
|
||||
public function currencyListEmpty(string $name, $value = null, array $options = []): string
|
||||
{
|
||||
/** @var CurrencyRepositoryInterface $currencyRepos */
|
||||
$currencyRepos = app(CurrencyRepositoryInterface::class);
|
||||
|
||||
// get all currencies:
|
||||
$list = $currencyRepos->get();
|
||||
$array = [
|
||||
0 => trans('firefly.no_currency')
|
||||
];
|
||||
/** @var TransactionCurrency $currency */
|
||||
foreach ($list as $currency) {
|
||||
$array[$currency->id] = $currency->name . ' (' . $currency->symbol . ')';
|
||||
}
|
||||
$res = $this->select($name, $array, $value, $options);
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @param null $value
|
||||
|
@@ -189,7 +189,7 @@ return [
|
||||
'date', 'text', 'select', 'balance', 'optionsList', 'checkbox', 'amount', 'tags', 'integer', 'textarea', 'location',
|
||||
'multiRadio', 'file', 'multiCheckbox', 'staticText', 'amountSmall', 'password', 'nonSelectableBalance', 'nonSelectableAmount',
|
||||
'number', 'assetAccountList','amountNoCurrency','currencyList','ruleGroupList','assetAccountCheckList','ruleGroupListWithEmpty',
|
||||
'piggyBankList'
|
||||
'piggyBankList','currencyListEmpty'
|
||||
],
|
||||
],
|
||||
'Form' => [
|
||||
|
@@ -1230,6 +1230,7 @@ return [
|
||||
'create_new_recurrence' => 'Create new recurring transaction',
|
||||
'help_first_date' => 'Indicate the first expected recurrence. This must be in the future.',
|
||||
'help_first_date_no_past' => 'Indicate the first expected recurrence. Firefly III will not create transactions in the past.',
|
||||
'no_currency' => '(no currency)',
|
||||
'mandatory_for_recurring' => 'Mandatory recurrence information',
|
||||
'mandatory_for_transaction' => 'Mandatory transaction information',
|
||||
'optional_for_recurring' => 'Optional recurrence information',
|
||||
|
@@ -48,7 +48,9 @@
|
||||
|
||||
{% endif %}
|
||||
{{ ExpandedForm.textarea('notes',null,{helpText: trans('firefly.field_supports_markdown')}) }}
|
||||
{{ ExpandedForm.checkbox('active','1', preFilled.active) }}
|
||||
|
||||
{# only correct way to do active checkbox #}
|
||||
{{ ExpandedForm.checkbox('active', 1) }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
@@ -35,7 +35,8 @@
|
||||
{{ ExpandedForm.textarea('notes',null,{helpText: trans('firefly.field_supports_markdown')}) }}
|
||||
{{ ExpandedForm.file('attachments[]', {'multiple': 'multiple','helpText': trans('firefly.upload_max_file_size', {'size': uploadSize|filesize}) }) }}
|
||||
{{ ExpandedForm.integer('skip',0) }}
|
||||
{{ ExpandedForm.checkbox('active',1, true) }}
|
||||
{# only correct way to do active checkbox #}
|
||||
{{ ExpandedForm.checkbox('active', 1) }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
@@ -37,7 +37,8 @@
|
||||
{{ ExpandedForm.textarea('notes',null,{helpText: trans('firefly.field_supports_markdown')}) }}
|
||||
{{ ExpandedForm.file('attachments[]', {'multiple': 'multiple','helpText': trans('firefly.upload_max_file_size', {'size': uploadSize|filesize}) }) }}
|
||||
{{ ExpandedForm.integer('skip') }}
|
||||
{{ ExpandedForm.checkbox('active',1) }}
|
||||
{# only correct way to do active checkbox #}
|
||||
{{ ExpandedForm.checkbox('active', 1) }}
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
@@ -14,7 +14,8 @@
|
||||
<h3 class="box-title">{{ 'mandatoryFields'|_ }}</h3>
|
||||
</div>
|
||||
<div class="box-body">
|
||||
{{ ExpandedForm.checkbox('active') }}
|
||||
{# only correct way to do active checkbox #}
|
||||
{{ ExpandedForm.checkbox('active', 1) }}
|
||||
{{ ExpandedForm.text('name') }}
|
||||
</div>
|
||||
</div>
|
||||
|
@@ -47,7 +47,8 @@
|
||||
<div class="box-body">
|
||||
{{ ExpandedForm.textarea('recurring_description') }}
|
||||
|
||||
{{ ExpandedForm.checkbox('active',1) }}
|
||||
{# only correct way to do active checkbox #}
|
||||
{{ ExpandedForm.checkbox('active', 1) }}
|
||||
|
||||
{{ ExpandedForm.checkbox('apply_rules',1) }}
|
||||
</div>
|
||||
@@ -109,7 +110,7 @@
|
||||
</div>
|
||||
<div class="box-body">
|
||||
{# transaction information (optional) #}
|
||||
{{ ExpandedForm.currencyList('foreign_currency_id', defaultCurrency.id) }}
|
||||
{{ ExpandedForm.currencyListEmpty('foreign_currency_id', 0) }}
|
||||
{{ ExpandedForm.amountNoCurrency('foreign_amount', []) }}
|
||||
|
||||
{# BUDGET ONLY WHEN CREATING A WITHDRAWAL #}
|
||||
|
@@ -47,9 +47,10 @@
|
||||
<div class="box-body">
|
||||
{{ ExpandedForm.textarea('recurring_description',array.description) }}
|
||||
|
||||
{{ ExpandedForm.checkbox('active',1, array.active) }}
|
||||
{# only correct way to do active checkbox #}
|
||||
{{ ExpandedForm.checkbox('active', 1) }}
|
||||
|
||||
{{ ExpandedForm.checkbox('apply_rules',1, array.apply_rules) }}
|
||||
{{ ExpandedForm.checkbox('apply_rules',1) }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -108,7 +109,7 @@
|
||||
</div>
|
||||
<div class="box-body">
|
||||
{# transaction information (optional) #}
|
||||
{{ ExpandedForm.currencyList('foreign_currency_id', array.transactions[0].foreign_currency_id) }}
|
||||
{{ ExpandedForm.currencyListEmpty('foreign_currency_id', array.transactions[0].foreign_currency_id) }}
|
||||
{{ ExpandedForm.amountNoCurrency('foreign_amount', array.transactions[0].foreign_amount) }}
|
||||
|
||||
{# BUDGET ONLY WHEN CREATING A WITHDRAWAL #}
|
||||
|
@@ -14,7 +14,9 @@
|
||||
<h3 class="box-title">{{ 'mandatoryFields'|_ }}</h3>
|
||||
</div>
|
||||
<div class="box-body">
|
||||
{{ ExpandedForm.checkbox('active') }}
|
||||
{# only correct way to do active checkbox #}
|
||||
{{ ExpandedForm.checkbox('active', 1) }}
|
||||
|
||||
{{ ExpandedForm.text('title') }}
|
||||
</div>
|
||||
</div>
|
||||
|
@@ -17,7 +17,10 @@
|
||||
{{ ExpandedForm.text('title') }}
|
||||
{{ ExpandedForm.ruleGroupList('rule_group_id', ruleGroup.id) }}
|
||||
{{ ExpandedForm.select('trigger',allJournalTriggers(), primaryTrigger) }}
|
||||
{{ ExpandedForm.checkbox('active',1,rule.active, {helpText: trans('firefly.rule_help_active')}) }}
|
||||
|
||||
{# only correct way to do active checkbox #}
|
||||
{{ ExpandedForm.checkbox('active', 1, null, {helpText: trans('firefly.rule_help_active')}) }}
|
||||
|
||||
{{ ExpandedForm.checkbox('stop_processing',1,rule.stop_processing, {helpText: trans('firefly.rule_help_stop_processing')}) }}
|
||||
{{ ExpandedForm.checkbox('strict',1,rule.strict, {helpText: trans('firefly.rule_help_strict')}) }}
|
||||
</div>
|
||||
|
Reference in New Issue
Block a user