FEATURE: add content page overview

This commit is contained in:
Michal Kváček
2016-08-22 23:29:04 +02:00
parent f6fd924cbd
commit d746d5b52b
11 changed files with 319 additions and 97 deletions
+13
View File
@@ -74,4 +74,17 @@ class Template
return config('app.url') . '/assets/' . config('app.theme') . '/' . $path;
}
public static function date($datestamp, $withTime = true)
{
$timestamp = strtotime($datestamp);
if ($timestamp <= 0) {
return '';
}
$format = $withTime ? config('app.datetime_format') : config('app.date_format');
return date($format, $timestamp);
}
}
@@ -1,6 +1,7 @@
<?php
namespace App\Http\Controllers\Admin;
use App\Enumerations\ContentStatuses;
use App\Models\Content;
use App\Models\Module;
use Illuminate\Support\Facades\Input;
@@ -45,6 +46,11 @@ class ContentOverview extends Controller
// get homepage - for checking if homepage is set and available
$homepage = $this->content->getHomepage();
return view('admin.content.overview', ['pages' => $pages, 'homepage' => $homepage]);
return view('admin.content.overview', [
'pages' => $pages,
'homepage' => $homepage,
'statuses' => ContentStatuses::getWithTranslations(),
'module' => isset($module) ? $module : null
]);
}
}
+1 -1
View File
@@ -185,7 +185,7 @@ class Content extends Model
public function getOverview($handler = false, $status = false, $joinAuthor = false, $joinParent = false)
{
$query = DB::table('contents')
->select('contents.*', 'modules.name AS module_name')
->select('contents.*', 'modules.name AS module_name', 'modules.id AS module_id')
->where('contents.status', '<>', self::STATUS_DELETED)
->where('contents.language', LaravelLocalization::getCurrentLocale())
->join('modules', 'modules.handler', '=', 'contents.module_handler')
+7
View File
@@ -81,6 +81,13 @@ class GlobalViewDataProvider extends ServiceProvider
return preg_replace($pattern, $code, $view);
});
Blade::extend(function ($view) {
$pattern = $this->createPattern('date');
$code = '<?php echo \App\Helpers\Template::date($2); ?>';
return preg_replace($pattern, $code, $view);
});
// register extension for rendering widget areas
Blade::extend(function ($view) {
$pattern = $this->createPattern('widgetArea');
+4
View File
@@ -98,6 +98,10 @@ return [
'upload_url' => env('UPLOAD_URL', PHP_SAPI === 'cli' ? '' : url('uploads')),
'thumbnail_url' => env('THUMBNAIL_URL', PHP_SAPI === 'cli' ? '' : url('uploads/thumbnails')),
'theme' => env('THEME'),
'datetime_format' => 'd. m. Y G:i',
'date_format' => 'd. m. Y',
'datetime_format_js' => 'dd-mm-yyyy hh:ii',
'date_format_js' => 'dd-mm-yyyy',
/*
|--------------------------------------------------------------------------
| Logging Configuration
+33
View File
@@ -13028,6 +13028,11 @@ a:focus {
.form-control {
margin: .3em 0;
}
.text-center {
text-align: center;
}
.has-error {
color: #FF4444;
font-size: 13px;
@@ -13038,3 +13043,31 @@ a:focus {
color: red !important;
font-weight: bold;
}
.item-col-header {
outline: solid 1px;
}
.full-width {
width: 100%;
}
.content-overview.item-list {
display: table;
}
.table.content-overview td{
vertical-align: middle !important;
}
.content-overview .with-placeholder {
max-width: 3em;
}
.content-overview .placeholder {
max-height: 3em;
}
.item-list .item-actions-dropdown.active .item-actions-block {
max-width: 300px !important;
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

+6 -1
View File
@@ -47,5 +47,10 @@ return [
'files' => 'Files',
'lockUrl' => 'Keep URL',
'noCategory' => ' -- No category -- ',
'noTemplates' => 'Cannot create content page. There are no available templates for this module.'
'noTemplates' => 'Cannot create content page. There are no available templates for this module.',
'title' => 'Title',
'createdAt' => 'Created at',
'status' => 'Status',
'moduleName' => 'Module',
'actions' => 'Actions'
];
@@ -1,6 +1,14 @@
@extends('admin.layoutWithNavigation')
@section('pageHeading', @trans('admin/contents.overview'))
@section('headerButtons')
@if($module)
<a href="{{route('content.new', ['moduleId' => $module->id])}}" class="btn btn-primary btn-sm rounded-s">
<i class="fa fa-plus"></i>
</a>
@endif
@endsection
@section('content')
@if (!$homepage)
@@ -14,20 +22,130 @@
@endif
@if (count($pages))
<table>
<table class="table item-list full-width content-overview table-striped table-bordered table-hover">
<tr>
<th></th>
<th></th>
<th></th>
<th></th>
<th>@lang('admin/contents.title')</th>
<th>@lang('admin/contents.status')</th>
<th>@lang('admin/contents.moduleName')</th>
<th>@lang('admin/contents.createdAt')</th>
<th>@lang('admin/contents.actions')</th>
</tr>
@foreach($pages as $page)
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
<td class="text-center with-placeholder">
<a href="{{route('content.edit', ['id' => $page->id])}}">
@if(!empty($page->title_photo))
<img src="@upload($page->title_photo)" class="placeholder" alt="{{$page->title}}" />
@else
<img src="{{asset('resources/assets/admin/img/placeholder.png')}}" class="placeholder"
alt="{{$page->title}}" />
@endif
</a>
</td>
<td>
<a href="{{route('content.edit', ['id' => $page->id])}}">
{{$page->title}}
</a>
</td>
<td>{{$statuses[$page->status]}}</td>
<td>
<a href="{{route('content.overview', ['moduleId' => $page->module_id])}}">
{{trans($page->module_name)}}
</a>
</td>
<td>@date($page->created_at)</td>
<td class="text-center">
<div class="item-actions-dropdown">
<a class="item-actions-toggle-btn">
<span class="inactive">
<i class="fa fa-cog"></i>
</span>
<span class="active">
<i class="fa fa-chevron-circle-right"></i>
</span>
</a>
<div class="item-actions-block">
<ul class="item-actions-list">
@if(!$page->is_homepage)
<li>
<a href="{{route('content.setHomepage', ['id' => $page->id])}}"
class="button tiny success">
<i class="fa fa-home"></i>
{{--@lang('admin/contents.setHomepage')--}}
</a>
</li>
@endif
<li>
<a class="edit" href="{{route('content.edit', ['id' => $page->id])}}"
class="button tiny success">
<i class="fa fa-pencil"></i>
{{-- @lang('admin/contents.editPlain')--}}
</a>
</li>
@if($page->status == \App\Models\Content::STATUS_DRAFT)
<li>
<a href="{{route('content.changeStatus', ['id' => $page->id, 'status' => \App\Models\Content::STATUS_PUBLIC])}}"
class="button tiny success">
<i class="fa fa-eye"></i>
{{-- @lang('admin/contents.makePublic')--}}
</a>
</li>
<li>
<a href="{{route('content.changeStatus', ['id' => $page->id, 'status' => \App\Models\Content::STATUS_PROTECTED])}}"
class="button tiny warning" data-toggle="modal"
data-target="#confirm-modal">
<i class="fa fa-lock"></i>
{{-- @lang('admin/contents.makeProtected')--}}
</a>
</li>
@else
<li>
<a href="{{route('page.content', ['url' => $page->url])}}" target="_blank"
class="button tiny secondary"><i class="fa fa-desktop"></i>
{{--@lang('admin/contents.viewPage')--}}
</a>
</li>
<li>
<a href="{{route('content.changeStatus', ['id' => $page->id, 'status' => \App\Models\Content::STATUS_DRAFT])}}"
class="button tiny warning confirm"><i
class="fa fa-eye-slash"></i>
{{--@lang('admin/contents.makeDraft')--}}
</a>
</li>
@endif
<li>
<a class="remove" data-toggle="modal" data-target="#confirm-modal"
href="{{route('content.delete', ['id' => $page->id])}}"
class="button tiny alert confirm"><i
class="fa fa-trash-o"></i>
{{--@lang('admin/contents.deletePage')--}}
</a>
</li>
{{--<li>--}}
{{--<a class="remove" href="#" data-toggle="modal" data-target="#confirm-modal"> <i--}}
{{--class="fa fa-trash-o "></i> </a>--}}
{{--</li>--}}
{{--<li>--}}
{{--<a class="edit" href="item-editor.html"> <i class="fa fa-pencil"></i> </a>--}}
{{--</li>--}}
</ul>
</div>
</div>
</td>
</tr>
@endforeach
</table>
@@ -42,3 +160,21 @@
</div>
@endif
@endsection
+18
View File
@@ -42,6 +42,24 @@
@yield('page')
<!-- /.modal -->
<div class="modal fade" id="confirm-modal">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
<h4 class="modal-title"><i class="fa fa-warning"></i> Alert</h4> </div>
<div class="modal-body">
<p>Are you sure want to do this?</p>
</div>
<div class="modal-footer"> <button type="button" class="btn btn-primary" data-dismiss="modal">Yes</button> <button type="button" class="btn btn-secondary" data-dismiss="modal">No</button> </div>
</div>
<!-- /.modal-content -->
</div>
<!-- /.modal-dialog -->
</div>
<div class="ref" id="ref">
<div class="color-primary"></div>
<div class="chart">
@@ -146,7 +146,7 @@
<article class="content charts-flot-page">
<div class="title-block">
<h3 class="title">
@yield('pageHeading')
@yield('pageHeading') @yield('headerButtons')
</h3>
<p class="title-description">@yield('pageDescription')</p>
</div>