]> BookStack Code Mirror - bookstack/commitdiff
Allow toggling between grid and list view in shelf view (shelves.show) 1755/head
authorjakob <redacted>
Wed, 30 Oct 2019 10:23:42 +0000 (11:23 +0100)
committerjakob <redacted>
Wed, 30 Oct 2019 10:23:42 +0000 (11:23 +0100)
app/Http/Controllers/BookshelfController.php
resources/views/shelves/show.blade.php

index 57e67dc00e618b53fec9b16eec134242422dd8af..5c9da762fb3499341c4be851bacc455cd13dad2c 100644 (file)
@@ -103,6 +103,7 @@ class BookshelfController extends Controller
     public function show(string $slug)
     {
         $shelf = $this->bookshelfRepo->getBySlug($slug);
+        $view = setting()->getForCurrentUser('books_view_type', config('app.views.books'));
         $this->checkOwnablePermission('book-view', $shelf);
 
         Views::add($shelf);
@@ -111,6 +112,7 @@ class BookshelfController extends Controller
         $this->setPageTitle($shelf->getShortName());
         return view('shelves.show', [
             'shelf' => $shelf,
+            'view' => $view,
             'activity' => Activity::entityActivity($shelf, 20, 1)
         ]);
     }
index 2212e1c1e32ae3014b3f839f802d1dc534542c3a..56df61c918219f341020be38356b9d3d2fec64ae 100644 (file)
         <div class="book-content">
             <p class="text-muted">{!! nl2br(e($shelf->description)) !!}</p>
             @if(count($shelf->visibleBooks) > 0)
-                <div class="entity-list">
-                    @foreach($shelf->visibleBooks as $book)
-                        @include('books.list-item', ['book' => $book])
-                    @endforeach
-                </div>
+                @if($view === 'list')
+                    <div class="entity-list">
+                        @foreach($shelf->visibleBooks as $book)
+                            @include('books.list-item', ['book' => $book])
+                        @endforeach
+                    </div>
+                @else
+                    <div class="grid third">
+                        @foreach($shelf->visibleBooks as $key => $book)
+                            @include('books.grid-item', ['book' => $book])
+                        @endforeach
+                    </div>
+                @endif
             @else
                 <div class="mt-xl">
                     <hr>
@@ -87,6 +95,8 @@
                 </a>
             @endif
 
+            @include('partials.view-toggle', ['view' => $view, 'type' => 'book'])
+
             <hr class="primary-background">
 
             @if(userCan('bookshelf-update', $shelf))
Morty Proxy This is a proxified and sanitized view of the page, visit original site.