Skip to content

Firefly III: a personal finances manager

Can create accounts.

James Cole11baa968cdfa
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) }}
<form action="{{ route('accounts.store') }}" method="post" id="store" class="form-horizontal">
+ <input type="hidden" name="_token" value="{{ csrf_token() }}" />
<input type="hidden" name="what" value="{{ what }}" />
-<div class="row">
- <div class="col-lg-6 col-md-6 col-sm-12">
- <div class="panel panel-primary">
- <div class="panel-heading">
- <i class="fa {{ subTitleIcon }}"></i> Mandatory fields
+ <div class="row">
+ <div class="col-lg-6 col-md-6 col-sm-12">
+ <div class="panel panel-primary">
+ <div class="panel-heading">
+ <i class="fa {{ subTitleIcon }}"></i> Mandatory fields
+ </div>
+ <div class="panel-body">
+ {{ ExpandedForm.text('name') }}
+ </div>
+ </div>
</div>
- <div class="panel-body">
- {{ ExpandedForm.text('name') }}
- </div>
- </div>
- </div>
-
- <div class="col-lg-6 col-md-6 col-sm-12">
-
- @if(what == 'asset')
- <div class="panel panel-default">
- <div class="panel-heading">
- <i class="fa fa-smile-o"></i> Optional fields
- </div>
- <div class="panel-body">
- {{ 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') }}
+ <div class="col-lg-6 col-md-6 col-sm-12">
+
+ {% if what == 'asset' %}
+ <div class="panel panel-default">
+ <div class="panel-heading">
+ <i class="fa fa-smile-o"></i> Optional fields
+ </div>
+ <div class="panel-body">
+
+ {{ ExpandedForm.balance('openingBalance') }}
+ {{ ExpandedForm.date('openingBalanceDate', phpdate('Y-m-d')) }}
+ {{ ExpandedForm.select('accountRole') }}
+ {{ ExpandedForm.balance('virtualBalance') }}
+
+ </div>
+ </div>
+ {% endif %}
+
+ <!-- panel for options -->
+ <div class="panel panel-default">
+ <div class="panel-heading">
+ <i class="fa fa-bolt"></i> Options
+ </div>
+ <div class="panel-body">
+ {{ ExpandedForm.optionsList('create','account') }}
+ </div>
+ </div>
</div>
</div>
- @endif
-
- <!-- panel for options -->
- <div class="panel panel-default">
- <div class="panel-heading">
- <i class="fa fa-bolt"></i> Options
- </div>
- <div class="panel-body">
- {{ ExpandedForm.optionsList('create','account') }}
+ <div class="row">
+ <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
+ <p>
+ <button type="submit" class="btn btn-lg btn-success">
+ <i class="fa fa-plus-circle"></i> Store new {{ what }} account
+ </button>
+ </p>
</div>
</div>
- </div>
-</div>
-<div class="row">
- <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
- <p>
- <button type="submit" class="btn btn-lg btn-success">
- <i class="fa fa-plus-circle"></i> Store new {{ what }} account
- </button>
- </p>
- </div>
-</div>
-
</form>
--->
{% 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 @@
+<div class="{{ classes }}">
+ <label for="{{ options.id }}" class="col-sm-4 control-label">{{ label }}</label>
+ <div class="col-sm-8">
+ <div class="input-group">
+ <div class="input-group-btn">
+ <button type="button" class="btn btn-default dropdown-toggle balanceCurrencyDropdown" data-toggle="dropdown" aria-expanded="false">
+ <span id="balanceCurrentSymbol">{{ defaultCurrency.symbol|raw }}</span> <span class="caret"></span>
+ </button>
+ <ul class="dropdown-menu" role="menu">
+ {% for currency in currencies %}
+ <li><a href="#" class="currencySelect" data-id="{{ currency.id }}" data-field="balance" data-currency="{{ currency.code }}" data-symbol="{{ currency.symbol }}">{{ currency.name }}</a></li>
+ {% endfor %}
+ </ul>
+ </div>
+ {{ Form.input('number', name, value, options) }}
+
+ </div>
+ {% include 'form/feedback.twig' %}
+ </div>
+
+ <input type="hidden" name="balance_currency_id" value="{{ defaultCurrency.id }}" />
+</div>
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 @@
+<div class="{{ classes }}">
+ <label for="{{ options.id }}" class="col-sm-4 control-label">{{ label }}</label>
+ <div class="col-sm-8">
+ {{ Form.input('date', name, value, options) }}
+ {% include 'form/help.twig' %}
+ {% include 'form/feedback.twig' %}
+ </div>
+</div>
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) %}
+ <span class="form-control-feedback"><i class="fa fa-fw fa-remove"></i></span>
+ <p class="text-danger">{{ errors.first(name) }}</p>
+{% 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 %}
+ <p class="help-block">{{ options.helpText }}</p>
+{% 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' %}
+ <div class="form-group">
+ <label for="{{ name }}_return_to_form" class="col-sm-4 control-label">
+ Return here
+ </label>
+ <div class="col-sm-8">
+ <div class="radio">
+ <label>
+ {{ Form.checkbox('create_another', '1') }}
+ After storing, return here to create another one.
+ </label>
+ </div>
+ </div>
+ </div>
+{% endif %}
+
+{% if type == 'update' %}
+ <div class="form-group">
+ <label for="{{ name }}_return_to_edit" class="col-sm-4 control-label">
+ Return here
+ </label>
+ <div class="col-sm-8">
+ <div class="radio"><label>
+ {{ Form.checkbox('return_to_edit', '1', Input.old('return_to_edit') == '1') }}
+ After updating, return here.
+ </label>
+ </div>
+ </div>
+ </div>
+{% 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 @@
+<div class="{{ classes }}">
+ <label for="{{ options.id }}" class="col-sm-4 control-label">{{ label }}</label>
+ <div class="col-sm-8">
+ {{ Form.select(name, list, selected , options ) }}
+ {% include 'form/help.twig' %}
+ {% include 'form/feedback.twig' %}
+
+ </div>
+</div>
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 @@
+<div class="{{ classes }}">
+ <label for="{{ options.id }}" class="col-sm-4 control-label">{{ label }}</label>
+ <div class="col-sm-8">
+ {{ Form.input('text', name, value, options) }}
+ {% include 'form/feedback.twig' %}
+ </div>
+</div>