This commit is contained in:
James Cole 2016-02-10 14:36:21 +01:00
parent 0b08010221
commit 94b6c7975a
5 changed files with 196 additions and 90 deletions

View File

@ -2,18 +2,22 @@
declare(strict_types = 1);
use Carbon\Carbon;
use DaveJamesMiller\Breadcrumbs\Generator as BreadCrumbGenerator;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Models\Account;
use FireflyIII\Models\Attachment;
use FireflyIII\Models\Bill;
use FireflyIII\Models\Budget;
use FireflyIII\Models\Category;
use FireflyIII\Models\LimitRepetition;
use FireflyIII\Models\PiggyBank;
use FireflyIII\Models\Rule;
use FireflyIII\Models\RuleGroup;
use FireflyIII\Models\Tag;
use FireflyIII\Models\TransactionCurrency;
use FireflyIII\Models\TransactionJournal;
/*
* Back home.
/**
* HOME
*/
Breadcrumbs::register(
'home',
@ -30,9 +34,10 @@ Breadcrumbs::register(
$breadcrumbs->push(trans('breadcrumbs.home'), route('index'));
}
);
//trans('breadcrumbs.')
// accounts
/**
* ACCOUNTS
*/
Breadcrumbs::register(
'accounts.index', function (BreadCrumbGenerator $breadcrumbs, string $what) {
$breadcrumbs->parent('home');
@ -74,7 +79,77 @@ Breadcrumbs::register(
}
);
// budgets.
/**
* ATTACHMENTS
*/
Breadcrumbs::register(
'attachments.edit', function (BreadCrumbGenerator $breadcrumbs, Attachment $attachment) {
$object = $attachment->attachable;
if ($object instanceof TransactionJournal) {
$breadcrumbs->parent('transactions.show', $object);
$breadcrumbs->push($attachment->filename, route('attachments.edit', $attachment));
} else {
throw new FireflyException('Cannot make breadcrumb for attachment connected to object of type ' . get_class($object));
}
}
);
Breadcrumbs::register(
'attachments.delete', function (BreadCrumbGenerator $breadcrumbs, Attachment $attachment) {
$object = $attachment->attachable;
if ($object instanceof TransactionJournal) {
$breadcrumbs->parent('transactions.show', $object);
$breadcrumbs->push(trans('firefly.delete_attachment', ['name' => $attachment->filename]), route('attachments.edit', $attachment));
} else {
throw new FireflyException('Cannot make breadcrumb for attachment connected to object of type ' . get_class($object));
}
}
);
/**
* BILLS
*/
Breadcrumbs::register(
'bills.index', function (BreadCrumbGenerator $breadcrumbs) {
$breadcrumbs->parent('home');
$breadcrumbs->push(trans('breadcrumbs.bills'), route('bills.index'));
}
);
Breadcrumbs::register(
'bills.create', function (BreadCrumbGenerator $breadcrumbs) {
$breadcrumbs->parent('bills.index');
$breadcrumbs->push(trans('breadcrumbs.newBill'), route('bills.create'));
}
);
Breadcrumbs::register(
'bills.edit', function (BreadCrumbGenerator $breadcrumbs, Bill $bill) {
$breadcrumbs->parent('bills.show', $bill);
$breadcrumbs->push(trans('breadcrumbs.edit_bill', ['name' => e($bill->name)]), route('bills.edit', [$bill->id]));
}
);
Breadcrumbs::register(
'bills.delete', function (BreadCrumbGenerator $breadcrumbs, Bill $bill) {
$breadcrumbs->parent('bills.show', $bill);
$breadcrumbs->push(trans('breadcrumbs.delete_bill', ['name' => e($bill->name)]), route('bills.delete', [$bill->id]));
}
);
Breadcrumbs::register(
'bills.show', function (BreadCrumbGenerator $breadcrumbs, Bill $bill) {
$breadcrumbs->parent('bills.index');
$breadcrumbs->push(e($bill->name), route('bills.show', [$bill->id]));
}
);
/**
* BUDGETS
*/
Breadcrumbs::register(
'budgets.index', function (BreadCrumbGenerator $breadcrumbs) {
$breadcrumbs->parent('home');
@ -120,7 +195,9 @@ Breadcrumbs::register(
}
);
// categories
/**
* CATEGORIES
*/
Breadcrumbs::register(
'categories.index', function (BreadCrumbGenerator $breadcrumbs) {
$breadcrumbs->parent('home');
@ -175,7 +252,9 @@ Breadcrumbs::register(
}
);
// CSV:
/**
* CSV CONTROLLER
*/
Breadcrumbs::register(
'csv.index', function (BreadCrumbGenerator $breadcrumbs) {
$breadcrumbs->parent('home');
@ -211,8 +290,9 @@ Breadcrumbs::register(
}
);
// currencies.
/**
* CURRENCIES
*/
Breadcrumbs::register(
'currency.index', function (BreadCrumbGenerator $breadcrumbs) {
$breadcrumbs->parent('home');
@ -240,8 +320,19 @@ Breadcrumbs::register(
}
);
/**
* EXPORT
*/
Breadcrumbs::register(
'export.index', function (BreadCrumbGenerator $breadcrumbs) {
$breadcrumbs->parent('home');
$breadcrumbs->push(trans('firefly.export_data'), route('export.index'));
}
);
// piggy banks
/**
* PIGGY BANKS
*/
Breadcrumbs::register(
'piggy-banks.index', function (BreadCrumbGenerator $breadcrumbs) {
$breadcrumbs->parent('home');
@ -276,7 +367,9 @@ Breadcrumbs::register(
}
);
// preferences
/**
* PREFERENCES
*/
Breadcrumbs::register(
'preferences', function (BreadCrumbGenerator $breadcrumbs) {
$breadcrumbs->parent('home');
@ -285,7 +378,9 @@ Breadcrumbs::register(
}
);
// profile
/**
* PROFILE
*/
Breadcrumbs::register(
'profile', function (BreadCrumbGenerator $breadcrumbs) {
$breadcrumbs->parent('home');
@ -308,42 +403,9 @@ Breadcrumbs::register(
}
);
// bills
Breadcrumbs::register(
'bills.index', function (BreadCrumbGenerator $breadcrumbs) {
$breadcrumbs->parent('home');
$breadcrumbs->push(trans('breadcrumbs.bills'), route('bills.index'));
}
);
Breadcrumbs::register(
'bills.create', function (BreadCrumbGenerator $breadcrumbs) {
$breadcrumbs->parent('bills.index');
$breadcrumbs->push(trans('breadcrumbs.newBill'), route('bills.create'));
}
);
Breadcrumbs::register(
'bills.edit', function (BreadCrumbGenerator $breadcrumbs, Bill $bill) {
$breadcrumbs->parent('bills.show', $bill);
$breadcrumbs->push(trans('breadcrumbs.edit_bill', ['name' => e($bill->name)]), route('bills.edit', [$bill->id]));
}
);
Breadcrumbs::register(
'bills.delete', function (BreadCrumbGenerator $breadcrumbs, Bill $bill) {
$breadcrumbs->parent('bills.show', $bill);
$breadcrumbs->push(trans('breadcrumbs.delete_bill', ['name' => e($bill->name)]), route('bills.delete', [$bill->id]));
}
);
Breadcrumbs::register(
'bills.show', function (BreadCrumbGenerator $breadcrumbs, Bill $bill) {
$breadcrumbs->parent('bills.index');
$breadcrumbs->push(e($bill->name), route('bills.show', [$bill->id]));
}
);
// reports
/**
* REPORTS
*/
Breadcrumbs::register(
'reports.index', function (BreadCrumbGenerator $breadcrumbs) {
$breadcrumbs->parent('home');
@ -375,7 +437,47 @@ Breadcrumbs::register(
}
);
// search
Breadcrumbs::register(
'rules.rule.create', function (BreadCrumbGenerator $breadcrumbs, RuleGroup $ruleGroup) {
$breadcrumbs->parent('rules.index');
$breadcrumbs->push(trans('firefly.make_new_rule', ['title' => $ruleGroup->title]), route('rules.rule.create', $ruleGroup));
}
);
Breadcrumbs::register(
'rules.rule.edit', function (BreadCrumbGenerator $breadcrumbs, Rule $rule) {
$breadcrumbs->parent('rules.index');
$breadcrumbs->push(trans('firefly.edit_rule', ['title' => $rule->title]), route('rules.rule.edit', $rule));
}
);
Breadcrumbs::register(
'rules.rule.delete', function (BreadCrumbGenerator $breadcrumbs, Rule $rule) {
$breadcrumbs->parent('rules.index');
$breadcrumbs->push(trans('firefly.delete_rule', ['title' => $rule->title]), route('rules.rule.delete', $rule));
}
);
Breadcrumbs::register(
'rules.rule-group.create', function (BreadCrumbGenerator $breadcrumbs) {
$breadcrumbs->parent('rules.index');
$breadcrumbs->push(trans('firefly.make_new_rule_group'), route('rules.rule-group.create'));
}
);
Breadcrumbs::register(
'rules.rule-group.edit', function (BreadCrumbGenerator $breadcrumbs, RuleGroup $ruleGroup) {
$breadcrumbs->parent('rules.index');
$breadcrumbs->push(trans('firefly.edit_rule_group', ['title' => $ruleGroup->title]), route('rules.rule-group.edit', $ruleGroup));
}
);
Breadcrumbs::register(
'rules.rule-group.delete', function (BreadCrumbGenerator $breadcrumbs, RuleGroup $ruleGroup) {
$breadcrumbs->parent('rules.index');
$breadcrumbs->push(trans('firefly.delete_rule_group', ['title' => $ruleGroup->title]), route('rules.rule-group.delete', $ruleGroup));
}
);
/**
* SEARCH
*/
Breadcrumbs::register(
'search', function (BreadCrumbGenerator $breadcrumbs, $query) {
$breadcrumbs->parent('home');
@ -383,43 +485,9 @@ Breadcrumbs::register(
}
);
// transactions
Breadcrumbs::register(
'transactions.index', function (BreadCrumbGenerator $breadcrumbs, string $what) {
$breadcrumbs->parent('home');
$breadcrumbs->push(trans('breadcrumbs.' . $what . '_list'), route('transactions.index', [$what]));
}
);
Breadcrumbs::register(
'transactions.create', function (BreadCrumbGenerator $breadcrumbs, string $what) {
$breadcrumbs->parent('transactions.index', $what);
$breadcrumbs->push(trans('breadcrumbs.create_' . e($what)), route('transactions.create', [$what]));
}
);
Breadcrumbs::register(
'transactions.edit', function (BreadCrumbGenerator $breadcrumbs, TransactionJournal $journal) {
$breadcrumbs->parent('transactions.show', $journal);
$breadcrumbs->push(trans('breadcrumbs.edit_journal', ['description' => $journal->description]), route('transactions.edit', [$journal->id]));
}
);
Breadcrumbs::register(
'transactions.delete', function (BreadCrumbGenerator $breadcrumbs, TransactionJournal $journal) {
$breadcrumbs->parent('transactions.show', $journal);
$breadcrumbs->push(trans('breadcrumbs.delete_journal', ['description' => e($journal->description)]), route('transactions.delete', [$journal->id]));
}
);
Breadcrumbs::register(
'transactions.show', function (BreadCrumbGenerator $breadcrumbs, TransactionJournal $journal) {
$breadcrumbs->parent('transactions.index', strtolower($journal->getTransactionType()));
$breadcrumbs->push($journal->description, route('transactions.show', [$journal->id]));
}
);
// tags
/**
* TAGS
*/
Breadcrumbs::register(
'tags.index', function (BreadCrumbGenerator $breadcrumbs) {
$breadcrumbs->parent('home');
@ -455,3 +523,41 @@ Breadcrumbs::register(
$breadcrumbs->push(e($tag->tag), route('tags.show', [$tag->id]));
}
);
/**
* TRANSACTIONS
*/
Breadcrumbs::register(
'transactions.index', function (BreadCrumbGenerator $breadcrumbs, string $what) {
$breadcrumbs->parent('home');
$breadcrumbs->push(trans('breadcrumbs.' . $what . '_list'), route('transactions.index', [$what]));
}
);
Breadcrumbs::register(
'transactions.create', function (BreadCrumbGenerator $breadcrumbs, string $what) {
$breadcrumbs->parent('transactions.index', $what);
$breadcrumbs->push(trans('breadcrumbs.create_' . e($what)), route('transactions.create', [$what]));
}
);
Breadcrumbs::register(
'transactions.edit', function (BreadCrumbGenerator $breadcrumbs, TransactionJournal $journal) {
$breadcrumbs->parent('transactions.show', $journal);
$breadcrumbs->push(trans('breadcrumbs.edit_journal', ['description' => $journal->description]), route('transactions.edit', [$journal->id]));
}
);
Breadcrumbs::register(
'transactions.delete', function (BreadCrumbGenerator $breadcrumbs, TransactionJournal $journal) {
$breadcrumbs->parent('transactions.show', $journal);
$breadcrumbs->push(trans('breadcrumbs.delete_journal', ['description' => e($journal->description)]), route('transactions.delete', [$journal->id]));
}
);
Breadcrumbs::register(
'transactions.show', function (BreadCrumbGenerator $breadcrumbs, TransactionJournal $journal) {
$breadcrumbs->parent('transactions.index', strtolower($journal->getTransactionType()));
$breadcrumbs->push($journal->description, route('transactions.show', [$journal->id]));
}
);

View File

@ -59,7 +59,6 @@ Route::group(
Route::get('/attachment/edit/{attachment}', ['uses' => 'AttachmentController@edit', 'as' => 'attachments.edit']);
Route::get('/attachment/delete/{attachment}', ['uses' => 'AttachmentController@delete', 'as' => 'attachments.delete']);
Route::get('/attachment/show/{attachment}', ['uses' => 'AttachmentController@show', 'as' => 'attachments.show']);
Route::get('/attachment/preview/{attachment}', ['uses' => 'AttachmentController@preview', 'as' => 'attachments.preview']);
Route::get('/attachment/download/{attachment}', ['uses' => 'AttachmentController@download', 'as' => 'attachments.download']);

View File

@ -123,6 +123,7 @@ return [
'stop_executing_other_actions' => 'Stop executing other actions',
'add_rule_action' => 'Add new action',
'edit_rule' => 'Edit rule ":title"',
'delete_rule' => 'Delete rule ":title"',
'update_rule' => 'Update rule',
// actions and triggers
@ -211,7 +212,7 @@ return [
'pref_custom_fiscal_year_label' => 'Enabled',
'pref_custom_fiscal_year_help' => 'In countries that use a financial year other than January 1 to December 31, you can switch this on and specify start / end days of the fiscal year',
'pref_fiscal_year_start_label' => 'Fiscal year start date',
'pref_two_factor_auth' => '2-step verification',
'pref_two_factor_auth' => '2-step verification',
'pref_two_factor_auth_help' => 'When you enable 2-step verification (also known as two-factor authentication), you add an extra layer of security to your account. You sign in with something you know (your password) and something you have (a verification code). Verification codes are generated by an application on your phone, such as Authy or Google Authenticator.',
'pref_enable_two_factor_auth' => 'Enable 2-step verification',
'pref_save_settings' => 'Save settings',

View File

@ -1,7 +1,7 @@
{% extends "./layout/default.twig" %}
{% block breadcrumbs %}
{{ Breadcrumbs.renderIfExists(Route.getCurrentRoute.getName) }}
{{ Breadcrumbs.renderIfExists(Route.getCurrentRoute.getName, ruleGroup) }}
{% endblock %}
{% block content %}

View File

@ -1,7 +1,7 @@
{% extends "./layout/default.twig" %}
{% block breadcrumbs %}
{{ Breadcrumbs.renderIfExists(Route.getCurrentRoute.getName) }}
{{ Breadcrumbs.renderIfExists(Route.getCurrentRoute.getName, rule) }}
{% endblock %}
{% block content %}