<h4>
@if (isset($showPath) && $showPath)
<a href="{{ $chapter->book->getUrl() }}" class="text-book">
- <i class="zmdi zmdi-book"></i>{{ $chapter->book->name }}
+ <i class="zmdi zmdi-book"></i>{{ $chapter->book->getShortName() }}
</a>
<span class="text-muted"> » </span>
@endif
<div class="page {{$page->draft ? 'draft' : ''}} entity-list-item" data-entity-type="page" data-entity-id="{{$page->id}}">
<h4>
+ @if (isset($showPath) && $showPath)
+ <a href="{{ $page->book->getUrl() }}" class="text-book">
+ <i class="zmdi zmdi-book"></i>{{ $page->book->getShortName() }}
+ </a>
+ <span class="text-muted"> » </span>
+ @if($page->chapter)
+ <a href="{{ $page->chapter->getUrl() }}" class="text-chapter">
+ <i class="zmdi zmdi-collection-bookmark"></i>{{ $page->chapter->getShortName() }}
+ </a>
+ <span class="text-muted"> » </span>
+ @endif
+ @endif
<a href="{{ $page->getUrl() }}" class="text-page entity-list-item-link"><i class="zmdi zmdi-file-text"></i><span class="entity-list-item-name">{{ $page->name }}</span></a>
</h4>
@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'))
<?php namespace Tests;
+use BookStack\Chapter;
+use BookStack\Page;
+
class EntitySearchTest extends TestCase
{
])
];
- $pageA = \BookStack\Page::first();
+ $pageA = Page::first();
$pageA->tags()->saveMany($newTags);
- $pageB = \BookStack\Page::all()->last();
+ $pageB = Page::all()->last();
$pageB->tags()->create(['name' => 'animal', 'value' => 'dog']);
$this->asEditor();
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());
$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());
+ }
}