From ec83f830172721745b996eb3b4fddd19ff7ca9bb Mon Sep 17 00:00:00 2001 From: Dan Brown Date: Thu, 27 Jul 2017 16:10:58 +0100 Subject: [PATCH] Added breadcrumbs to pages in entity select Fixes #391 --- package.json | 3 ++- resources/views/chapters/list-item.blade.php | 2 +- resources/views/pages/list-item.blade.php | 12 +++++++++ .../views/search/entity-ajax-list.blade.php | 2 +- tests/Entity/EntitySearchTest.php | 27 ++++++++++++++++--- 5 files changed, 39 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index fb5e5a54a..429572882 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,8 @@ "build": "gulp build", "production": "gulp build --production", "dev": "gulp", - "watch": "gulp" + "watch": "gulp", + "permissions": "chown -R $USER:$USER bootstrap/cache storage public/uploads" }, "devDependencies": { "babelify": "^7.3.0", diff --git a/resources/views/chapters/list-item.blade.php b/resources/views/chapters/list-item.blade.php index 8487a63a3..1ae20b301 100644 --- a/resources/views/chapters/list-item.blade.php +++ b/resources/views/chapters/list-item.blade.php @@ -2,7 +2,7 @@

@if (isset($showPath) && $showPath) - {{ $chapter->book->name }} + {{ $chapter->book->getShortName() }}   »   @endif diff --git a/resources/views/pages/list-item.blade.php b/resources/views/pages/list-item.blade.php index 70b309e7d..f440a52f6 100644 --- a/resources/views/pages/list-item.blade.php +++ b/resources/views/pages/list-item.blade.php @@ -1,5 +1,17 @@

+ @if (isset($showPath) && $showPath) + + {{ $page->book->getShortName() }} + +   »   + @if($page->chapter) + + {{ $page->chapter->getShortName() }} + +   »   + @endif + @endif {{ $page->name }}

diff --git a/resources/views/search/entity-ajax-list.blade.php b/resources/views/search/entity-ajax-list.blade.php index 93f2633aa..9a146506f 100644 --- a/resources/views/search/entity-ajax-list.blade.php +++ b/resources/views/search/entity-ajax-list.blade.php @@ -2,7 +2,7 @@ @if(count($entities) > 0) @foreach($entities as $index => $entity) @if($entity->isA('page')) - @include('pages/list-item', ['page' => $entity]) + @include('pages/list-item', ['page' => $entity, 'showPath' => true]) @elseif($entity->isA('book')) @include('books/list-item', ['book' => $entity]) @elseif($entity->isA('chapter')) diff --git a/tests/Entity/EntitySearchTest.php b/tests/Entity/EntitySearchTest.php index 94e28e944..587430918 100644 --- a/tests/Entity/EntitySearchTest.php +++ b/tests/Entity/EntitySearchTest.php @@ -1,6 +1,9 @@ tags()->saveMany($newTags); - $pageB = \BookStack\Page::all()->last(); + $pageB = Page::all()->last(); $pageB->tags()->create(['name' => 'animal', 'value' => 'dog']); $this->asEditor(); @@ -160,8 +163,8 @@ class EntitySearchTest extends TestCase public function test_ajax_entity_search() { - $page = \BookStack\Page::all()->last(); - $notVisitedPage = \BookStack\Page::first(); + $page = Page::all()->last(); + $notVisitedPage = Page::first(); // Visit the page to make popular $this->asEditor()->get($page->getUrl()); @@ -176,4 +179,20 @@ class EntitySearchTest extends TestCase $defaultListTest->assertSee($page->name); $defaultListTest->assertDontSee($notVisitedPage->name); } + + public function test_ajax_entity_serach_shows_breadcrumbs() + { + $chapter = Chapter::first(); + $page = $chapter->pages->first(); + $this->asEditor(); + + $pageSearch = $this->get('/ajax/search/entities?term=' . urlencode($page->name)); + $pageSearch->assertSee($page->name); + $pageSearch->assertSee($chapter->getShortName()); + $pageSearch->assertSee($page->book->getShortName()); + + $chapterSearch = $this->get('/ajax/search/entities?term=' . urlencode($chapter->name)); + $chapterSearch->assertSee($chapter->name); + $chapterSearch->assertSee($chapter->book->getShortName()); + } }