From 3daddd690f8dd6fd0194d3e0b59bbdb89dfa6341 Mon Sep 17 00:00:00 2001
From: James Cole
Date: Sat, 10 Aug 2019 16:50:37 +0200
Subject: [PATCH] Fix all views.
---
app/Providers/FireflyServiceProvider.php | 27 +++++++++++-
app/Support/Facades/AccountForm.php | 2 +-
app/Support/Facades/CurrencyForm.php | 44 +++++++++++++++++++
app/Support/Facades/ExpandedForm.php | 3 --
app/Support/Facades/PiggyBankForm.php | 44 +++++++++++++++++++
app/Support/Facades/RuleForm.php | 44 +++++++++++++++++++
app/Support/Form/CurrencyForm.php | 8 ++++
app/Support/Form/PiggyBankForm.php | 3 ++
config/app.php | 5 ++-
config/twigbridge.php | 27 +++++++++---
resources/views/v1/accounts/create.twig | 2 +-
resources/views/v1/accounts/edit.twig | 2 +-
resources/views/v1/bills/create.twig | 2 +-
resources/views/v1/bills/edit.twig | 2 +-
resources/views/v1/new-user/index.twig | 2 +-
resources/views/v1/recurring/create.twig | 6 +--
resources/views/v1/recurring/edit.twig | 6 +--
.../views/v1/rules/rule-group/delete.twig | 2 +-
resources/views/v1/rules/rule/create.twig | 2 +-
resources/views/v1/rules/rule/edit.twig | 2 +-
20 files changed, 207 insertions(+), 28 deletions(-)
create mode 100644 app/Support/Facades/CurrencyForm.php
create mode 100644 app/Support/Facades/PiggyBankForm.php
create mode 100644 app/Support/Facades/RuleForm.php
diff --git a/app/Providers/FireflyServiceProvider.php b/app/Providers/FireflyServiceProvider.php
index 4d6957ff89..2288539806 100644
--- a/app/Providers/FireflyServiceProvider.php
+++ b/app/Providers/FireflyServiceProvider.php
@@ -53,9 +53,12 @@ use FireflyIII\Services\IP\IPRetrievalInterface;
use FireflyIII\Services\Password\PwndVerifierV3;
use FireflyIII\Services\Password\Verifier;
use FireflyIII\Support\Amount;
-use FireflyIII\Support\ExpandedForm;
use FireflyIII\Support\FireflyConfig;
+use FireflyIII\Support\ExpandedForm;
use FireflyIII\Support\Form\AccountForm;
+use FireflyIII\Support\Form\CurrencyForm;
+use FireflyIII\Support\Form\PiggyBankForm;
+use FireflyIII\Support\Form\RuleForm;
use FireflyIII\Support\Navigation;
use FireflyIII\Support\Preferences;
use FireflyIII\Support\Steam;
@@ -143,7 +146,7 @@ class FireflyServiceProvider extends ServiceProvider
);
$this->app->bind(
'expandedform',
- function () {
+ static function () {
return new ExpandedForm;
}
);
@@ -154,6 +157,26 @@ class FireflyServiceProvider extends ServiceProvider
return new AccountForm;
}
);
+ $this->app->bind(
+ 'currencyform',
+ static function () {
+ return new CurrencyForm;
+ }
+ );
+
+ $this->app->bind(
+ 'piggybankform',
+ static function () {
+ return new PiggyBankForm;
+ }
+ );
+
+ $this->app->bind(
+ 'ruleform',
+ static function () {
+ return new RuleForm;
+ }
+ );
// chart generator:
$this->app->bind(GeneratorInterface::class, ChartJsGenerator::class);
diff --git a/app/Support/Facades/AccountForm.php b/app/Support/Facades/AccountForm.php
index 5e2328a42d..a9e8924286 100644
--- a/app/Support/Facades/AccountForm.php
+++ b/app/Support/Facades/AccountForm.php
@@ -27,7 +27,7 @@ use Illuminate\Support\Facades\Facade;
/**
* @codeCoverageIgnore
- * Class ExpandedForm.
+ * Class AccountForm.
*
*/
class AccountForm extends Facade
diff --git a/app/Support/Facades/CurrencyForm.php b/app/Support/Facades/CurrencyForm.php
new file mode 100644
index 0000000000..b2760568d7
--- /dev/null
+++ b/app/Support/Facades/CurrencyForm.php
@@ -0,0 +1,44 @@
+.
+ */
+declare(strict_types=1);
+
+namespace FireflyIII\Support\Facades;
+
+use Illuminate\Support\Collection;
+use Illuminate\Support\Facades\Facade;
+
+/**
+ * @codeCoverageIgnore
+ * Class CurrencyForm.
+ *
+ */
+class CurrencyForm extends Facade
+{
+ /**
+ * Get the registered name of the component.
+ *
+ * @return string
+ */
+ protected static function getFacadeAccessor(): string
+ {
+ return 'currencyform';
+ }
+}
diff --git a/app/Support/Facades/ExpandedForm.php b/app/Support/Facades/ExpandedForm.php
index 983373509d..d82ae7fd96 100644
--- a/app/Support/Facades/ExpandedForm.php
+++ b/app/Support/Facades/ExpandedForm.php
@@ -28,9 +28,6 @@ use Illuminate\Support\Facades\Facade;
/**
* @codeCoverageIgnore
* Class ExpandedForm.
- *
- * @method array makeSelectList(Collection $set)
- * @method array makeSelectListWithEmpty(Collection $set)
*/
class ExpandedForm extends Facade
{
diff --git a/app/Support/Facades/PiggyBankForm.php b/app/Support/Facades/PiggyBankForm.php
new file mode 100644
index 0000000000..a454b571dc
--- /dev/null
+++ b/app/Support/Facades/PiggyBankForm.php
@@ -0,0 +1,44 @@
+.
+ */
+declare(strict_types=1);
+
+namespace FireflyIII\Support\Facades;
+
+use Illuminate\Support\Collection;
+use Illuminate\Support\Facades\Facade;
+
+/**
+ * @codeCoverageIgnore
+ * Class PiggyBankForm.
+ *
+ */
+class PiggyBankForm extends Facade
+{
+ /**
+ * Get the registered name of the component.
+ *
+ * @return string
+ */
+ protected static function getFacadeAccessor(): string
+ {
+ return 'piggybankform';
+ }
+}
diff --git a/app/Support/Facades/RuleForm.php b/app/Support/Facades/RuleForm.php
new file mode 100644
index 0000000000..1df324e057
--- /dev/null
+++ b/app/Support/Facades/RuleForm.php
@@ -0,0 +1,44 @@
+.
+ */
+declare(strict_types=1);
+
+namespace FireflyIII\Support\Facades;
+
+use Illuminate\Support\Collection;
+use Illuminate\Support\Facades\Facade;
+
+/**
+ * @codeCoverageIgnore
+ * Class RuleForm.
+ *
+ */
+class RuleForm extends Facade
+{
+ /**
+ * Get the registered name of the component.
+ *
+ * @return string
+ */
+ protected static function getFacadeAccessor(): string
+ {
+ return 'ruleform';
+ }
+}
diff --git a/app/Support/Form/CurrencyForm.php b/app/Support/Form/CurrencyForm.php
index 6f16f4230c..8dac83b809 100644
--- a/app/Support/Form/CurrencyForm.php
+++ b/app/Support/Form/CurrencyForm.php
@@ -40,7 +40,9 @@ use Throwable;
class CurrencyForm
{
use FormSupport;
+
/**
+ * TODO cleanup and describe.
* @param string $name
* @param mixed $value
* @param array $options
@@ -64,6 +66,8 @@ class CurrencyForm
}
/**
+ * TODO cleanup and describe.
+ *
* @param string $name
* @param mixed $value
* @param array $options
@@ -90,6 +94,8 @@ class CurrencyForm
/**
+ * TODO describe and cleanup.
+ *
* @param string $name
* @param mixed $value
* @param array $options
@@ -103,6 +109,8 @@ class CurrencyForm
}
/**
+ * TODO cleanup and describe better.
+ *
* @param string $name
* @param string $view
* @param mixed $value
diff --git a/app/Support/Form/PiggyBankForm.php b/app/Support/Form/PiggyBankForm.php
index 38fae973a8..40bf878201 100644
--- a/app/Support/Form/PiggyBankForm.php
+++ b/app/Support/Form/PiggyBankForm.php
@@ -33,7 +33,10 @@ use FireflyIII\Repositories\PiggyBank\PiggyBankRepositoryInterface;
class PiggyBankForm
{
use FormSupport;
+
/**
+ * TODO cleanup and describe.
+ *
* @param string $name
* @param mixed $value
* @param array $options
diff --git a/config/app.php b/config/app.php
index 7941e75248..7d8097079a 100644
--- a/config/app.php
+++ b/config/app.php
@@ -100,8 +100,6 @@ return [
FireflyIII\Providers\AdminServiceProvider::class,
FireflyIII\Providers\RecurringServiceProvider::class,
ImportServiceProvider::class,
-
-
],
'aliases' => [
'App' => Illuminate\Support\Facades\App::class,
@@ -146,7 +144,10 @@ return [
'Amount' => \FireflyIII\Support\Facades\Amount::class,
'Steam' => \FireflyIII\Support\Facades\Steam::class,
'ExpandedForm' => \FireflyIII\Support\Facades\ExpandedForm::class,
+ 'CurrencyForm' => \FireflyIII\Support\Facades\CurrencyForm::class,
'AccountForm' => \FireflyIII\Support\Facades\AccountForm::class,
+ 'PiggyBankForm' => \FireflyIII\Support\Facades\PiggyBankForm::class,
+ 'RuleForm' => \FireflyIII\Support\Facades\RuleForm::class,
'Google2FA' => PragmaRX\Google2FALaravel\Facade::class,
],
diff --git a/config/twigbridge.php b/config/twigbridge.php
index 3b62450e26..8c1137f345 100644
--- a/config/twigbridge.php
+++ b/config/twigbridge.php
@@ -179,7 +179,7 @@ return [
|
*/
'facades' => [
- 'Breadcrumbs' => [
+ 'Breadcrumbs' => [
'is_safe' => [
'render',
],
@@ -193,22 +193,37 @@ return [
'Steam',
'Config',
'Request',
- 'Form' => ['is_safe' => ['input', 'select', 'checkbox', 'model', 'open', 'radio', 'textarea', 'file',],],
- 'ExpandedForm' => [
+ 'Form' => ['is_safe' => ['input', 'select', 'checkbox', 'model', 'open', 'radio', 'textarea', 'file',],],
+ 'ExpandedForm' => [
'is_safe' => [
'date', 'text', 'select', 'balance', 'optionsList', 'checkbox', 'amount', 'tags', 'integer', 'textarea', 'location', 'file', 'staticText',
- 'password', 'nonSelectableAmount', 'number', 'amountNoCurrency', 'currencyList', 'ruleGroupList',
- 'ruleGroupListWithEmpty', 'piggyBankList', 'currencyListEmpty', 'percentage', 'balanceAll',
+ 'password', 'nonSelectableAmount', 'number', 'amountNoCurrency', 'percentage',
],
],
- 'AccountForm' => [
+ 'AccountForm' => [
'is_safe' => [
'activeAssetAccountList', 'activeLongAccountList', 'activeWithdrawalDestinations', 'activeDepositDestinations',
'assetAccountCheckList', 'assetAccountList', 'longAccountList',
],
],
+ 'CurrencyForm' => [
+ 'is_safe' => [
+ 'currencyList', 'currencyListEmpty', 'balanceAll',
+ ],
+ ],
+ 'PiggyBankForm' =>
+ [
+ 'is_safe' => [
+ 'piggyBankList',
+ ],
+ ],
+ 'RuleForm' => [
+ 'is_safe' => [
+ 'ruleGroupList', 'ruleGroupListWithEmpty',
+ ],
+ ],
],
diff --git a/resources/views/v1/accounts/create.twig b/resources/views/v1/accounts/create.twig
index 7c24565854..d52a1f46f2 100644
--- a/resources/views/v1/accounts/create.twig
+++ b/resources/views/v1/accounts/create.twig
@@ -18,7 +18,7 @@
{{ ExpandedForm.text('name') }}
{% if objectType == 'asset' or objectType == 'liabilities' %}
- {{ ExpandedForm.currencyList('currency_id', null, {helpText:'account_default_currency'|_}) }}
+ {{ CurrencyForm.currencyList('currency_id', null, {helpText:'account_default_currency'|_}) }}
{% endif %}
{% if objectType == 'liabilities' %}
{{ ExpandedForm.select('liability_type_id', liabilityTypes) }}
diff --git a/resources/views/v1/accounts/edit.twig b/resources/views/v1/accounts/edit.twig
index 97f24244eb..2324f9de53 100644
--- a/resources/views/v1/accounts/edit.twig
+++ b/resources/views/v1/accounts/edit.twig
@@ -19,7 +19,7 @@
{{ ExpandedForm.text('name') }}
{% if account.accountType.type == 'Default account' or account.accountType.type == 'Asset account' or objectType == 'liabilities' %}
- {{ ExpandedForm.currencyList('currency_id', null, {helpText:'account_default_currency'|_}) }}
+ {{ CurrencyForm.currencyList('currency_id', null, {helpText:'account_default_currency'|_}) }}
{% endif %}
{% if objectType == 'liabilities' %}
diff --git a/resources/views/v1/bills/create.twig b/resources/views/v1/bills/create.twig
index 1ee25f1059..8d1e69ff90 100644
--- a/resources/views/v1/bills/create.twig
+++ b/resources/views/v1/bills/create.twig
@@ -17,7 +17,7 @@
{{ ExpandedForm.text('name') }}
- {{ ExpandedForm.currencyList('transaction_currency_id', defaultCurrency.id) }}
+ {{ CurrencyForm.currencyList('transaction_currency_id', defaultCurrency.id) }}
{{ ExpandedForm.amountNoCurrency('amount_min') }}
{{ ExpandedForm.amountNoCurrency('amount_max') }}
{{ ExpandedForm.date('date',phpdate('Y-m-d')) }}
diff --git a/resources/views/v1/bills/edit.twig b/resources/views/v1/bills/edit.twig
index e680c33125..509e26704c 100644
--- a/resources/views/v1/bills/edit.twig
+++ b/resources/views/v1/bills/edit.twig
@@ -18,7 +18,7 @@
{{ ExpandedForm.text('name') }}
- {{ ExpandedForm.currencyList('transaction_currency_id') }}
+ {{ CurrencyForm.currencyList('transaction_currency_id') }}
{{ ExpandedForm.amountNoCurrency('amount_min') }}
{{ ExpandedForm.amountNoCurrency('amount_max') }}
{{ ExpandedForm.date('date',bill.date.format('Y-m-d')) }}
diff --git a/resources/views/v1/new-user/index.twig b/resources/views/v1/new-user/index.twig
index a939818a4b..316bb7c5b5 100644
--- a/resources/views/v1/new-user/index.twig
+++ b/resources/views/v1/new-user/index.twig
@@ -24,7 +24,7 @@
{{ 'to_get_started'|_ }}
{{ ExpandedForm.text('bank_name') }}
- {{ ExpandedForm.balanceAll('bank_balance') }}
+ {{ CurrencyForm.balanceAll('bank_balance') }}
{{ 'currency_not_present'|_ }}
diff --git a/resources/views/v1/recurring/create.twig b/resources/views/v1/recurring/create.twig
index b666c8b025..9185a278ad 100644
--- a/resources/views/v1/recurring/create.twig
+++ b/resources/views/v1/recurring/create.twig
@@ -86,7 +86,7 @@
{{ ExpandedForm.text('transaction_description') }}
{# transaction information (mandatory) #}
- {{ ExpandedForm.currencyList('transaction_currency_id', defaultCurrency.id) }}
+ {{ CurrencyForm.currencyList('transaction_currency_id', defaultCurrency.id) }}
{{ ExpandedForm.amountNoCurrency('amount', []) }}
{# source account if withdrawal, or if transfer: #}
@@ -115,7 +115,7 @@
{# transaction information (optional) #}
- {{ ExpandedForm.currencyListEmpty('foreign_currency_id', 0) }}
+ {{ CurrencyForm.currencyListEmpty('foreign_currency_id', 0) }}
{{ ExpandedForm.amountNoCurrency('foreign_amount', []) }}
{# BUDGET ONLY WHEN CREATING A WITHDRAWAL #}
@@ -132,7 +132,7 @@
{{ ExpandedForm.text('tags') }}
{# RELATE THIS TRANSFER TO A PIGGY BANK #}
- {{ ExpandedForm.piggyBankList('piggy_bank_id',0) }}
+ {{ PiggyBankForm.piggyBankList('piggy_bank_id',0) }}
diff --git a/resources/views/v1/recurring/edit.twig b/resources/views/v1/recurring/edit.twig
index 05c81e9ecd..8090ba55ae 100644
--- a/resources/views/v1/recurring/edit.twig
+++ b/resources/views/v1/recurring/edit.twig
@@ -84,7 +84,7 @@
{# end of three buttons#}
{{ ExpandedForm.text('transaction_description', array.transactions[0].description) }}
{# transaction information (mandatory) #}
- {{ ExpandedForm.currencyList('transaction_currency_id', array.transactions[0].currency_id) }}
+ {{ CurrencyForm.currencyList('transaction_currency_id', array.transactions[0].currency_id) }}
{{ ExpandedForm.amountNoCurrency('amount', array.transactions[0].amount) }}
{# source account if withdrawal, or if transfer: #}
@@ -116,7 +116,7 @@
{# transaction information (optional) #}
- {{ ExpandedForm.currencyListEmpty('foreign_currency_id', array.transactions[0].foreign_currency_id) }}
+ {{ CurrencyForm.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 #}
@@ -155,7 +155,7 @@
{{ ExpandedForm.text('tags', tags) }}
{# RELATE THIS TRANSFER TO A PIGGY BANK #}
- {{ ExpandedForm.piggyBankList('piggy_bank_id',piggyBankId) }}
+ {{ PiggyBankForm.piggyBankList('piggy_bank_id',piggyBankId) }}
diff --git a/resources/views/v1/rules/rule-group/delete.twig b/resources/views/v1/rules/rule-group/delete.twig
index 4b5618bc9e..332cd444c1 100644
--- a/resources/views/v1/rules/rule-group/delete.twig
+++ b/resources/views/v1/rules/rule-group/delete.twig
@@ -35,7 +35,7 @@
- {{ ExpandedForm.ruleGroupListWithEmpty('move_rules_before_delete',null, {'hidden': ruleGroup.id}) }}
+ {{ RuleForm.ruleGroupListWithEmpty('move_rules_before_delete',null, {'hidden': ruleGroup.id}) }}
{% else %}
diff --git a/resources/views/v1/rules/rule/create.twig b/resources/views/v1/rules/rule/create.twig
index 18d3510993..8a9bc42327 100644
--- a/resources/views/v1/rules/rule/create.twig
+++ b/resources/views/v1/rules/rule/create.twig
@@ -38,7 +38,7 @@
{{ ExpandedForm.text('title') }}
{{ ExpandedForm.select('trigger',allJournalTriggers()) }}
- {{ ExpandedForm.ruleGroupList('rule_group_id', ruleGroup.id) }}
+ {{ RuleForm.ruleGroupList('rule_group_id', ruleGroup.id) }}
{{ ExpandedForm.checkbox('stop_processing',1,null, {helpText: trans('firefly.rule_help_stop_processing')}) }}
{{ ExpandedForm.checkbox('strict',1, null,{helpText: trans('firefly.rule_help_strict')}) }}
diff --git a/resources/views/v1/rules/rule/edit.twig b/resources/views/v1/rules/rule/edit.twig
index efe3182b87..31fe3dddfd 100644
--- a/resources/views/v1/rules/rule/edit.twig
+++ b/resources/views/v1/rules/rule/edit.twig
@@ -15,7 +15,7 @@
{{ ExpandedForm.text('title') }}
- {{ ExpandedForm.ruleGroupList('rule_group_id', ruleGroup.id) }}
+ {{ RuleForm.ruleGroupList('rule_group_id', ruleGroup.id) }}
{{ ExpandedForm.select('trigger',allJournalTriggers(), primaryTrigger) }}
{# only correct way to do active checkbox #}