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();
}
/**
* Display the homepage.
* @return Response
@ -45,17 +44,36 @@ class HomeController extends Controller
'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') {
$shelves = $this->entityRepo->getAllPaginated('bookshelf', 18);
$shelvesViewType = setting()->getUser($this->currentUser, 'bookshelves_view_type', config('app.views.bookshelves', 'grid'));
$data = array_merge($commonData, ['shelves' => $shelves, 'shelvesViewType' => $shelvesViewType]);
$shelves = $this->entityRepo->getAllPaginated('bookshelf', 18, $commonData['sort'], $commonData['order']);
$data = array_merge($commonData, ['shelves' => $shelves]);
return view('common.home-shelves', $data);
}
if ($homepageOption === 'books') {
$books = $this->entityRepo->getAllPaginated('book', 18);
$booksViewType = setting()->getUser($this->currentUser, 'books_view_type', config('app.views.books', 'list'));
$data = array_merge($commonData, ['books' => $books, 'booksViewType' => $booksViewType]);
$books = $this->entityRepo->getAllPaginated('book', 18, $commonData['sort'], $commonData['order']);
$data = array_merge($commonData, ['books' => $books]);
return view('common.home-book', $data);
}

View File

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

View File

@ -371,6 +371,7 @@ ul.pagination {
border: 0;
width: 100%;
position: relative;
word-break: break-word;
h4 a {
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])
@section('body')
<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
@section('sidebar')
@include('common/home-sidebar')
@stop
@section('body')
@include('books/list', ['books' => $books, 'bookViewType' => $booksViewType])
@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>
@section('body')
<div class="container mt-l">
<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>
@stop
@section('sidebar')
@include('common/home-sidebar')
@stop
@section('body')
<div class="page-content" page-display="{{ $customHomepage->id }}">
@include('pages/page-display', ['page' => $customHomepage])
</div>
@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])
@section('body')
<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
@section('sidebar')
@include('common/home-sidebar')
@stop
@section('body')
@include('shelves/list', ['shelves' => $shelves, 'shelvesViewType' => $shelvesViewType])
@stop

View File

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

View File

@ -1,10 +1,10 @@
<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="text" placeholder="{{ trans('common.search') }}" entity-selector-search>
<div class="text-center loading" entity-selector-loading>@include('partials.loading-icon')</div>
<div entity-selector-results></div>
@if($showAdd)
@if($showAdd ?? false)
<div class="entity-selector-add">
<button entity-selector-add-button type="button"
class="button outline">@icon('add'){{ trans('common.add') }}</button>