Lots of cleanup and stuff.

This commit is contained in:
James Cole 2015-06-06 23:09:12 +02:00
parent 1a1f127993
commit 40b3097374
61 changed files with 361 additions and 323 deletions

View File

@ -80,15 +80,15 @@ class TransactionController extends Controller
*/ */
public function delete(TransactionJournal $journal) public function delete(TransactionJournal $journal)
{ {
$type = strtolower($journal->transactionType->type); $what = strtolower($journal->transactionType->type);
$subTitle = trans('firefly.delete_' . $type, ['description' => $journal->description]); $subTitle = trans('firefly.delete_' . $what, ['description' => $journal->description]);
// put previous url in session // put previous url in session
Session::put('transactions.delete.url', URL::previous()); Session::put('transactions.delete.url', URL::previous());
Session::flash('gaEventCategory', 'transactions'); Session::flash('gaEventCategory', 'transactions');
Session::flash('gaEventAction', 'delete-' . $type); Session::flash('gaEventAction', 'delete-' . $what);
return view('transactions.delete', compact('journal', 'subTitle')); return view('transactions.delete', compact('journal', 'subTitle','what'));
} }
@ -258,9 +258,10 @@ class TransactionController extends Controller
$t->after = $t->before + $t->amount; $t->after = $t->before + $t->amount;
} }
); );
$what = strtolower($journal->transactionType->type);
$subTitle = trans('firefly.' . $journal->transactionType->type) . ' "' . e($journal->description) . '"'; $subTitle = trans('firefly.' . $journal->transactionType->type) . ' "' . e($journal->description) . '"';
return view('transactions.show', compact('journal', 'subTitle')); return view('transactions.show', compact('journal', 'subTitle','what'));
} }
/** /**

View File

@ -56,7 +56,6 @@ class Bill extends Model
protected $hidden = ['amount_min_encrypted', 'amount_max_encrypted', 'name_encrypted', 'match_encrypted']; protected $hidden = ['amount_min_encrypted', 'amount_max_encrypted', 'name_encrypted', 'match_encrypted'];
/** /**
* @return array * @return array
*/ */

View File

@ -7,7 +7,6 @@ use Illuminate\Database\Eloquent\Builder as EloquentBuilder;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany; use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\SoftDeletes; use Illuminate\Database\Eloquent\SoftDeletes;
use Log;
use Watson\Validating\ValidatingTrait; use Watson\Validating\ValidatingTrait;
/** /**

View File

@ -7,8 +7,9 @@ use Carbon\Carbon;
use Crypt; use Crypt;
use FireflyIII\Models\Category; use FireflyIII\Models\Category;
use FireflyIII\Models\TransactionJournal; use FireflyIII\Models\TransactionJournal;
use Illuminate\Support\Collection;
use FireflyIII\Repositories\Shared\ComponentRepository; use FireflyIII\Repositories\Shared\ComponentRepository;
use Illuminate\Support\Collection;
/** /**
* Class CategoryRepository * Class CategoryRepository
* *

View File

@ -204,6 +204,7 @@ class TagRepository implements TagRepositoryInterface
return false; return false;
} }
} }
return true; return true;
} }
@ -289,6 +290,7 @@ class TagRepository implements TagRepositoryInterface
// tag is attached just like that: // tag is attached just like that:
if ($withdrawals < 1 && $deposits < 1) { if ($withdrawals < 1 && $deposits < 1) {
$journal->tags()->save($tag); $journal->tags()->save($tag);
return true; return true;
} }

View File

@ -9,7 +9,6 @@ use Carbon\Carbon;
use Illuminate\Database\Eloquent\Collection as EloquentCollection; use Illuminate\Database\Eloquent\Collection as EloquentCollection;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
use Preferences as Prefs; use Preferences as Prefs;
use Log;
/** /**
* Class CacheProperties * Class CacheProperties

View File

@ -41,7 +41,7 @@ class Navigation
'6M' => 6, '6M' => 6,
'half-year' => 6, 'half-year' => 6,
]; ];
$specialMap = ['1M', 'month', 'monthly'];
if (!isset($functionMap[$repeatFreq])) { if (!isset($functionMap[$repeatFreq])) {
throw new FireflyException('Cannot do addPeriod for $repeat_freq "' . $repeatFreq . '"'); throw new FireflyException('Cannot do addPeriod for $repeat_freq "' . $repeatFreq . '"');
} }

View File

@ -49,7 +49,10 @@ class General extends Twig_Extension
$this->getCurrencySymbol(), $this->getCurrencySymbol(),
$this->phpdate(), $this->phpdate(),
$this->env(), $this->env(),
$this->activeRoute()
$this->activeRouteStrict(),
$this->activeRoutePartial(),
$this->activeRoutePartialWhat(),
]; ];
} }
@ -188,31 +191,65 @@ class General extends Twig_Extension
} }
/** /**
* Will return "active" when the current route matches the given argument
* exactly.
*
* @return Twig_SimpleFunction * @return Twig_SimpleFunction
*/ */
protected function activeRoute() protected function activeRouteStrict()
{ {
return new Twig_SimpleFunction( return new Twig_SimpleFunction(
'activeRoute', function ($context) { 'activeRouteStrict', function () {
$args = func_get_args(); $args = func_get_args();
$route = $args[1]; $route = $args[0]; // name of the route.
$what = isset($args[2]) ? $args[2] : false;
$strict = isset($args[3]) ? $args[3] : false;
$activeWhat = isset($context['what']) ? $context['what'] : false;
// activeRoute if (Route::getCurrentRoute()->getName() == $route) {
if (!($what === false)) {
if ($what == $activeWhat && Route::getCurrentRoute()->getName() == $route) {
return 'active because-active-what';
}
} else {
if (!$strict && !(strpos(Route::getCurrentRoute()->getName(), $route) === false)) {
return 'active because-route-matches-non-strict';
} else {
if ($strict && Route::getCurrentRoute()->getName() == $route) {
return 'active because-route-matches-strict'; return 'active because-route-matches-strict';
} }
return 'not-xxx-at-all';
} }
);
}
/**
* Will return "active" when a part of the route matches the argument.
* ie. "accounts" will match "accounts.index".
*
* @return Twig_SimpleFunction
*/
protected function activeRoutePartial()
{
return new Twig_SimpleFunction(
'activeRoutePartial', function () {
$args = func_get_args();
$route = $args[0]; // name of the route.
if (!(strpos(Route::getCurrentRoute()->getName(), $route) === false)) {
return 'active because-route-matches-non-strict';
}
return 'not-xxx-at-all';
}
);
}
/**
* This function will return "active" when the current route matches the first argument (even partly)
* but, the variable $what has been set and matches the second argument.
*
* @return Twig_SimpleFunction
*/
protected function activeRoutePartialWhat()
{
return new Twig_SimpleFunction(
'activeRoutePartialWhat', function ($context) {
$args = func_get_args();
$route = $args[1]; // name of the route.
$what = $args[2]; // name of the route.
$activeWhat = isset($context['what']) ? $context['what'] : false;
if ($what == $activeWhat && !(strpos(Route::getCurrentRoute()->getName(), $route) === false)) {
return 'active because-route-matches-non-strict-what';
} }
return 'not-xxx-at-all'; return 'not-xxx-at-all';

View File

@ -89,83 +89,83 @@
<!-- /input-group --> <!-- /input-group -->
</li> </li>
<li> <li>
<a class="{{ activeRoute('index',null,true) }}" href="{{ route('index') }}"><i class="fa fa-dashboard fa-fw"></i> {{ 'dashboard'|_ }}</a> <a class="{{ activeRouteStrict('index') }}" href="{{ route('index') }}"><i class="fa fa-dashboard fa-fw"></i> {{ 'dashboard'|_ }}</a>
</li> </li>
<li class="{{ activeRoute('accounts.index') }}"> <li class="{{ activeRoutePartial('accounts') }}">
<a href="#"><i class="fa fa-credit-card fa-fw"></i> {{ 'accounts'|_ }} <span class="fa arrow"></span></a> <a href="#"><i class="fa fa-credit-card fa-fw"></i> {{ 'accounts'|_ }} <span class="fa arrow"></span></a>
<ul class="nav nav-second-level"> <ul class="nav nav-second-level">
<li> <li>
<a class="{{ activeRoute('accounts.index', 'asset') }}" href="{{ route('accounts.index','asset') }}"> <a class="{{ activeRoutePartialWhat('accounts', 'asset') }}" href="{{ route('accounts.index','asset') }}">
<i class="fa fa-money fa-fw"></i> {{ 'assetAccounts'|_ }}</a> <i class="fa fa-money fa-fw"></i> {{ 'assetAccounts'|_ }}</a>
</li> </li>
<li> <li>
<a class="{{ activeRoute('accounts.index', 'expense') }}" href="{{ route('accounts.index','expense') }}"> <a class="{{ activeRoutePartialWhat('accounts', 'expense') }}" href="{{ route('accounts.index','expense') }}">
<i class="fa fa-shopping-cart fa-fw"></i> {{ 'expenseAccounts'|_ }}</a> <i class="fa fa-shopping-cart fa-fw"></i> {{ 'expenseAccounts'|_ }}</a>
</li> </li>
<li> <li>
<a class="{{ activeRoute('accounts.index', 'revenue') }}" href="{{ route('accounts.index','revenue') }}"> <a class="{{ activeRoutePartialWhat('accounts', 'revenue') }}" href="{{ route('accounts.index','revenue') }}">
<i class="fa fa-download fa-fw"></i> {{ 'revenueAccounts'|_ }}</a> <i class="fa fa-download fa-fw"></i> {{ 'revenueAccounts'|_ }}</a>
</li> </li>
</ul> </ul>
<!-- /.nav-second-level --> <!-- /.nav-second-level -->
</li> </li>
<li> <li>
<a class="{{ activeRoute('budgets') }}" href="{{ route('budgets.index') }}"><i class="fa fa-tasks fa-fw"></i> {{ 'budgets'|_ }}</a> <a class="{{ activeRoutePartial('budgets') }}" href="{{ route('budgets.index') }}"><i class="fa fa-tasks fa-fw"></i> {{ 'budgets'|_ }}</a>
</li> </li>
<li> <li>
<a class="{{ activeRoute('categories') }}" href="{{ route('categories.index') }}"><i class="fa fa-bar-chart fa-fw"></i> {{ 'categories'|_ }}</a> <a class="{{ activeRoutePartial('categories') }}" href="{{ route('categories.index') }}"><i class="fa fa-bar-chart fa-fw"></i> {{ 'categories'|_ }}</a>
</li> </li>
<li> <li>
<a class="{{ activeRoute('tags') }}" href="{{ route('tags.index') }}"><i class="fa fa-tags fa-fw"></i> {{ 'tags'|_ }}</a> <a class="{{ activeRoutePartial('tags') }}" href="{{ route('tags.index') }}"><i class="fa fa-tags fa-fw"></i> {{ 'tags'|_ }}</a>
</li> </li>
<li> <li>
<a class="{{ activeRoute('reports') }}" href="{{ route('reports.index') }}"><i class="fa fa-line-chart fa-fw"></i> {{ 'reports'|_ }}</a> <a class="{{ activeRoutePartial('reports') }}" href="{{ route('reports.index') }}"><i class="fa fa-line-chart fa-fw"></i> {{ 'reports'|_ }}</a>
</li> </li>
<li class="{{ activeRoute('transactions') }}"> <li class="{{ activeRoutePartial('transactions') }}">
<a href="#"><i class="fa fa-repeat fa-fw"></i> {{ 'transactions'|_ }}<span class="fa arrow"></span></a> <a href="#"><i class="fa fa-repeat fa-fw"></i> {{ 'transactions'|_ }}<span class="fa arrow"></span></a>
<ul class="nav nav-second-level"> <ul class="nav nav-second-level">
<li> <li>
<a class="{{ activeRoute('transactions.index','withdrawal') }}" href="{{ route('transactions.index','withdrawal') }}"> <a class="{{ activeRoutePartialWhat('transactions','withdrawal') }}" href="{{ route('transactions.index','withdrawal') }}">
<i class="fa fa-long-arrow-left fa-fw"></i> {{ 'expenses'|_ }}</a> <i class="fa fa-long-arrow-left fa-fw"></i> {{ 'expenses'|_ }}</a>
</li> </li>
<li> <li>
<a class="{{ activeRoute('transactions.index','deposit') }}" href="{{ route('transactions.index','deposit') }}"><i <a class="{{ activeRoutePartialWhat('transactions','deposit') }}" href="{{ route('transactions.index','deposit') }}"><i
class="fa fa-long-arrow-right fa-fw"></i> {{ 'income'|_ }}</a> class="fa fa-long-arrow-right fa-fw"></i> {{ 'income'|_ }}</a>
</li> </li>
<li> <li>
<a class="{{ activeRoute('transactions.index','transfers') }}" href="{{ route('transactions.index','transfers') }}"> <a class="{{ activeRoutePartialWhat('transactions','transfers') }}" href="{{ route('transactions.index','transfers') }}">
<i class="fa fa-fw fa-exchange"></i> {{ 'transfers'|_ }}</a> <i class="fa fa-fw fa-exchange"></i> {{ 'transfers'|_ }}</a>
</li> </li>
</ul> </ul>
</li> </li>
<li class="{{ activeRoute('piggy-banks') }}"> <li class="{{ activeRoutePartial('bills') }} {{ activeRoutePartial('piggy-banks') }}">
<a href="#"><i class="fa fa-euro fa-fw"></i> {{ 'moneyManagement'|_ }}<span class="fa arrow"></span></a> <a href="#"><i class="fa fa-euro fa-fw"></i> {{ 'moneyManagement'|_ }}<span class="fa arrow"></span></a>
<ul class="nav nav-second-level"> <ul class="nav nav-second-level">
<li> <li>
<a class="{{ activeRoute('piggy-banks') }}" href="{{ route('piggy-banks.index') }}"> <a class="{{ activeRoutePartial('piggy-banks') }}" href="{{ route('piggy-banks.index') }}">
<i class="fa fa-sort-amount-asc fa-fw"></i> {{ 'piggyBanks'|_ }}</a> <i class="fa fa-sort-amount-asc fa-fw"></i> {{ 'piggyBanks'|_ }}</a>
</li> </li>
<li> <li>
<a class="{{ activeRoute('bills') }}" href="{{ route('bills.index') }}"> <a class="{{ activeRoutePartial('bills') }}" href="{{ route('bills.index') }}">
<i class="fa fa-calendar-o fa-fw"></i> {{ 'bills'|_ }}</a> <i class="fa fa-calendar-o fa-fw"></i> {{ 'bills'|_ }}</a>
</li> </li>
</ul> </ul>
<!-- /.nav-second-level --> <!-- /.nav-second-level -->
</li> </li>
<li class="{{ activeRoute('transactions.create') }}"> <li class="{{ activeRouteStrict('transactions.create') }}">
<a href="#"><i class="fa fa-plus fa-fw"></i> {{ 'createNew'|_ }} <span class="fa arrow"></span></a> <a href="#"><i class="fa fa-plus fa-fw"></i> {{ 'createNew'|_ }} <span class="fa arrow"></span></a>
<ul class="nav nav-second-level"> <ul class="nav nav-second-level">
<li> <li>
<a class="{{ activeRoute('transactions.create','withdrawal') }}" href="{{ route('transactions.create','withdrawal') }}"> <a class="{{ activeRoutePartialWhat('transactions.create','withdrawal') }}" href="{{ route('transactions.create','withdrawal') }}">
<i class="fa fa-long-arrow-left fa-fw"></i> {{ 'withdrawal'|_ }}</a> <i class="fa fa-long-arrow-left fa-fw"></i> {{ 'withdrawal'|_ }}</a>
</li> </li>
<li> <li>
<a class="{{ activeRoute('transactions.create','deposit') }}" href="{{ route('transactions.create','deposit') }}"> <a class="{{ activeRoutePartialWhat('transactions.create','deposit') }}" href="{{ route('transactions.create','deposit') }}">
<i class="fa fa-long-arrow-right fa-fw"></i> {{ 'deposit'|_ }}</a> <i class="fa fa-long-arrow-right fa-fw"></i> {{ 'deposit'|_ }}</a>
</li> </li>
<li> <li>
<a class="{{ activeRoute('transactions.create','transfer') }}" href="{{ route('transactions.create','transfer') }}"> <a class="{{ activeRoutePartialWhat('transactions.create','transfer') }}" href="{{ route('transactions.create','transfer') }}">
<i class="fa fa-fw fa-exchange"></i> {{ 'transfer'|_ }}</a> <i class="fa fa-fw fa-exchange"></i> {{ 'transfer'|_ }}</a>
</li> </li>
</ul> </ul>
@ -173,17 +173,17 @@
</li> </li>
<!-- top menu again --> <!-- top menu again -->
<li class="hidden-sm hidden-md hidden-lg"> <li class="hidden-sm hidden-md hidden-lg">
<a class="{{ activeRoute('profile',null,true) }}" href="{{ route('profile') }}"><i class="fa fa-user fa-fw"></i> {{ Auth.user.email }}</a> <a class="{{ activeRouteStrict('profile') }}" href="{{ route('profile') }}"><i class="fa fa-user fa-fw"></i> {{ Auth.user.email }}</a>
</li> </li>
<li class="hidden-sm hidden-md hidden-lg"> <li class="hidden-sm hidden-md hidden-lg">
<a class="{{ activeRoute('preferences',null,true) }}" href="{{ route('preferences') }}"><i class="fa fa-gear fa-fw"></i> {{ 'preferences'|_ }}</a> <a class="{{ activeRouteStrict('preferences') }}" href="{{ route('preferences') }}"><i class="fa fa-gear fa-fw"></i> {{ 'preferences'|_ }}</a>
</li> </li>
<li class="hidden-sm hidden-md hidden-lg"> <li class="hidden-sm hidden-md hidden-lg">
<a class="{{ activeRoute('currency') }}" href="{{ route('currency.index') }}"><i class="fa fa-usd fa-fw"></i> {{ 'currency'|_ }}</a> <a class="{{ activeRoutePartial('currency') }}" href="{{ route('currency.index') }}"><i class="fa fa-usd fa-fw"></i> {{ 'currency'|_ }}</a>
</li> </li>
<li class="hidden-sm hidden-md hidden-lg"> <li class="hidden-sm hidden-md hidden-lg">
<a class="{{ activeRoute('reminders') }}" href="{{ route('reminders.index') }}"><i class="fa fa-clock-o fa-fw"></i> {{ 'reminders'|_ }}</a> <a class="{{ activeRoutePartial('reminders') }}" href="{{ route('reminders.index') }}"><i class="fa fa-clock-o fa-fw"></i> {{ 'reminders'|_ }}</a>
</li> </li>
<li class="hidden-sm hidden-md hidden-lg"> <li class="hidden-sm hidden-md hidden-lg">
<a href="{{ route('logout') }}"><i class="fa fa-sign-out fa-fw"></i> {{ 'logout'|_ }}</a> <a href="{{ route('logout') }}"><i class="fa fa-sign-out fa-fw"></i> {{ 'logout'|_ }}</a>