From 7b001d039ce0b6f169cec27f251c0852f408d5e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=BCneyt=20=C5=9Eent=C3=BCrk?= Date: Mon, 11 Jan 2021 12:22:51 +0300 Subject: [PATCH] fixed cancel button path for document form refs #1729 --- .../View/Components/DocumentForm.php | 21 ++++++++++++++++++- .../documents/form/buttons.blade.php | 2 +- .../documents/form/content.blade.php | 1 + 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/app/Abstracts/View/Components/DocumentForm.php b/app/Abstracts/View/Components/DocumentForm.php index 5f38dccb3..16cd00f9a 100644 --- a/app/Abstracts/View/Components/DocumentForm.php +++ b/app/Abstracts/View/Components/DocumentForm.php @@ -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)) { diff --git a/resources/views/components/documents/form/buttons.blade.php b/resources/views/components/documents/form/buttons.blade.php index a87f137d3..56da609e3 100644 --- a/resources/views/components/documents/form/buttons.blade.php +++ b/resources/views/components/documents/form/buttons.blade.php @@ -2,7 +2,7 @@
diff --git a/resources/views/components/documents/form/content.blade.php b/resources/views/components/documents/form/content.blade.php index 2dde4f456..dfd63aeb0 100644 --- a/resources/views/components/documents/form/content.blade.php +++ b/resources/views/components/documents/form/content.blade.php @@ -88,6 +88,7 @@ @endif