diff --git a/app/Entity.php b/app/Entity.php index 68c773592..977b02e77 100644 --- a/app/Entity.php +++ b/app/Entity.php @@ -36,6 +36,32 @@ abstract class Entity extends Model 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. * @return \Illuminate\Database\Eloquent\Relations\MorphMany @@ -106,7 +132,7 @@ abstract class Entity extends Model $search = $search->with('book'); } - if(static::isA('page')) { + if (static::isA('page')) { $search = $search->with('chapter'); } diff --git a/resources/assets/sass/_lists.scss b/resources/assets/sass/_lists.scss index c2bfb38e3..9d429c39e 100644 --- a/resources/assets/sass/_lists.scss +++ b/resources/assets/sass/_lists.scss @@ -6,7 +6,7 @@ color: $color-chapter; } .inset-list { - display: block; + display: none; overflow: hidden; // padding-left: $-m; margin-bottom: $-l; @@ -45,7 +45,7 @@ margin: 0 0 $-l 0; transition: all ease-in-out 180ms; user-select: none; - i { + i.zmdi-caret-right { transition: all ease-in-out 180ms; transform: rotate(0deg); transform-origin: 25% 50%; @@ -53,7 +53,7 @@ &.open { margin-bottom: 0; } - &.open i { + &.open i.zmdi-caret-right { transform: rotate(90deg); } } @@ -140,6 +140,9 @@ background-color: rgba($color-chapter, 0.12); } } + .chapter-toggle { + padding-left: $-s; + } .list-item-chapter { border-left: 5px solid $color-chapter; margin: 10px 10px; @@ -157,6 +160,12 @@ background-color: rgba($color-page, 0.1); } } + .sub-menu { + display: none; + } + .sub-menu.open { + display: block; + } } // Sortable Lists diff --git a/resources/views/chapters/list-item.blade.php b/resources/views/chapters/list-item.blade.php index f4673c597..91f5ce688 100644 --- a/resources/views/chapters/list-item.blade.php +++ b/resources/views/chapters/list-item.blade.php @@ -11,7 +11,7 @@ @endif @if(count($chapter->pages) > 0 && !isset($hidePages)) -
{{ count($chapter->pages) }} Pages
+{{ count($chapter->pages) }} Pages