fixed empty page
This commit is contained in:
parent
a3027f0c2e
commit
6256f381c0
|
|
@ -26,6 +26,8 @@ abstract class Index extends Component
|
|||
|
||||
public $documents;
|
||||
|
||||
public $totalDocuments;
|
||||
|
||||
/** @var string */
|
||||
public $group;
|
||||
|
||||
|
|
@ -223,7 +225,7 @@ abstract class Index extends Component
|
|||
* @return void
|
||||
*/
|
||||
public function __construct(
|
||||
string $type, string $alias = '', $documents = [], string $group = '', string $page = '', string $textTabDocument = '', string $textPage = '',
|
||||
string $type, string $alias = '', $documents = [], int $totalDocuments = null, string $group = '', string $page = '', string $textTabDocument = '', string $textPage = '',
|
||||
string $routeTabDocument = '', string $routeTabRecurring = '', string $routeParamsTabUnpaid = '', string $routeParamsTabDraft = '',
|
||||
string $permissionCreate = '', string $permissionUpdate = '', string $permissionDelete = '',
|
||||
bool $hideAcceptPayment = false, bool $checkPermissionCreate = true,
|
||||
|
|
@ -246,6 +248,7 @@ abstract class Index extends Component
|
|||
$this->type = $type;
|
||||
$this->alias = $this->getAlias($type, $alias);
|
||||
$this->documents = ($documents) ? $documents : collect();
|
||||
$this->totalDocuments = $this->getTotalDocuments($totalDocuments);
|
||||
$this->group = $this->getGroup($type, $group);
|
||||
$this->page = $this->getPage($type, $page);
|
||||
$this->textTabDocument = $this->getTextTabDocument($type, $textTabDocument);
|
||||
|
|
@ -278,7 +281,7 @@ abstract class Index extends Component
|
|||
|
||||
/* -- Content Start -- */
|
||||
/* -- Empty Page Start -- */
|
||||
$this->hideEmptyPage = $hideEmptyPage;
|
||||
$this->hideEmptyPage = $this->getHideEmptyPage($hideEmptyPage);
|
||||
|
||||
$this->emptyPageButtons = $this->getEmptyPageButtons($type, $emptyPageButtons);
|
||||
$this->imageEmptyPage = $this->getImageEmptyPage($type, $imageEmptyPage);
|
||||
|
|
@ -351,6 +354,32 @@ abstract class Index extends Component
|
|||
$this->setParentData();
|
||||
}
|
||||
|
||||
protected function getTotalDocuments($totalDocuments)
|
||||
{
|
||||
if (! is_null($totalDocuments)) {
|
||||
return $totalDocuments;
|
||||
}
|
||||
|
||||
return $this->documents->count();
|
||||
}
|
||||
|
||||
protected function getHideEmptyPage($hideEmptyPage): bool
|
||||
{
|
||||
if ($hideEmptyPage) {
|
||||
return $hideEmptyPage;
|
||||
}
|
||||
|
||||
if ($this->totalDocuments > 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (request()->has('search') && ($this->totalDocuments > 0)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
protected function getEmptyPageButtons($type, $emptyPageButtons)
|
||||
{
|
||||
if (! empty($emptyPageButtons)) {
|
||||
|
|
|
|||
|
|
@ -31,7 +31,9 @@ class Bills extends Controller
|
|||
|
||||
$bills = Document::bill()->with('contact', 'items', 'item_taxes', 'last_history', 'transactions', 'totals', 'histories', 'media')->collect(['issued_at' => 'desc']);
|
||||
|
||||
return $this->response('purchases.bills.index', compact('bills'));
|
||||
$total_bills = Document::bill()->count();
|
||||
|
||||
return $this->response('purchases.bills.index', compact('bills', 'total_bills'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -32,7 +32,9 @@ class Invoices extends Controller
|
|||
|
||||
$invoices = Document::invoice()->with('contact', 'items', 'item_taxes', 'last_history', 'transactions', 'totals', 'histories', 'media')->collect(['document_number'=> 'desc']);
|
||||
|
||||
return $this->response('sales.invoices.index', compact('invoices'));
|
||||
$total_invoices = Document::invoice()->count();
|
||||
|
||||
return $this->response('sales.invoices.index', compact('invoices', 'total_invoices'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
@if ($hideEmptyPage || ($documents->count() || (request()->has('search') && ! request()->has('programmatic'))))
|
||||
@if ($hideEmptyPage)
|
||||
@if (! $hideSummary)
|
||||
<x-index.summary :items="$summaryItems" />
|
||||
@endif
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@
|
|||
</x-slot>
|
||||
|
||||
<x-slot name="content">
|
||||
<x-documents.index.content type="bill" :documents="$bills" />
|
||||
<x-documents.index.content type="bill" :documents="$bills" :total-documents="$total_bills" />
|
||||
</x-slot>
|
||||
|
||||
<x-documents.script type="bill" />
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@
|
|||
</x-slot>
|
||||
|
||||
<x-slot name="content">
|
||||
<x-documents.index.content type="invoice" :documents="$invoices" />
|
||||
<x-documents.index.content type="invoice" :documents="$invoices" :total-documents="$total_invoices" />
|
||||
</x-slot>
|
||||
|
||||
<x-documents.script type="invoice" />
|
||||
|
|
|
|||
Loading…
Reference in New Issue