fixed cancel button path for document form refs #1729

This commit is contained in:
Cüneyt Şentürk 2021-01-11 12:22:51 +03:00
parent 00ed7bcd49
commit 7b001d039c
3 changed files with 22 additions and 2 deletions

View File

@ -49,6 +49,9 @@ abstract class DocumentForm extends Base
/** @var string */
public $routeUpdate;
/** @var string */
public $routeCancel;
/** @var string */
public $formId;
@ -195,7 +198,7 @@ abstract class DocumentForm extends Base
bool $hideLogo = false, bool $hideDocumentTitle = false, bool $hideDocumentSubheading = false, bool $hideCompanyEdit = false,
/** Company Component End */
/** Content Component Start */
string $routeStore = '', string $routeUpdate = '', string $formId = 'document', string $formSubmit = 'onSubmit',
string $routeStore = '', string $routeUpdate = '', string $formId = 'document', string $formSubmit = 'onSubmit', string $routeCancel = '',
bool $hideCompany = false, bool $hideAdvanced = false, bool $hideFooter = false, bool $hideButtons = false,
/** Content Component End */
/** Metadata Component Start */
@ -232,6 +235,7 @@ abstract class DocumentForm extends Base
/** Content Component Start */
$this->routeStore = $this->getRouteStore($type, $routeStore);
$this->routeUpdate = $this->getRouteUpdate($type, $routeUpdate, $document);
$this->routeCancel = $this->getRouteCancel($type, $routeCancel);
$this->formId = $formId;
$this->formSubmit = $formSubmit;
@ -322,6 +326,21 @@ abstract class DocumentForm extends Base
return 'invoices.update';
}
protected function getRouteCancel($type, $routeCancel)
{
if (!empty($routeCancel)) {
return $routeCancel;
}
$route = $this->getRouteFromConfig($type, 'index');
if (!empty($route)) {
return $route;
}
return 'invoices.index';
}
protected function getContacts($type, $contacts)
{
if (!empty($contacts)) {

View File

@ -2,7 +2,7 @@
<div class="card">
<div class="card-footer">
<div class="row save-buttons">
{{ Form::saveButtons('invoices.index') }}
{{ Form::saveButtons($routeCancel) }}
</div>
</div>
</div>

View File

@ -88,6 +88,7 @@
<x-documents.form.buttons
type="{{ $type }}"
:document="$document"
route-cancel="{{ $routeCancel }}"
/>
@endif