Add Empty page component..
This commit is contained in:
parent
2c7f25f41f
commit
01742cd054
125
app/View/Components/EmptyPage.php
Normal file
125
app/View/Components/EmptyPage.php
Normal file
@ -0,0 +1,125 @@
|
||||
<?php
|
||||
|
||||
namespace App\View\Components;
|
||||
|
||||
use Illuminate\View\Component;
|
||||
use Illuminate\Support\Str;
|
||||
use Symfony\Component\Routing\Exception\RouteNotFoundException;
|
||||
|
||||
class EmptyPage extends Component
|
||||
{
|
||||
/** @var string */
|
||||
public $page;
|
||||
|
||||
/** @var string */
|
||||
public $imageEmptyPage;
|
||||
|
||||
/** @var string */
|
||||
public $textEmptyPage;
|
||||
|
||||
/** @var string */
|
||||
public $textPage;
|
||||
|
||||
/** @var string */
|
||||
public $urlDocsPath;
|
||||
|
||||
/** @var bool */
|
||||
public $checkPermissionCreate;
|
||||
|
||||
/** @var string */
|
||||
public $permissionCreate;
|
||||
|
||||
/** @var string */
|
||||
public $routeCreate;
|
||||
|
||||
/**
|
||||
* Create a new component instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(
|
||||
string $page, string $imageEmptyPage = '', string $textEmptyPage = '', string $textPage = '',
|
||||
string $urlDocsPath = '', bool $checkPermissionCreate = true, string $permissionCreate = '', string $routeCreate = ''
|
||||
) {
|
||||
$this->page = $page;
|
||||
$this->imageEmptyPage = $this->getImageEmptyPage($page, $imageEmptyPage);
|
||||
$this->textEmptyPage = $this->getTextEmptyPage($page, $textEmptyPage);
|
||||
$this->textPage = $this->getTextPage($page, $textPage);
|
||||
$this->urlDocsPath = $this->getUrlDocsPath($page, $urlDocsPath);
|
||||
$this->checkPermissionCreate = $checkPermissionCreate;
|
||||
$this->permissionCreate = $this->getPermissionCreate($page, $permissionCreate);
|
||||
$this->routeCreate = $this->getRouteCreate($page, $routeCreate);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the view / contents that represent the component.
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View|string
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
return view('components.empty-page');
|
||||
}
|
||||
|
||||
protected function getImageEmptyPage($page, $imageEmptyPage)
|
||||
{
|
||||
if ($imageEmptyPage) {
|
||||
return $imageEmptyPage;
|
||||
}
|
||||
|
||||
return 'public/img/empty_pages/' . $page . '.png';
|
||||
}
|
||||
|
||||
protected function getTextEmptyPage($page, $textEmptyPage)
|
||||
{
|
||||
if ($textEmptyPage) {
|
||||
return $textEmptyPage;
|
||||
}
|
||||
|
||||
return 'general.empty.' . $page;
|
||||
}
|
||||
|
||||
protected function getTextPage($page, $textPage)
|
||||
{
|
||||
if ($textPage) {
|
||||
return $textPage;
|
||||
}
|
||||
|
||||
return 'general.' . $page;
|
||||
}
|
||||
|
||||
protected function getUrlDocsPath($page, $urlDocsPath)
|
||||
{
|
||||
if ($urlDocsPath) {
|
||||
return $urlDocsPath;
|
||||
}
|
||||
|
||||
return 'https://akaunting.com/docs/user-manual/' . $page;
|
||||
}
|
||||
|
||||
protected function getPermissionCreate($page, $permissionCreate)
|
||||
{
|
||||
if ($permissionCreate) {
|
||||
return $permissionCreate;
|
||||
}
|
||||
|
||||
$pages = [
|
||||
'items' => 'create-commen-items',
|
||||
];
|
||||
|
||||
if (array_key_exists($page, $pages)) {
|
||||
$permissionCreate = $pages[$page];
|
||||
}
|
||||
|
||||
return $permissionCreate;
|
||||
}
|
||||
|
||||
protected function getRouteCreate($page, $routeCreate)
|
||||
{
|
||||
if ($routeCreate) {
|
||||
return $routeCreate;
|
||||
}
|
||||
|
||||
return $page . '.create';
|
||||
}
|
||||
}
|
24
resources/views/components/empty-page.blade.php
Normal file
24
resources/views/components/empty-page.blade.php
Normal file
@ -0,0 +1,24 @@
|
||||
|
||||
<div class="card">
|
||||
<div class="row align-items-center">
|
||||
<div class="col-xs-12 col-sm-6 text-center p-5">
|
||||
<img class="blank-image" src="{{ asset($imageEmptyPage) }}" alt="@yield('title')"/>
|
||||
</div>
|
||||
|
||||
<div class="col-xs-12 col-sm-6 text-center p-5">
|
||||
<p class="text-justify description">
|
||||
{!! trans($textEmptyPage) !!} {!! trans('general.empty.documentation', ['url' => $urlDocsPath]) !!}
|
||||
</p>
|
||||
|
||||
@if ($checkPermissionCreate)
|
||||
@can($permissionCreate)
|
||||
@endif
|
||||
<a href="{{ route($routeCreate) }}" class="btn btn-success float-right mt-4">
|
||||
<span class="btn-inner--text">{{ trans('general.title.create', ['type' => trans_choice($textPage, 1)]) }}</span>
|
||||
</a>
|
||||
@if ($checkPermissionCreate)
|
||||
@endcan
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
Loading…
x
Reference in New Issue
Block a user