diff --git a/app/Providers/ConfigServiceProvider.php b/app/Providers/ConfigServiceProvider.php index 77dd2eef93..0af1c058c7 100644 --- a/app/Providers/ConfigServiceProvider.php +++ b/app/Providers/ConfigServiceProvider.php @@ -108,7 +108,7 @@ class ConfigServiceProvider extends ServiceProvider | `Twig_Extension_Debug` is enabled automatically if twig.debug is TRUE. | */ - 'enabled' => [ + 'enabled' => [ 'TwigBridge\Extension\Loader\Facades', 'TwigBridge\Extension\Loader\Filters', 'TwigBridge\Extension\Loader\Functions', @@ -122,7 +122,7 @@ class ConfigServiceProvider extends ServiceProvider 'TwigBridge\Extension\Laravel\Translator', 'TwigBridge\Extension\Laravel\Url', - // 'TwigBridge\Extension\Laravel\Form', + // 'TwigBridge\Extension\Laravel\Form', // 'TwigBridge\Extension\Laravel\Html', // 'TwigBridge\Extension\Laravel\Legacy\Facades', ], @@ -154,8 +154,8 @@ class ConfigServiceProvider extends ServiceProvider | in order to be marked as safe. | */ - 'facades' => [ - 'Breadcrumbs' => [ + 'facades' => [ + 'Breadcrumbs' => [ 'is_safe' => [ 'renderIfExists' ] @@ -163,7 +163,16 @@ class ConfigServiceProvider extends ServiceProvider 'Session', 'Route', 'Config', - 'ExpandedForm' + 'ExpandedForm' => [ + 'is_safe' => [ + 'date','text','select','balance','optionsList' + ] + ], + 'Form' => [ + 'is_safe' => [ + 'input','select','checkbox' + ] + ], ], /* @@ -195,10 +204,10 @@ class ConfigServiceProvider extends ServiceProvider | */ 'functions' => [ - 'elixir', - 'head', - 'last', - ], + 'elixir', + 'head', + 'last', + ], /* |-------------------------------------------------------------------------- diff --git a/app/Support/Twig/General.php b/app/Support/Twig/General.php index e80e327bdc..3f0410e7ab 100644 --- a/app/Support/Twig/General.php +++ b/app/Support/Twig/General.php @@ -71,6 +71,12 @@ class General extends Twig_Extension } ); + $functions[] = new Twig_SimpleFunction( + 'phpdate', function ($str) { + return date($str); + } + ); + $functions[] = new Twig_SimpleFunction( 'env', function ($name, $default) { diff --git a/resources/twig/accounts/create.twig b/resources/twig/accounts/create.twig index 9439400236..20da44b186 100644 --- a/resources/twig/accounts/create.twig +++ b/resources/twig/accounts/create.twig @@ -2,60 +2,60 @@ {% block content %} {{ Breadcrumbs.renderIfExists(Route.getCurrentRoute.getName, what) }}
+ -
-
-
-
- Mandatory fields +
+
+
+
+ Mandatory fields +
+
+ {{ ExpandedForm.text('name') }} +
+
-
- {{ ExpandedForm.text('name') }} -
-
-
-
+
- @if(what == 'asset') -
-
- Optional fields -
-
+ {% if what == 'asset' %} +
+
+ Optional fields +
+
- {{ ExpandedForm.balance('openingBalance') }} - {{ ExpandedForm.date('openingBalanceDate', date('Y-m-d')) }} - {{ ExpandedForm.select('accountRole',Config.get('firefly.accountRoles'), null, {'helpText' : 'Any extra options resulting from your choice can be set later.'}) }} - {{ ExpandedForm.balance('virtualBalance') }} + {{ ExpandedForm.balance('openingBalance') }} + {{ ExpandedForm.date('openingBalanceDate', phpdate('Y-m-d')) }} + {{ ExpandedForm.select('accountRole') }} + {{ ExpandedForm.balance('virtualBalance') }} + +
+
+ {% endif %} + + +
+
+ Options +
+
+ {{ ExpandedForm.optionsList('create','account') }} +
+
- @endif - - -
-
- Options -
-
- {{ ExpandedForm.optionsList('create','account') }} +
+
+

+ +

-
-
-
-
-

- -

-
-
- ---> {% endblock %} \ No newline at end of file diff --git a/resources/twig/form/balance.twig b/resources/twig/form/balance.twig new file mode 100644 index 0000000000..882db8e808 --- /dev/null +++ b/resources/twig/form/balance.twig @@ -0,0 +1,22 @@ +
+ +
+
+
+ + +
+ {{ Form.input('number', name, value, options) }} + +
+ {% include 'form/feedback.twig' %} +
+ + +
diff --git a/resources/twig/form/date.twig b/resources/twig/form/date.twig new file mode 100644 index 0000000000..33a300d057 --- /dev/null +++ b/resources/twig/form/date.twig @@ -0,0 +1,8 @@ +
+ +
+ {{ Form.input('date', name, value, options) }} + {% include 'form/help.twig' %} + {% include 'form/feedback.twig' %} +
+
diff --git a/resources/twig/form/feedback.twig b/resources/twig/form/feedback.twig new file mode 100644 index 0000000000..8cebea7222 --- /dev/null +++ b/resources/twig/form/feedback.twig @@ -0,0 +1,4 @@ +{% if errors.has(name) %} + +

{{ errors.first(name) }}

+{% endif %} diff --git a/resources/twig/form/help.twig b/resources/twig/form/help.twig new file mode 100644 index 0000000000..e1e2d011ea --- /dev/null +++ b/resources/twig/form/help.twig @@ -0,0 +1,3 @@ +{% if options.helpText %} +

{{ options.helpText }}

+{% endif %} diff --git a/resources/twig/form/options.twig b/resources/twig/form/options.twig new file mode 100644 index 0000000000..9af8428ba2 --- /dev/null +++ b/resources/twig/form/options.twig @@ -0,0 +1,30 @@ +{% if type == 'create' %} +
+ +
+
+ +
+
+
+{% endif %} + +{% if type == 'update' %} +
+ +
+
+
+
+
+{% endif %} \ No newline at end of file diff --git a/resources/twig/form/select.twig b/resources/twig/form/select.twig new file mode 100644 index 0000000000..6956207700 --- /dev/null +++ b/resources/twig/form/select.twig @@ -0,0 +1,9 @@ +
+ +
+ {{ Form.select(name, list, selected , options ) }} + {% include 'form/help.twig' %} + {% include 'form/feedback.twig' %} + +
+
diff --git a/resources/twig/form/text.twig b/resources/twig/form/text.twig new file mode 100644 index 0000000000..428b238b70 --- /dev/null +++ b/resources/twig/form/text.twig @@ -0,0 +1,7 @@ +
+ +
+ {{ Form.input('text', name, value, options) }} + {% include 'form/feedback.twig' %} +
+