Some cleanup.

This commit is contained in:
James Cole 2015-06-03 17:32:50 +02:00
parent d1d6c48d9b
commit 4b0b79199d
16 changed files with 172 additions and 39 deletions

View File

@ -2,6 +2,7 @@
use Carbon\Carbon;
use Config;
use FireflyIII\Models\TransactionJournal;
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use Input;
use Preferences;
@ -40,6 +41,16 @@ class HomeController extends Controller
{
Session::clear();
// encrypt transaction journal description
$set = TransactionJournal::where('encrypted', 0)->take(100)->get();
/** @var TransactionJournal $entry */
foreach ($set as $entry) {
$description = $entry->description;
$entry->description = $description;
$entry->save();
}
unset($set, $entry, $description);
return Redirect::route('index');
}

View File

@ -115,7 +115,7 @@ return [
*/
'Illuminate\Foundation\Providers\ArtisanServiceProvider',
'Illuminate\Auth\AuthServiceProvider',
'Illuminate\Bus\BusServiceProvider',
//'Illuminate\Bus\BusServiceProvider',
'Illuminate\Cache\CacheServiceProvider',
'Illuminate\Foundation\Providers\ConsoleSupportServiceProvider',
'Illuminate\Routing\ControllerServiceProvider',
@ -139,16 +139,16 @@ return [
'TwigBridge\ServiceProvider',
'DaveJamesMiller\Breadcrumbs\ServiceProvider',
// 'Barryvdh\Debugbar\ServiceProvider',
// 'Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider',
//'Barryvdh\Debugbar\ServiceProvider',
//'Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider',
'Zizaco\Entrust\EntrustServiceProvider',
/*
* Application Service Providers...
*/
'FireflyIII\Providers\AppServiceProvider',
'FireflyIII\Providers\BusServiceProvider',
'FireflyIII\Providers\ConfigServiceProvider',
//'FireflyIII\Providers\BusServiceProvider',
//'FireflyIII\Providers\ConfigServiceProvider',
'FireflyIII\Providers\EventServiceProvider',
'FireflyIII\Providers\RouteServiceProvider',
'FireflyIII\Providers\FireflyServiceProvider',

View File

@ -1,4 +1,4 @@
/* globals what, $ */
/* globals what:true, $, doSwitch, txt, middleCrumbName, title,button, middleCrumbUrl, piggiesLength, breadcrumbs */
$(document).ready(function () {
"use strict";
if ($('input[name="expense_account"]').length > 0) {
@ -38,4 +38,104 @@ $(document).ready(function () {
});
}
// respond to switch buttons:
if (doSwitch) {
updateButtons();
updateForm();
updateLayout();
}
});
function updateLayout() {
"use strict";
$('#subTitle').text(title[what]);
$('.breadcrumb .active').text(breadcrumbs[what]);
$('.breadcrumb li:nth-child(2)').html('<a href="' + middleCrumbUrl[what] + '">' + middleCrumbName[what] + '</a>');
$('#transaction-btn').html('<i class="fa fa-plus-circle"></i> ' + button[what]);
}
function updateForm() {
"use strict";
$('input[name="what"]').val(what);
switch (what) {
case 'withdrawal':
$('#account_id_holder').show();
$('#expense_account_holder').show();
$('#revenue_account_holder').hide();
$('#account_from_id_holder').hide();
$('#account_to_id_holder').hide();
$('#budget_id_holder').show();
$('#piggy_bank_id_holder').hide();
if ($('#ffInput_revenue_account').val().length > 0) {
$('#ffInput_expense_account').val($('#ffInput_revenue_account').val());
}
break;
case 'deposit':
$('#account_id_holder').show();
$('#expense_account_holder').hide();
$('#revenue_account_holder').show();
$('#account_from_id_holder').hide();
$('#account_to_id_holder').hide();
$('#budget_id_holder').hide();
$('#piggy_bank_id_holder').hide();
if ($('#ffInput_expense_account').val().length > 0) {
$('#ffInput_revenue_account').val($('#ffInput_expense_account').val());
}
break;
case 'transfer':
$('#account_id_holder').hide();
$('#expense_account_holder').hide();
$('#revenue_account_holder').hide();
$('#account_from_id_holder').show();
$('#account_to_id_holder').show();
$('#budget_id_holder').hide();
if (piggiesLength === 0) {
$('#piggy_bank_id_holder').hide();
} else {
$('#piggy_bank_id_holder').show();
}
break;
}
}
function updateButtons() {
"use strict";
$('.switch').each(function (i, v) {
var button = $(v);
// remove click event:
button.unbind('click');
// new click event:
button.bind('click', clickButton);
if (button.data('what') == what) {
button.removeClass('btn-default').addClass('btn-info').html('<i class="fa fa-fw fa-check"></i> ' + txt[button.data('what')]);
console.log('Now displaying form for ' + what);
} else {
button.removeClass('btn-info').addClass('btn-default').text(txt[button.data('what')]);
}
});
}
function clickButton(e) {
"use strict";
var button = $(e.target);
var newWhat = button.data('what');
if (newWhat != what) {
what = newWhat;
updateButtons();
updateForm();
updateLayout();
}
return false;
}

View File

@ -1,4 +1,4 @@
<div class="{{ classes }}">
<div class="{{ classes }}" id="{{ name}}_holder">
<label for="{{ options.id }}" class="col-sm-4 control-label">{{ label }}</label>
<div class="col-sm-8">
<div class="input-group">

View File

@ -1,4 +1,4 @@
<div class="{{ classes }}">
<div class="{{ classes }}" id="{{ name}}_holder">
<label for="{{ options.id }}" class="col-sm-4 control-label">{{ label }}</label>
<div class="col-sm-8">
<div class="input-group">

View File

@ -1,4 +1,4 @@
<div class="{{ classes }}">
<div class="{{ classes }}" id="{{ name}}_holder">
<label for="{{ options.id }}" class="col-sm-4 control-label">{{ label }}</label>
<div class="col-sm-8">
<div class="checkbox">

View File

@ -1,4 +1,4 @@
<div class="{{ classes }}">
<div class="{{ classes }}" id="{{ name}}_holder">
<label for="{{ options.id }}" class="col-sm-4 control-label">{{ label }}</label>
<div class="col-sm-8">
{{ Form.input('date', name, value, options) }}

View File

@ -1,4 +1,4 @@
<div class="{{ classes }}">
<div class="{{ classes }}" id="{{ name}}_holder">
<label for="{{ options.id }}" class="col-sm-4 control-label">{{ label }}</label>
<div class="col-sm-8">
<div class="input-group">

View File

@ -1,4 +1,4 @@
<div class="{{ classes }}">
<div class="{{ classes }}" id="{{ name}}_holder">
<label for="{{ options.id }}" class="col-sm-4 control-label">{{ label }}</label>
<div class="col-sm-8">
<div id="map-canvas" style="width:100%;height:300px;"></div>

View File

@ -1,4 +1,4 @@
<div class="{{ classes }}">
<div class="{{ classes }}" id="{{ name}}_holder">
<label for="{{ options.id }}" class="col-sm-4 control-label">{{ label }}</label>
<div class="col-sm-8">
{% for value,description in list %}

View File

@ -1,4 +1,4 @@
<div class="{{ classes }}">
<div class="{{ classes }}" id="{{ name}}_holder">
<label for="{{ options.id }}" class="col-sm-4 control-label">{{ label }}</label>
<div class="col-sm-8">
{{ Form.select(name, list, selected , options ) }}

View File

@ -1,4 +1,4 @@
<div class="{{ classes }}">
<div class="{{ classes }}" id="{{ name}}_holder">
<label for="{{ options.id }}" class="col-sm-4 control-label">{{ label }}</label>
<div class="col-sm-8">
{{ Form.input('text', name, value, options) }}

View File

@ -1,4 +1,4 @@
<div class="{{ classes }}">
<div class="{{ classes }}" id="{{ name}}_holder">
<label for="{{ options.id }}" class="col-sm-4 control-label">{{ label }}</label>
<div class="col-sm-8">
{{ Form.input('text', name, value, options) }}

View File

@ -1,4 +1,4 @@
<div class="{{ classes }}">
<div class="{{ classes }}" id="{{ name}}_holder">
<label for="{{ options.id }}" class="col-sm-4 control-label">{{ label }}</label>
<div class="col-sm-8">
{{ Form.textarea(name, value, options) }}

View File

@ -66,7 +66,7 @@
{{ title }}
{% if subTitle %}
<small>
<small id="subTitle">
{% if subTitleIcon %}
<i class="hidden-xs fa {{ subTitleIcon }}"></i>
{% endif %}

View File

@ -11,29 +11,35 @@
<i class="fa fa-exclamation-circle"></i> {{ 'mandatoryFields'|_ }}
</div>
<div class="panel-body">
<div class="form-group">
<label class="col-sm-4 control-label">Quickswitch</label>
<div class="col-sm-8">
<div class="btn-group btn-group-justified">
<a href="#" data-what="withdrawal" class="switch btn btn-default"> {{ 'withdrawal'|_ }}</a>
<a href="#" data-what="deposit" class="switch btn btn-default"> {{ 'deposit'|_ }}</a>
<a href="#" data-what="transfer" class="switch btn btn-default">{{ 'transfer'|_ }}</a>
</div>
</div>
</div>
<!-- DESCRIPTION ALWAYS AVAILABLE -->
{{ ExpandedForm.text('description') }}
{% if what == 'deposit' or what == 'withdrawal' %}
{{ ExpandedForm.select('account_id',accounts) }}
{% endif %}
<!-- ACCOUNT ONLY FOR DEPOSITS AND WITHDRAWALS -->
{{ ExpandedForm.select('account_id',accounts) }}
<!-- SHOW EXPENSE ACCOUNT ONLY FOR WITHDRAWALS -->
{% if what == 'withdrawal' %}
{{ ExpandedForm.text('expense_account') }}
{% endif %}
{{ ExpandedForm.text('expense_account') }}
<!-- SHOW REVENUE ACCOUNT ONLY FOR DEPOSITS -->
{% if what == 'deposit' %}
{{ ExpandedForm.text('revenue_account') }}
{% endif %}
{{ ExpandedForm.text('revenue_account') }}
<!-- ONLY SHOW FROM/TO ACCOUNT WHEN CREATING TRANSFER -->
{% if what == 'transfer' %}
{{ ExpandedForm.select('account_from_id',accounts) }}
{{ ExpandedForm.select('account_to_id',accounts) }}
{% endif %}
{{ ExpandedForm.select('account_from_id',accounts) }}
{{ ExpandedForm.select('account_to_id',accounts) }}
<!-- ALWAYS SHOW AMOUNT -->
@ -51,9 +57,7 @@
</div>
<div class="panel-body">
<!-- BUDGET ONLY WHEN CREATING A WITHDRAWAL -->
{% if what == 'withdrawal' %}
{{ ExpandedForm.select('budget_id',budgets,0) }}
{% endif %}
{{ ExpandedForm.select('budget_id',budgets,0) }}
<!-- CATEGORY ALWAYS -->
{{ ExpandedForm.text('category') }}
@ -62,9 +66,7 @@
<!-- RELATE THIS TRANSFER TO A PIGGY BANK -->
{% if what == 'withdrawal' and piggies|length > 0 %}
{{ ExpandedForm.select('piggy_bank_id',piggies) }}
{% endif %}
{{ ExpandedForm.select('piggy_bank_id',piggies) }}
</div>
</div>
@ -82,7 +84,7 @@
<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">
<button type="submit" id="transaction-btn" class="btn btn-lg btn-success">
<i class="fa fa-plus-circle"></i> {{ trans('form.store_new_'~what) }}
</button>
</p>
@ -94,6 +96,26 @@
{% block scripts %}
<script type="text/javascript">
var what = "{{ what }}";
var piggiesLength = {{ piggies|length }};
var doSwitch = true;
// some titles and names:
var txt = [];
var title = [];
var breadcrumbs = [];
var middleCrumbName = [];
var middleCrumbUrl = [];
var button = [];
{% for type in {0:'withdrawal',1:'deposit',2:'transfer'} %}
txt['{{ type }}'] = '{{ type|_ }}';
title['{{ type }}'] = '{{ trans('form.add_new_' ~ type) }}';
breadcrumbs['{{ type }}'] = '{{ trans('breadcrumbs.create_' ~ type) }}';
middleCrumbName['{{ type }}'] = '{{ trans('breadcrumbs.' ~ type ~ '_list') }}';
middleCrumbUrl['{{ type }}'] = '{{ route('transactions.index', type) }}';
button['{{ type }}'] = '{{ trans('form.store_new_' ~ type) }}';
{% endfor %}
</script>
<script type="text/javascript" src="js/bootstrap3-typeahead.min.js"></script>
<script type="text/javascript" src="js/bootstrap-tagsinput.min.js"></script>