mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-06-17 18:02:26 +08:00
Cleaned book-show and page sidebar by hiding inactive chapter contents
This commit is contained in:
@ -36,6 +36,32 @@ abstract class Entity extends Model
|
|||||||
return [get_class($this), $this->id] === [get_class($entity), $entity->id];
|
return [get_class($this), $this->id] === [get_class($entity), $entity->id];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if an entity matches or contains another given entity.
|
||||||
|
* @param Entity $entity
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function matchesOrContains(Entity $entity)
|
||||||
|
{
|
||||||
|
$matches = [get_class($this), $this->id] === [get_class($entity), $entity->id];
|
||||||
|
|
||||||
|
if ($matches) return true;
|
||||||
|
|
||||||
|
if ($entity->isA('chapter') && $this->isA('book')) {
|
||||||
|
return $entity->book_id === $this->id;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($entity->isA('page') && $this->isA('book')) {
|
||||||
|
return $entity->book_id === $this->id;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($entity->isA('page') && $this->isA('chapter')) {
|
||||||
|
return $entity->chapter_id === $this->id;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the activity objects for this entity.
|
* Gets the activity objects for this entity.
|
||||||
* @return \Illuminate\Database\Eloquent\Relations\MorphMany
|
* @return \Illuminate\Database\Eloquent\Relations\MorphMany
|
||||||
@ -106,7 +132,7 @@ abstract class Entity extends Model
|
|||||||
$search = $search->with('book');
|
$search = $search->with('book');
|
||||||
}
|
}
|
||||||
|
|
||||||
if(static::isA('page')) {
|
if (static::isA('page')) {
|
||||||
$search = $search->with('chapter');
|
$search = $search->with('chapter');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
color: $color-chapter;
|
color: $color-chapter;
|
||||||
}
|
}
|
||||||
.inset-list {
|
.inset-list {
|
||||||
display: block;
|
display: none;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
// padding-left: $-m;
|
// padding-left: $-m;
|
||||||
margin-bottom: $-l;
|
margin-bottom: $-l;
|
||||||
@ -45,7 +45,7 @@
|
|||||||
margin: 0 0 $-l 0;
|
margin: 0 0 $-l 0;
|
||||||
transition: all ease-in-out 180ms;
|
transition: all ease-in-out 180ms;
|
||||||
user-select: none;
|
user-select: none;
|
||||||
i {
|
i.zmdi-caret-right {
|
||||||
transition: all ease-in-out 180ms;
|
transition: all ease-in-out 180ms;
|
||||||
transform: rotate(0deg);
|
transform: rotate(0deg);
|
||||||
transform-origin: 25% 50%;
|
transform-origin: 25% 50%;
|
||||||
@ -53,7 +53,7 @@
|
|||||||
&.open {
|
&.open {
|
||||||
margin-bottom: 0;
|
margin-bottom: 0;
|
||||||
}
|
}
|
||||||
&.open i {
|
&.open i.zmdi-caret-right {
|
||||||
transform: rotate(90deg);
|
transform: rotate(90deg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -140,6 +140,9 @@
|
|||||||
background-color: rgba($color-chapter, 0.12);
|
background-color: rgba($color-chapter, 0.12);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
.chapter-toggle {
|
||||||
|
padding-left: $-s;
|
||||||
|
}
|
||||||
.list-item-chapter {
|
.list-item-chapter {
|
||||||
border-left: 5px solid $color-chapter;
|
border-left: 5px solid $color-chapter;
|
||||||
margin: 10px 10px;
|
margin: 10px 10px;
|
||||||
@ -157,6 +160,12 @@
|
|||||||
background-color: rgba($color-page, 0.1);
|
background-color: rgba($color-page, 0.1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
.sub-menu {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
.sub-menu.open {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sortable Lists
|
// Sortable Lists
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
@endif
|
@endif
|
||||||
|
|
||||||
@if(count($chapter->pages) > 0 && !isset($hidePages))
|
@if(count($chapter->pages) > 0 && !isset($hidePages))
|
||||||
<p class="text-muted chapter-toggle open"><i class="zmdi zmdi-caret-right"></i> {{ count($chapter->pages) }} Pages</p>
|
<p class="text-muted chapter-toggle"><i class="zmdi zmdi-caret-right"></i> <i class="zmdi zmdi-file-text"></i> <span>{{ count($chapter->pages) }} Pages</span></p>
|
||||||
<div class="inset-list">
|
<div class="inset-list">
|
||||||
@foreach($chapter->pages as $page)
|
@foreach($chapter->pages as $page)
|
||||||
<h4><a href="{{$page->getUrl()}}"><i class="zmdi zmdi-file-text"></i>{{$page->name}}</a></h4>
|
<h4><a href="{{$page->getUrl()}}"><i class="zmdi zmdi-file-text"></i>{{$page->name}}</a></h4>
|
||||||
|
@ -3,14 +3,19 @@
|
|||||||
<h6 class="text-muted">Book Navigation</h6>
|
<h6 class="text-muted">Book Navigation</h6>
|
||||||
<ul class="sidebar-page-list menu">
|
<ul class="sidebar-page-list menu">
|
||||||
<li class="book-header"><a href="{{$book->getUrl()}}" class="book {{ $current->matches($book)? 'selected' : '' }}"><i class="zmdi zmdi-book"></i>{{$book->name}}</a></li>
|
<li class="book-header"><a href="{{$book->getUrl()}}" class="book {{ $current->matches($book)? 'selected' : '' }}"><i class="zmdi zmdi-book"></i>{{$book->name}}</a></li>
|
||||||
|
|
||||||
|
|
||||||
@foreach($sidebarTree as $bookChild)
|
@foreach($sidebarTree as $bookChild)
|
||||||
<li class="list-item-{{ $bookChild->getName() }}">
|
<li class="list-item-{{ $bookChild->getName() }} {{ $bookChild->getName() }}">
|
||||||
<a href="{{$bookChild->getUrl()}}" class="{{ $bookChild->getName() }} {{ $current->matches($bookChild)? 'selected' : '' }}">
|
<a href="{{$bookChild->getUrl()}}" class="{{ $bookChild->getName() }} {{ $current->matches($bookChild)? 'selected' : '' }}">
|
||||||
@if($bookChild->isA('chapter'))<i class="zmdi zmdi-collection-bookmark"></i>@else <i class="zmdi zmdi-file-text"></i>@endif{{ $bookChild->name }}
|
@if($bookChild->isA('chapter'))<i class="zmdi zmdi-collection-bookmark"></i>@else <i class="zmdi zmdi-file-text"></i>@endif{{ $bookChild->name }}
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
@if($bookChild->isA('chapter') && count($bookChild->pages) > 0)
|
@if($bookChild->isA('chapter') && count($bookChild->pages) > 0)
|
||||||
<ul class="menu">
|
<p class="text-muted chapter-toggle @if($bookChild->matchesOrContains($current)) open @endif">
|
||||||
|
<i class="zmdi zmdi-caret-right"></i> <i class="zmdi zmdi-file-text"></i> <span>{{ count($bookChild->pages) }} Pages</span>
|
||||||
|
</p>
|
||||||
|
<ul class="menu sub-menu inset-list @if($bookChild->matchesOrContains($current)) open @endif">
|
||||||
@foreach($bookChild->pages as $childPage)
|
@foreach($bookChild->pages as $childPage)
|
||||||
<li class="list-item-page">
|
<li class="list-item-page">
|
||||||
<a href="{{$childPage->getUrl()}}" class="page {{ $current->matches($childPage)? 'selected' : '' }}">
|
<a href="{{$childPage->getUrl()}}" class="page {{ $current->matches($childPage)? 'selected' : '' }}">
|
||||||
@ -20,7 +25,11 @@
|
|||||||
@endforeach
|
@endforeach
|
||||||
</ul>
|
</ul>
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
|
|
||||||
</li>
|
</li>
|
||||||
@endforeach
|
@endforeach
|
||||||
|
|
||||||
|
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
Reference in New Issue
Block a user