From 11346d899f097939f86b0b391bd07c01005fe017 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=BCneyt=20=C5=9Eent=C3=BCrk?= Date: Wed, 6 Oct 2021 15:24:12 +0300 Subject: [PATCH] close #2260 Fixed: Categories in New Payment window initially shown by id instead of name. --- app/Abstracts/View/Components/DocumentForm.php | 8 ++++++-- app/View/Components/Documents/Form/Advanced.php | 4 ++++ app/View/Components/Documents/Form/Company.php | 2 +- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/app/Abstracts/View/Components/DocumentForm.php b/app/Abstracts/View/Components/DocumentForm.php index 2930ff1ea..7f6f2d152 100644 --- a/app/Abstracts/View/Components/DocumentForm.php +++ b/app/Abstracts/View/Components/DocumentForm.php @@ -285,7 +285,7 @@ abstract class DocumentForm extends Base /** Content Component End */ /** Metadata Component Start */ - $this->contacts = $this->getContacts($type, $contacts); + $this->contacts = $this->getContacts($type, $document, $contacts); $this->contact = $this->getContact($contact, $document); $this->contactType = $this->getContactType($type, $contactType); @@ -442,7 +442,7 @@ abstract class DocumentForm extends Base return 'general.recurring_and_more'; } - protected function getContacts($type, $contacts) + protected function getContacts($type, $document, $contacts) { if (!empty($contacts)) { return $contacts; @@ -456,6 +456,10 @@ abstract class DocumentForm extends Base $contacts = Contact::enabled()->orderBy('name')->take(setting('default.select_limit'))->get(); } + if (!empty($document) && ($document->contact && !$contacts->has($document->contact_id))) { + $contacts->put($document->contact->id, $document->contact->name); + } + return $contacts; } diff --git a/app/View/Components/Documents/Form/Advanced.php b/app/View/Components/Documents/Form/Advanced.php index caeb66f9c..b88b0eee2 100644 --- a/app/View/Components/Documents/Form/Advanced.php +++ b/app/View/Components/Documents/Form/Advanced.php @@ -22,6 +22,10 @@ class Advanced extends Component $categories = Category::enabled()->orderBy('name')->take(setting('default.select_limit'))->pluck('name', 'id'); } + if (!empty($this->document) && ($this->document->category && !$categories->has($this->document->category_id))) { + $categories->put($this->document->category->id, $this->document->category->name); + } + $recurring_class = 'col-sm-6 col-md-6 col-lg-6 col-xl-6'; $more_class = 'col-sm-6 col-md-6 col-lg-6 col-xl-6'; $more_form_class = 'col-md-12'; diff --git a/app/View/Components/Documents/Form/Company.php b/app/View/Components/Documents/Form/Company.php index 9dce2ab4f..069807d2f 100644 --- a/app/View/Components/Documents/Form/Company.php +++ b/app/View/Components/Documents/Form/Company.php @@ -18,6 +18,6 @@ class Company extends Component $inputNameType = config('type.' . $this->type . '.route.parameter'); - return view('components.documents.form.company', compact('company','inputNameType')); + return view('components.documents.form.company', compact('company', 'inputNameType')); } }