Skip to content

Commit

Permalink
Fix passing data to the SelectContactCard component.
Browse files Browse the repository at this point in the history
  • Loading branch information
pavel-mironchik committed Nov 2, 2021
1 parent abc18da commit 0b85a3a
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 20 deletions.
24 changes: 12 additions & 12 deletions app/View/Components/SelectContactCard.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ class SelectContactCard extends Component

public $contacts;

public $search_route;
public $searchRoute;

public $create_route;
public $createRoute;

/** @var string */
public $textAddContact;
Expand All @@ -44,15 +44,15 @@ class SelectContactCard extends Component
* @return void
*/
public function __construct(
$type, $contact = false, $contacts = [], $search_route = '', $create_route = '', string $error = '',
$type, $contact = false, $contacts = [], $searchRoute = '', $createRoute = '', string $error = '',
$textAddContact = '', $textCreateNewContact = '', $textEditContact = '', $textContactInfo = '', $textChooseDifferentContact = ''
)
{
$this->type = $type;
$this->contact = $contact;
$this->contacts = $contacts;
$this->search_route = $search_route;
$this->create_route = $create_route;
$this->searchRoute = $searchRoute;
$this->createRoute = $createRoute;
$this->error = ($error) ?: "form.errors.get('contact_id')" ;

$this->textAddContact = $this->getTextAddContact($type, $textAddContact);
Expand All @@ -73,24 +73,24 @@ public function render()
$this->contacts = Contact::{$this->type}()->enabled()->orderBy('name')->take(setting('default.select_limit'))->get();
}

if (empty($this->search_route)) {
if (empty($this->searchRoute)) {
switch ($this->type) {
case 'customer':
$this->search_route = route('customers.index');
$this->searchRoute = route('customers.index');
break;
case 'vendor':
$this->search_route = route('vendors.index');
$this->searchRoute = route('vendors.index');
break;
}
}

if (empty($this->create_route)) {
if (empty($this->createRoute)) {
switch ($this->type) {
case 'customer':
$this->create_route = route('modals.customers.create');
$this->createRoute = route('modals.customers.create');
break;
case 'vendor':
$this->create_route = route('modals.vendors.create');
$this->createRoute = route('modals.vendors.create');
break;
}
}
Expand All @@ -100,7 +100,7 @@ public function render()

return view('components.select-contact-card');
}

protected function getTextAddContact($type, $textAddContact)
{
if (!empty($textAddContact)) {
Expand Down
4 changes: 2 additions & 2 deletions resources/views/components/documents/form/content.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@
contact-type="{{ $contactType }}"
:contact="$contact"
:contacts="$contacts"
:search_route="$contactSearchRoute"
:create_route="$contactCreateRoute"
:search-route="$contactSearchRoute"
:create-route="$contactCreateRoute"
hide-issued-at="{{ $hideIssuedAt }}"
text-issued-at="{{ $textIssuedAt }}"
issued-at="{{ $issuedAt }}"
Expand Down
4 changes: 2 additions & 2 deletions resources/views/components/documents/form/main.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
contact-type="{{ $contactType }}"
:contact="$contact"
:contacts="$contacts"
:search_route="$contactSearchRoute"
:create_route="$contactCreateRoute"
:search-route="$contactSearchRoute"
:create-route="$contactCreateRoute"
hide-issued-at="{{ $hideIssuedAt }}"
text-issued-at="{{ $textIssuedAt }}"
issued-at="{{ $issuedAt }}"
Expand Down
4 changes: 2 additions & 2 deletions resources/views/components/documents/form/metadata.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
type="{{ $contactType }}"
:contact="$contact"
:contacts="$contacts"
:search_route="$contactSearchRoute"
:create_route="$contactCreateRoute"
:search-route="$contactSearchRoute"
:create-route="$contactCreateRoute"
error="form.errors.get('contact_name')"
:text-add-contact="$textAddContact"
:text-create-new-contact="$textCreateNewContact"
Expand Down
4 changes: 2 additions & 2 deletions resources/views/components/select-contact-card.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
placeholder="{{ $placeholder }}"
no-data-text="{{ trans('general.no_data') }}"
no-matching-data-text="{{ trans('general.no_matching_data') }}"
search-route="{{ $search_route }}"
create-route="{{ $create_route }}"
search-route="{{ $searchRoute }}"
create-route="{{ $createRoute }}"
:contacts="{{ json_encode($contacts) }}"
:selected="{{ json_encode($contact) }}"
add-contact-text="{{ is_array($textAddContact) ? trans($textAddContact[0], ['field' => trans_choice($textAddContact[1], 1)]) : trans($textAddContact) }}"
Expand Down

0 comments on commit 0b85a3a

Please sign in to comment.