Added breadcrumbs to pages in entity select

Fixes #391
This commit is contained in:
Dan Brown 2017-07-27 16:10:58 +01:00
parent 5cd08ab2f5
commit ec83f83017
No known key found for this signature in database
GPG Key ID: 46D9F943C24A2EF9
5 changed files with 39 additions and 7 deletions

View File

@ -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",

View File

@ -2,7 +2,7 @@
<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">&nbsp;&nbsp;&raquo;&nbsp;&nbsp;</span>
@endif

View File

@ -1,5 +1,17 @@
<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">&nbsp;&nbsp;&raquo;&nbsp;&nbsp;</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">&nbsp;&nbsp;&raquo;&nbsp;&nbsp;</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>

View File

@ -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'))

View File

@ -1,6 +1,9 @@
<?php namespace Tests;
use BookStack\Chapter;
use BookStack\Page;
class EntitySearchTest extends TestCase
{
@ -75,10 +78,10 @@ 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();
@ -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());
}
}