Updated custom homepage views

This commit is contained in:
Dan Brown 2019-04-06 17:31:59 +01:00
parent aedff7dc6d
commit 745a0bb98d
No known key found for this signature in database
GPG Key ID: 46D9F943C24A2EF9
8 changed files with 113 additions and 68 deletions

View File

@ -19,7 +19,6 @@ class HomeController extends Controller
parent::__construct(); parent::__construct();
} }
/** /**
* Display the homepage. * Display the homepage.
* @return Response * @return Response
@ -45,17 +44,36 @@ class HomeController extends Controller
'draftPages' => $draftPages, 'draftPages' => $draftPages,
]; ];
// Add required list ordering & sorting for books & shelves views.
if ($homepageOption === 'bookshelves' || $homepageOption === 'books') {
$key = $homepageOption;
$view = setting()->getUser($this->currentUser, $key . '_view_type', config('app.views.' . $key));
$sort = setting()->getUser($this->currentUser, $key . '_sort', 'name');
$order = setting()->getUser($this->currentUser, $key . '_sort_order', 'asc');
$sortOptions = [
'name' => trans('common.sort_name'),
'created_at' => trans('common.sort_created_at'),
'updated_at' => trans('common.sort_updated_at'),
];
$commonData = array_merge($commonData, [
'view' => $view,
'sort' => $sort,
'order' => $order,
'sortOptions' => $sortOptions,
]);
}
if ($homepageOption === 'bookshelves') { if ($homepageOption === 'bookshelves') {
$shelves = $this->entityRepo->getAllPaginated('bookshelf', 18); $shelves = $this->entityRepo->getAllPaginated('bookshelf', 18, $commonData['sort'], $commonData['order']);
$shelvesViewType = setting()->getUser($this->currentUser, 'bookshelves_view_type', config('app.views.bookshelves', 'grid')); $data = array_merge($commonData, ['shelves' => $shelves]);
$data = array_merge($commonData, ['shelves' => $shelves, 'shelvesViewType' => $shelvesViewType]);
return view('common.home-shelves', $data); return view('common.home-shelves', $data);
} }
if ($homepageOption === 'books') { if ($homepageOption === 'books') {
$books = $this->entityRepo->getAllPaginated('book', 18); $books = $this->entityRepo->getAllPaginated('book', 18, $commonData['sort'], $commonData['order']);
$booksViewType = setting()->getUser($this->currentUser, 'books_view_type', config('app.views.books', 'list')); $data = array_merge($commonData, ['books' => $books]);
$data = array_merge($commonData, ['books' => $books, 'booksViewType' => $booksViewType]);
return view('common.home-book', $data); return view('common.home-book', $data);
} }

View File

@ -231,7 +231,7 @@ div[class^="col-"] img {
grid-template-columns: 2fr 1fr; grid-template-columns: 2fr 1fr;
} }
&.right-focus { &.right-focus {
grid-template-columns: 1fr 2fr; grid-template-columns: 1fr 3fr;
} }
&.gap-xl { &.gap-xl {
grid-column-gap: $-xl; grid-column-gap: $-xl;

View File

@ -371,6 +371,7 @@ ul.pagination {
border: 0; border: 0;
width: 100%; width: 100%;
position: relative; position: relative;
word-break: break-word;
h4 a { h4 a {
color: #666; color: #666;
} }

View File

@ -1,18 +1,26 @@
@extends('sidebar-layout') @extends('simple-layout')
@section('toolbar')
<div class="col-sm-6 faded">
<div class="action-buttons text-left">
<a expand-toggle=".entity-list.compact .entity-item-snippet" class="text-primary text-button">@icon('expand-text'){{ trans('common.toggle_details') }}</a>
@include('books/view-toggle', ['booksViewType' => $booksViewType])
</div>
</div>
@stop
@section('sidebar')
@include('common/home-sidebar')
@stop
@section('body') @section('body')
@include('books/list', ['books' => $books, 'bookViewType' => $booksViewType]) <div class="container mt-m">
<div class="grid right-focus gap-xl">
<div>
<div class="actions mb-xl">
<h5>{{ trans('common.actions') }}</h5>
<div class="icon-list text-primary">
@include('partials.view-toggle', ['view' => $view, 'type' => 'book'])
<a expand-toggle=".entity-list.compact .entity-item-snippet" class="icon-list-item">
<span>@icon('expand-text')</span>
<span>{{ trans('common.toggle_details') }}</span>
</a>
</div>
</div>
@include('common.home-sidebar')
</div>
<div>
@include('books.list', ['books' => $books, 'view' => $view])
</div>
</div>
</div>
@stop @stop

View File

@ -1,19 +1,29 @@
@extends('sidebar-layout') @extends('simple-layout')
@section('toolbar')
<div class="col-sm-6 faded">
<div class="action-buttons text-left">
<a expand-toggle=".entity-list.compact .entity-item-snippet" class="text-primary text-button">@icon('expand-text'){{ trans('common.toggle_details') }}</a>
</div>
</div>
@stop
@section('sidebar')
@include('common/home-sidebar')
@stop
@section('body') @section('body')
<div class="page-content" page-display="{{ $customHomepage->id }}"> <div class="container mt-l">
@include('pages/page-display', ['page' => $customHomepage]) <div class="grid right-focus gap-xl">
<div>
<div class="actions mb-xl">
<h5>{{ trans('common.actions') }}</h5>
<div class="icon-list text-primary">
<a expand-toggle=".entity-list.compact .entity-item-snippet" class="icon-list-item">
<span>@icon('expand-text')</span>
<span>{{ trans('common.toggle_details') }}</span>
</a>
</div>
</div>
@include('common.home-sidebar')
</div>
<div>
<div class="content-wrap card">
<div class="page-content" page-display="{{ $customHomepage->id }}">
@include('pages.page-display', ['page' => $customHomepage])
</div>
</div>
</div>
</div>
</div> </div>
@stop @stop

View File

@ -1,18 +1,26 @@
@extends('sidebar-layout') @extends('simple-layout')
@section('toolbar')
<div class="col-sm-6 faded">
<div class="action-buttons text-left">
<a expand-toggle=".entity-list.compact .entity-item-snippet" class="text-primary text-button">@icon('expand-text'){{ trans('common.toggle_details') }}</a>
@include('shelves/view-toggle', ['shelvesViewType' => $shelvesViewType])
</div>
</div>
@stop
@section('sidebar')
@include('common/home-sidebar')
@stop
@section('body') @section('body')
@include('shelves/list', ['shelves' => $shelves, 'shelvesViewType' => $shelvesViewType]) <div class="container mt-m">
<div class="grid right-focus gap-xl">
<div>
<div class="actions mb-xl">
<h5>{{ trans('common.actions') }}</h5>
<div class="icon-list text-primary">
@include('partials.view-toggle', ['view' => $view, 'type' => 'shelf'])
<a expand-toggle=".entity-list.compact .entity-item-snippet" class="icon-list-item">
<span>@icon('expand-text')</span>
<span>{{ trans('common.toggle_details') }}</span>
</a>
</div>
</div>
@include('common.home-sidebar')
</div>
<div>
@include('shelves.list', ['shelves' => $shelves, 'view' => $view])
</div>
</div>
</div>
@stop @stop

View File

@ -1,23 +1,23 @@
@if(count($draftPages) > 0) @if(count($draftPages) > 0)
<div id="recent-drafts" class="card"> <div id="recent-drafts" class="mb-xl">
<h3>@icon('edit') {{ trans('entities.my_recent_drafts') }}</h3> <h5>{{ trans('entities.my_recent_drafts') }}</h5>
@include('partials/entity-list', ['entities' => $draftPages, 'style' => 'compact']) @include('partials.entity-list', ['entities' => $draftPages, 'style' => 'compact'])
</div> </div>
@endif @endif
<div class="card"> <div class="mb-xl">
<h3>@icon($signedIn ? 'view' : 'star-circle') {{ trans('entities.' . ($signedIn ? 'my_recently_viewed' : 'books_recent')) }}</h3> <h5>{{ trans('entities.' . ($signedIn ? 'my_recently_viewed' : 'books_recent')) }}</h5>
@include('partials/entity-list', [ @include('partials.entity-list', [
'entities' => $recents, 'entities' => $recents,
'style' => 'compact', 'style' => 'compact',
'emptyText' => $signedIn ? trans('entities.no_pages_viewed') : trans('entities.books_empty') 'emptyText' => $signedIn ? trans('entities.no_pages_viewed') : trans('entities.books_empty')
]) ])
</div> </div>
<div class="card"> <div class="mb-xl">
<h3>@icon('file') <a class="no-color" href="{{ baseUrl("/pages/recently-updated") }}">{{ trans('entities.recently_updated_pages') }}</a></h3> <h5><a class="no-color" href="{{ baseUrl("/pages/recently-updated") }}">{{ trans('entities.recently_updated_pages') }}</a></h5>
<div id="recently-updated-pages"> <div id="recently-updated-pages">
@include('partials/entity-list', [ @include('partials.entity-list', [
'entities' => $recentlyUpdatedPages, 'entities' => $recentlyUpdatedPages,
'style' => 'compact', 'style' => 'compact',
'emptyText' => trans('entities.no_pages_recently_updated') 'emptyText' => trans('entities.no_pages_recently_updated')
@ -25,7 +25,7 @@
</div> </div>
</div> </div>
<div id="recent-activity" class="card"> <div id="recent-activity" class="mb-xl">
<h3>@icon('time') {{ trans('entities.recent_activity') }}</h3> <h5>{{ trans('entities.recent_activity') }}</h5>
@include('partials/activity-list', ['activity' => $activity]) @include('partials.activity-list', ['activity' => $activity])
</div> </div>

View File

@ -1,10 +1,10 @@
<div class="form-group"> <div class="form-group">
<div entity-selector class="entity-selector {{$selectorSize or ''}}" entity-types="{{ $entityTypes or 'book,chapter,page' }}" entity-permission="{{ $entityPermission or 'view' }}"> <div entity-selector class="entity-selector {{$selectorSize ?? ''}}" entity-types="{{ $entityTypes ?? 'book,chapter,page' }}" entity-permission="{{ $entityPermission ?? 'view' }}">
<input type="hidden" entity-selector-input name="{{$name}}" value=""> <input type="hidden" entity-selector-input name="{{$name}}" value="">
<input type="text" placeholder="{{ trans('common.search') }}" entity-selector-search> <input type="text" placeholder="{{ trans('common.search') }}" entity-selector-search>
<div class="text-center loading" entity-selector-loading>@include('partials.loading-icon')</div> <div class="text-center loading" entity-selector-loading>@include('partials.loading-icon')</div>
<div entity-selector-results></div> <div entity-selector-results></div>
@if($showAdd) @if($showAdd ?? false)
<div class="entity-selector-add"> <div class="entity-selector-add">
<button entity-selector-add-button type="button" <button entity-selector-add-button type="button"
class="button outline">@icon('add'){{ trans('common.add') }}</button> class="button outline">@icon('add'){{ trans('common.add') }}</button>