From eb8f8fa9351dd27963462f2cd5c90663125b650e Mon Sep 17 00:00:00 2001 From: James Cole Date: Fri, 14 Nov 2014 11:56:45 +0100 Subject: [PATCH] Expanded on categories. --- app/controllers/CategoryController.php | 9 ++++++++- app/lib/FireflyIII/Database/Category.php | 14 ++++++++++++++ app/views/categories/show.blade.php | 2 +- app/views/list/journals-full.blade.php | 6 +++++- public/assets/javascript/firefly/categories.js | 13 ++----------- 5 files changed, 30 insertions(+), 14 deletions(-) diff --git a/app/controllers/CategoryController.php b/app/controllers/CategoryController.php index 19ca21766f..cb9aa2c649 100644 --- a/app/controllers/CategoryController.php +++ b/app/controllers/CategoryController.php @@ -78,7 +78,14 @@ class CategoryController extends BaseController */ public function show(Category $category) { - return View::make('categories.show', compact('category')); + $hideCategory = true; + + /** @var \FireflyIII\Database\Category $repos */ + $repos = App::make('FireflyIII\Database\Category'); + + $journals = $repos->getTransactionJournals($category, 50); + + return View::make('categories.show', compact('category','journals','hideCategory')); } /** diff --git a/app/lib/FireflyIII/Database/Category.php b/app/lib/FireflyIII/Database/Category.php index 0e4085e439..faa11b7f65 100644 --- a/app/lib/FireflyIII/Database/Category.php +++ b/app/lib/FireflyIII/Database/Category.php @@ -170,6 +170,20 @@ class Category implements CUD, CommonDatabaseCalls, CategoryInterface throw new NotImplementedException; } + public function getTransactionJournals(\Category $category, $limit = 50) + { + $offset = intval(\Input::get('page')) > 0 ? intval(\Input::get('page')) * $limit : 0; + $set = $category->transactionJournals()->withRelevantData()->take($limit)->offset($offset)->orderBy('date', 'DESC')->get(['transaction_journals.*']); + $count = $category->transactionJournals()->count(); + $items = []; + foreach ($set as $entry) { + $items[] = $entry; + } + + return \Paginator::make($items, $count, $limit); + + } + /** * @param \Category $budget * @param Carbon $date diff --git a/app/views/categories/show.blade.php b/app/views/categories/show.blade.php index 594680d8ca..5cebffd6ed 100644 --- a/app/views/categories/show.blade.php +++ b/app/views/categories/show.blade.php @@ -17,7 +17,7 @@ Transactions
-
+ @include('list.journals-full')
diff --git a/app/views/list/journals-full.blade.php b/app/views/list/journals-full.blade.php index b4cec4ae25..d118ec5fa1 100644 --- a/app/views/list/journals-full.blade.php +++ b/app/views/list/journals-full.blade.php @@ -13,7 +13,9 @@ @if(!isset($hideBudget) || (isset($hideBudget) && $hideBudget=== false)) @endif - + @if(!isset($hideCategory) || (isset($hideCategory) && $hideCategory=== false)) + + @endif @foreach($journals as $journal) @@ -89,12 +91,14 @@ @endif @endif + @if(!isset($hideCategory) || (isset($hideCategory) && $hideCategory=== false)) categories[0]) ? $journal->categories[0] : null; ?> @if($category) {{{$category->name}}} @endif + @endif @if($journal->recurringTransaction) {{{$journal->recurringTransaction->name}}} diff --git a/public/assets/javascript/firefly/categories.js b/public/assets/javascript/firefly/categories.js index 502dfd7366..4827e81307 100644 --- a/public/assets/javascript/firefly/categories.js +++ b/public/assets/javascript/firefly/categories.js @@ -1,18 +1,9 @@ $(function () { - if (typeof googleTable == 'function') { - googleTable('table/categories', 'category-list'); - if (typeof(componentID) != 'undefined') { - googleTable('table/component/' + componentID + '/0/transactions','transactions'); - - if (typeof googleColumnChart == 'function') { - googleColumnChart('chart/component/' + componentID + '/spending/' + year, 'componentOverview'); - } - - } + if (typeof componentID != 'undefined' && typeof repetitionID == 'undefined') { + googleColumnChart('chart/component/' + componentID + '/spending/' + year, 'componentOverview'); } - }); \ No newline at end of file