Skip to content

Commit 057d7be

Browse files
committed
Views: Made index/show sidebars a lot more modular
Split out each sidebar block into their own template for easier customization of those elements, and less code to manage when overriding the parent show/index views.
1 parent 984a731 commit 057d7be

31 files changed

+540
-542
lines changed

resources/views/books/index.blade.php

Lines changed: 4 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -5,58 +5,11 @@
55
@stop
66

77
@section('left')
8-
@if($recents)
9-
<div id="recents" class="mb-xl">
10-
<h5>{{ trans('entities.recently_viewed') }}</h5>
11-
@include('entities.list', ['entities' => $recents, 'style' => 'compact'])
12-
</div>
13-
@endif
14-
15-
<div id="popular" class="mb-xl">
16-
<h5>{{ trans('entities.books_popular') }}</h5>
17-
@if(count($popular) > 0)
18-
@include('entities.list', ['entities' => $popular, 'style' => 'compact'])
19-
@else
20-
<p class="text-muted pb-l mb-none">{{ trans('entities.books_popular_empty') }}</p>
21-
@endif
22-
</div>
23-
24-
<div id="new" class="mb-xl">
25-
<h5>{{ trans('entities.books_new') }}</h5>
26-
@if(count($new) > 0)
27-
@include('entities.list', ['entities' => $new, 'style' => 'compact'])
28-
@else
29-
<p class="text-muted pb-l mb-none">{{ trans('entities.books_new_empty') }}</p>
30-
@endif
31-
</div>
8+
@include('books.parts.index-sidebar-section-recents', ['recents' => $recents])
9+
@include('books.parts.index-sidebar-section-popular', ['popular' => $popular])
10+
@include('books.parts.index-sidebar-section-new', ['new' => $new])
3211
@stop
3312

3413
@section('right')
35-
36-
<div class="actions mb-xl">
37-
<h5>{{ trans('common.actions') }}</h5>
38-
<div class="icon-list text-link">
39-
@if(userCan(\BookStack\Permissions\Permission::BookCreateAll))
40-
<a href="{{ url("/create-book") }}" data-shortcut="new" class="icon-list-item">
41-
<span>@icon('add')</span>
42-
<span>{{ trans('entities.books_create') }}</span>
43-
</a>
44-
@endif
45-
46-
@include('entities.view-toggle', ['view' => $view, 'type' => 'books'])
47-
48-
<a href="{{ url('/tags') }}" class="icon-list-item">
49-
<span>@icon('tag')</span>
50-
<span>{{ trans('entities.tags_view_tags') }}</span>
51-
</a>
52-
53-
@if(userCan(\BookStack\Permissions\Permission::ContentImport))
54-
<a href="{{ url('/import') }}" class="icon-list-item">
55-
<span>@icon('upload')</span>
56-
<span>{{ trans('entities.import') }}</span>
57-
</a>
58-
@endif
59-
</div>
60-
</div>
61-
14+
@include('books.parts.index-sidebar-section-actions', ['view' => $view])
6215
@stop
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<div id="actions" class="actions mb-xl">
2+
<h5>{{ trans('common.actions') }}</h5>
3+
<div class="icon-list text-link">
4+
@if(userCan(\BookStack\Permissions\Permission::BookCreateAll))
5+
<a href="{{ url("/create-book") }}" data-shortcut="new" class="icon-list-item">
6+
<span>@icon('add')</span>
7+
<span>{{ trans('entities.books_create') }}</span>
8+
</a>
9+
@endif
10+
11+
@include('entities.view-toggle', ['view' => $view, 'type' => 'books'])
12+
13+
<a href="{{ url('/tags') }}" class="icon-list-item">
14+
<span>@icon('tag')</span>
15+
<span>{{ trans('entities.tags_view_tags') }}</span>
16+
</a>
17+
18+
@if(userCan(\BookStack\Permissions\Permission::ContentImport))
19+
<a href="{{ url('/import') }}" class="icon-list-item">
20+
<span>@icon('upload')</span>
21+
<span>{{ trans('entities.import') }}</span>
22+
</a>
23+
@endif
24+
</div>
25+
</div>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<div id="new" class="mb-xl">
2+
<h5>{{ trans('entities.books_new') }}</h5>
3+
@if(count($new) > 0)
4+
@include('entities.list', ['entities' => $new, 'style' => 'compact'])
5+
@else
6+
<p class="text-muted pb-l mb-none">{{ trans('entities.books_new_empty') }}</p>
7+
@endif
8+
</div>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<div id="popular" class="mb-xl">
2+
<h5>{{ trans('entities.books_popular') }}</h5>
3+
@if(count($popular) > 0)
4+
@include('entities.list', ['entities' => $popular, 'style' => 'compact'])
5+
@else
6+
<p class="text-muted pb-l mb-none">{{ trans('entities.books_popular_empty') }}</p>
7+
@endif
8+
</div>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
@if($recents)
2+
<div id="recents" class="mb-xl">
3+
<h5>{{ trans('entities.recently_viewed') }}</h5>
4+
@include('entities.list', ['entities' => $recents, 'style' => 'compact'])
5+
</div>
6+
@endif
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
<div class="actions mb-xl">
2+
<h5>{{ trans('common.actions') }}</h5>
3+
<div class="icon-list text-link">
4+
5+
@if(userCan(\BookStack\Permissions\Permission::PageCreate, $book))
6+
<a href="{{ $book->getUrl('/create-page') }}" data-shortcut="new" class="icon-list-item">
7+
<span>@icon('add')</span>
8+
<span>{{ trans('entities.pages_new') }}</span>
9+
</a>
10+
@endif
11+
@if(userCan(\BookStack\Permissions\Permission::ChapterCreate, $book))
12+
<a href="{{ $book->getUrl('/create-chapter') }}" data-shortcut="new" class="icon-list-item">
13+
<span>@icon('add')</span>
14+
<span>{{ trans('entities.chapters_new') }}</span>
15+
</a>
16+
@endif
17+
18+
<hr class="primary-background">
19+
20+
@if(userCan(\BookStack\Permissions\Permission::BookUpdate, $book))
21+
<a href="{{ $book->getUrl('/edit') }}" data-shortcut="edit" class="icon-list-item">
22+
<span>@icon('edit')</span>
23+
<span>{{ trans('common.edit') }}</span>
24+
</a>
25+
<a href="{{ $book->getUrl('/sort') }}" data-shortcut="sort" class="icon-list-item">
26+
<span>@icon('sort')</span>
27+
<span>{{ trans('common.sort') }}</span>
28+
</a>
29+
@endif
30+
@if(userCan(\BookStack\Permissions\Permission::BookCreateAll))
31+
<a href="{{ $book->getUrl('/copy') }}" data-shortcut="copy" class="icon-list-item">
32+
<span>@icon('copy')</span>
33+
<span>{{ trans('common.copy') }}</span>
34+
</a>
35+
@endif
36+
@if(userCan(\BookStack\Permissions\Permission::RestrictionsManage, $book))
37+
<a href="{{ $book->getUrl('/permissions') }}" data-shortcut="permissions" class="icon-list-item">
38+
<span>@icon('lock')</span>
39+
<span>{{ trans('entities.permissions') }}</span>
40+
</a>
41+
@endif
42+
@if(userCan(\BookStack\Permissions\Permission::BookDelete, $book))
43+
<a href="{{ $book->getUrl('/delete') }}" data-shortcut="delete" class="icon-list-item">
44+
<span>@icon('delete')</span>
45+
<span>{{ trans('common.delete') }}</span>
46+
</a>
47+
@endif
48+
49+
<hr class="primary-background">
50+
51+
@if($watchOptions->canWatch() && !$watchOptions->isWatching())
52+
@include('entities.watch-action', ['entity' => $book])
53+
@endif
54+
@if(!user()->isGuest())
55+
@include('entities.favourite-action', ['entity' => $book])
56+
@endif
57+
@if(userCan(\BookStack\Permissions\Permission::ContentExport))
58+
@include('entities.export-menu', ['entity' => $book])
59+
@endif
60+
</div>
61+
</div>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
@if(count($activity) > 0)
2+
<div id="recent-activity" class="mb-xl">
3+
<h5>{{ trans('entities.recent_activity') }}</h5>
4+
@include('common.activity-list', ['activity' => $activity])
5+
</div>
6+
@endif
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<div class="mb-xl">
2+
<h5>{{ trans('common.details') }}</h5>
3+
<div class="blended-links">
4+
@include('entities.meta', ['entity' => $book, 'watchOptions' => $watchOptions])
5+
@if($book->hasPermissions())
6+
<div class="active-restriction">
7+
@if(userCan(\BookStack\Permissions\Permission::RestrictionsManage, $book))
8+
<a href="{{ $book->getUrl('/permissions') }}" class="entity-meta-item">
9+
@icon('lock')
10+
<div>{{ trans('entities.books_permissions_active') }}</div>
11+
</a>
12+
@else
13+
<div class="entity-meta-item">
14+
@icon('lock')
15+
<div>{{ trans('entities.books_permissions_active') }}</div>
16+
</div>
17+
@endif
18+
</div>
19+
@endif
20+
</div>
21+
</div>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
@if(count($bookParentShelves) > 0)
2+
<div class="actions mb-xl">
3+
<h5>{{ trans('entities.shelves') }}</h5>
4+
@include('entities.list', ['entities' => $bookParentShelves, 'style' => 'compact'])
5+
</div>
6+
@endif
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
@if($book->tags->count() > 0)
2+
<div class="mb-xl">
3+
@include('entities.tag-list', ['entity' => $book])
4+
</div>
5+
@endif

0 commit comments

Comments
 (0)