BookStack/resources/views/books/sort-box.blade.php
Dan Brown 3f3fad7113
Fixed book-tree-gen page visibility issue
When book trees were generated, pages in chapters where ALL pages within
were not supposed to be visibile, would be visible due to the code
falling back on the raw relation which would not account for
permissions.

This has now been changed so that a custom 'visible_pages' attribute is set and used by any book tree structures, to ensure it does not fall back to the raw relation.

Added an extra test to cover.

For #2414
2020-12-17 17:31:18 +00:00

48 lines
2.4 KiB
PHP

<div class="sort-box" data-type="book" data-id="{{ $book->id }}">
<h5 class="text-book entity-list-item no-hover py-xs pl-none">
<span>@icon('book')</span>
<span>{{ $book->name }}</span>
</h5>
<div class="sort-box-options pb-sm">
<a href="#" data-sort="name" class="button outline small">{{ trans('entities.books_sort_name') }}</a>
<a href="#" data-sort="created" class="button outline small">{{ trans('entities.books_sort_created') }}</a>
<a href="#" data-sort="updated" class="button outline small">{{ trans('entities.books_sort_updated') }}</a>
<a href="#" data-sort="chaptersFirst" class="button outline small">{{ trans('entities.books_sort_chapters_first') }}</a>
<a href="#" data-sort="chaptersLast" class="button outline small">{{ trans('entities.books_sort_chapters_last') }}</a>
</div>
<ul class="sortable-page-list sort-list">
@foreach($bookChildren as $bookChild)
<li class="text-{{ $bookChild->getClassName() }}"
data-id="{{$bookChild->id}}" data-type="{{ $bookChild->getClassName() }}"
data-name="{{ $bookChild->name }}" data-created="{{ $bookChild->created_at->timestamp }}"
data-updated="{{ $bookChild->updated_at->timestamp }}">
<div class="entity-list-item">
<span>@icon($bookChild->getType()) </span>
<div>
{{ $bookChild->name }}
<div>
</div>
</div>
</div>
@if($bookChild->isA('chapter'))
<ul>
@foreach($bookChild->visible_pages as $page)
<li class="text-page"
data-id="{{$page->id}}" data-type="page"
data-name="{{ $page->name }}" data-created="{{ $page->created_at->timestamp }}"
data-updated="{{ $page->updated_at->timestamp }}">
<div class="entity-list-item">
<span>@icon('page')</span>
<span>{{ $page->name }}</span>
</div>
</li>
@endforeach
</ul>
@endif
</li>
@endforeach
</ul>
</div>