Empty page change method..

This commit is contained in:
Cüneyt Şentürk 2021-02-12 17:51:46 +03:00
parent 04592a8d23
commit c17a596c33
9 changed files with 35 additions and 14 deletions

View File

@ -11,6 +11,9 @@ class EmptyPage extends Component
/** @var string */ /** @var string */
public $page; public $page;
/** @var string */
public $group;
/** @var string */ /** @var string */
public $imageEmptyPage; public $imageEmptyPage;
@ -38,16 +41,17 @@ class EmptyPage extends Component
* @return void * @return void
*/ */
public function __construct( public function __construct(
string $page, string $imageEmptyPage = '', string $textEmptyPage = '', string $textPage = '', string $page, string $group = '', string $imageEmptyPage = '', string $textEmptyPage = '', string $textPage = '',
string $urlDocsPath = '', bool $checkPermissionCreate = true, string $permissionCreate = '', string $routeCreate = '' string $urlDocsPath = '', bool $checkPermissionCreate = true, string $permissionCreate = '', string $routeCreate = ''
) { ) {
$this->page = $page; $this->page = $page;
$this->group = $group;
$this->imageEmptyPage = $this->getImageEmptyPage($page, $imageEmptyPage); $this->imageEmptyPage = $this->getImageEmptyPage($page, $imageEmptyPage);
$this->textEmptyPage = $this->getTextEmptyPage($page, $textEmptyPage); $this->textEmptyPage = $this->getTextEmptyPage($page, $textEmptyPage);
$this->textPage = $this->getTextPage($page, $textPage); $this->textPage = $this->getTextPage($page, $textPage);
$this->urlDocsPath = $this->getUrlDocsPath($page, $urlDocsPath); $this->urlDocsPath = $this->getUrlDocsPath($page, $group, $urlDocsPath);
$this->checkPermissionCreate = $checkPermissionCreate; $this->checkPermissionCreate = $checkPermissionCreate;
$this->permissionCreate = $this->getPermissionCreate($page, $permissionCreate); $this->permissionCreate = $this->getPermissionCreate($page, $group, $permissionCreate);
$this->routeCreate = $this->getRouteCreate($page, $routeCreate); $this->routeCreate = $this->getRouteCreate($page, $routeCreate);
} }
@ -88,29 +92,46 @@ class EmptyPage extends Component
return 'general.' . $page; return 'general.' . $page;
} }
protected function getUrlDocsPath($page, $urlDocsPath) protected function getUrlDocsPath($page, $group, $urlDocsPath)
{ {
if ($urlDocsPath) { if ($urlDocsPath) {
return $urlDocsPath; return $urlDocsPath;
} }
$docs_path = $page;
if (!empty($group)) {
$docs_path = $group . '/' . $page;
}
return 'https://akaunting.com/docs/user-manual/' . $page; return 'https://akaunting.com/docs/user-manual/' . $page;
} }
protected function getPermissionCreate($page, $permissionCreate) protected function getPermissionCreate($page, $group, $permissionCreate)
{ {
if ($permissionCreate) { if ($permissionCreate) {
return $permissionCreate; return $permissionCreate;
} }
$pages = [ $pages = [
'items' => 'create-commen-items', 'reconciliations' => 'create-banking-reconciliations',
'transfers' => 'create-banking-transfers',
'payments' => 'create-purchases-payments',
'vendors' => 'create-purchases-vendors',
'customers' => 'create-sales-customers',
'revenues' => 'create-sales-revenues',
'taxes' => 'create-settings-taxes',
'items' => 'create-common-items',
]; ];
if (array_key_exists($page, $pages)) { if (array_key_exists($page, $pages)) {
$permissionCreate = $pages[$page]; $permissionCreate = $pages[$page];
} }
if (empty($permissionCreate) && !empty($group)) {
$permissionCreate = 'create-' . $group . '-' . $page;
}
return $permissionCreate; return $permissionCreate;
} }

View File

@ -82,7 +82,7 @@
</div> </div>
</div> </div>
@else @else
@include('partials.admin.empty_page', ['page' => 'reconciliations', 'docs_path' => 'banking/reconciliations']) <x-empty-page group="banking" page="reconciliations" />
@endif @endif
@endsection @endsection

View File

@ -83,7 +83,7 @@
</div> </div>
</div> </div>
@else @else
@include('partials.admin.empty_page', ['page' => 'transfers', 'docs_path' => 'banking/transfers']) <x-empty-page group="banking" page="transfers" />
@endif @endif
@endsection @endsection

View File

@ -103,7 +103,7 @@
</div> </div>
</div> </div>
@else @else
@include('partials.admin.empty_page', ['page' => 'items', 'docs_path' => 'items']) <x-empty-page page="items" />
@endif @endif
@endsection @endsection

View File

@ -116,7 +116,7 @@
</div> </div>
</div> </div>
@else @else
@include('partials.admin.empty_page', ['page' => 'payments', 'docs_path' => 'purchases/payments']) <x-empty-page group="purchases" page="payments" />
@endif @endif
@endsection @endsection

View File

@ -103,7 +103,7 @@
</div> </div>
</div> </div>
@else @else
@include('partials.admin.empty_page', ['page' => 'vendors', 'docs_path' => 'purchases/vendors']) <x-empty-page group="purchases" page="vendors" />
@endif @endif
@endsection @endsection

View File

@ -105,7 +105,7 @@
</div> </div>
</div> </div>
@else @else
@include('partials.admin.empty_page', ['page' => 'customers', 'docs_path' => 'sales/customers']) <x-empty-page group="sales" page="customers" />
@endif @endif
@endsection @endsection

View File

@ -116,7 +116,7 @@
</div> </div>
</div> </div>
@else @else
@include('partials.admin.empty_page', ['page' => 'revenues', 'docs_path' => 'sales/revenues']) <x-empty-page group="sales" page="revenues" />
@endif @endif
@endsection @endsection

View File

@ -86,7 +86,7 @@
</div> </div>
</div> </div>
@else @else
@include('partials.admin.empty_page', ['page' => 'taxes', 'docs_path' => 'settings/taxes']) <x-empty-page group="settings" page="taxes" />
@endif @endif
@endsection @endsection