mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-05-06 17:20:07 +00:00
Merge branch 'feature/#1598' of git://github.com/cw1998/BookStack into cw1998-feature/#1598
This commit is contained in:
commit
898cedf536
5 changed files with 41 additions and 3 deletions
app
resources
tests/Entity
0
app/Entities/Repos/EntityRepo.php
Normal file
0
app/Entities/Repos/EntityRepo.php
Normal file
|
@ -114,6 +114,7 @@ class BookController extends Controller
|
||||||
{
|
{
|
||||||
$book = $this->bookRepo->getBySlug($slug);
|
$book = $this->bookRepo->getBySlug($slug);
|
||||||
$bookChildren = (new BookContents($book))->getTree(true);
|
$bookChildren = (new BookContents($book))->getTree(true);
|
||||||
|
$bookParentShelves = $book->shelves()->visible();
|
||||||
|
|
||||||
Views::add($book);
|
Views::add($book);
|
||||||
if ($request->has('shelf')) {
|
if ($request->has('shelf')) {
|
||||||
|
@ -125,6 +126,7 @@ class BookController extends Controller
|
||||||
'book' => $book,
|
'book' => $book,
|
||||||
'current' => $book,
|
'current' => $book,
|
||||||
'bookChildren' => $bookChildren,
|
'bookChildren' => $bookChildren,
|
||||||
|
'bookParentShelves' => $bookParentShelves,
|
||||||
'activity' => Activity::entityActivity($book, 20, 1)
|
'activity' => Activity::entityActivity($book, 20, 1)
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -135,6 +135,7 @@ return [
|
||||||
'books_sort_chapters_last' => 'Chapters Last',
|
'books_sort_chapters_last' => 'Chapters Last',
|
||||||
'books_sort_show_other' => 'Show Other Books',
|
'books_sort_show_other' => 'Show Other Books',
|
||||||
'books_sort_save' => 'Save New Order',
|
'books_sort_save' => 'Save New Order',
|
||||||
|
'book_parent_shelves_empty' => 'Shelves that this book is on will appear here.',
|
||||||
|
|
||||||
// Chapters
|
// Chapters
|
||||||
'chapter' => 'Chapter',
|
'chapter' => 'Chapter',
|
||||||
|
|
|
@ -57,9 +57,7 @@
|
||||||
|
|
||||||
@stop
|
@stop
|
||||||
|
|
||||||
|
|
||||||
@section('right')
|
@section('right')
|
||||||
|
|
||||||
<div class="mb-xl">
|
<div class="mb-xl">
|
||||||
<h5>{{ trans('common.details') }}</h5>
|
<h5>{{ trans('common.details') }}</h5>
|
||||||
<div class="text-small text-muted blended-links">
|
<div class="text-small text-muted blended-links">
|
||||||
|
@ -76,7 +74,6 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<div class="actions mb-xl">
|
<div class="actions mb-xl">
|
||||||
<h5>{{ trans('common.actions') }}</h5>
|
<h5>{{ trans('common.actions') }}</h5>
|
||||||
<div class="icon-list text-primary">
|
<div class="icon-list text-primary">
|
||||||
|
@ -125,6 +122,16 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="actions mb-xl">
|
||||||
|
<h5>{{ trans('entities.shelves_long') }}</h5>
|
||||||
|
|
||||||
|
@if(count($bookParentShelves) > 0)
|
||||||
|
@include('partials.entity-list', ['entities' => $bookParentShelves, 'style' => 'compact'])
|
||||||
|
@else
|
||||||
|
<div class="body text-muted">{{ trans('entities.book_parent_shelves_empty') }}</div>
|
||||||
|
@endif
|
||||||
|
</div>
|
||||||
|
|
||||||
@stop
|
@stop
|
||||||
|
|
||||||
@section('left')
|
@section('left')
|
||||||
|
|
|
@ -264,4 +264,32 @@ class BookShelfTest extends TestCase
|
||||||
$pageVisit->assertElementNotContains('.breadcrumbs', $shelf->getShortName());
|
$pageVisit->assertElementNotContains('.breadcrumbs', $shelf->getShortName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function test_bookshelves_show_on_book()
|
||||||
|
{
|
||||||
|
// Create shelf
|
||||||
|
$shelfInfo = [
|
||||||
|
'name' => 'My test shelf' . Str::random(4),
|
||||||
|
'description' => 'Test shelf description ' . Str::random(10)
|
||||||
|
];
|
||||||
|
|
||||||
|
$this->asEditor()->post('/shelves', $shelfInfo);
|
||||||
|
$shelf = Bookshelf::where('name', '=', $shelfInfo['name'])->first();
|
||||||
|
|
||||||
|
// Create book and add to shelf
|
||||||
|
$this->asEditor()->post($shelf->getUrl('/create-book'), [
|
||||||
|
'name' => 'Test book name',
|
||||||
|
'description' => 'Book in shelf description'
|
||||||
|
]);
|
||||||
|
|
||||||
|
$newBook = Book::query()->orderBy('id', 'desc')->first();
|
||||||
|
|
||||||
|
$resp = $this->asEditor()->get($newBook->getUrl());
|
||||||
|
$resp->assertSee($shelfInfo['name']);
|
||||||
|
|
||||||
|
// Remove shelf
|
||||||
|
$this->delete($shelf->getUrl());
|
||||||
|
|
||||||
|
$resp = $this->asEditor()->get($newBook->getUrl());
|
||||||
|
$resp->assertDontSee($shelfInfo['name']);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue