SelectContactCard add text fields..

This commit is contained in:
Cüneyt Şentürk 2020-12-28 22:58:28 +03:00
parent 918c5af23e
commit 3b3c0c60a5
3 changed files with 169 additions and 9 deletions

View File

@ -20,18 +20,42 @@ class SelectContactCard extends Component
public $create_route;
/** @var string */
public $textAddContact;
/** @var string */
public $textCreateNewContact;
/** @var string */
public $textEditContact;
/** @var string */
public $textContactInfo;
/** @var string */
public $textChooseDifferentContact;
/**
* Create a new component instance.
*
* @return void
*/
public function __construct($type, $contact = false, $contacts = [], $search_route = '', $create_route = '')
public function __construct(
$type, $contact = false, $contacts = [], $search_route = '', $create_route = '',
string $textAddContact = '', string $textCreateNewContact = '', string $textEditContact = '', string $textContactInfo = '', string $textChooseDifferentContact = ''
)
{
$this->type = $type;
$this->contact = $contact;
$this->contacts = $contacts;
$this->search_route = $search_route;
$this->create_route = $create_route;
$this->textAddContact = $this->getTextAddContact($type, $textAddContact);
$this->textCreateNewContact = $this->getTextCreateNewContact($type, $textCreateNewContact);
$this->textEditContact = $this->getTextEditContact($type, $textEditContact);
$this->textContactInfo = $this->getTextContactInfo($type, $textContactInfo);
$this->textChooseDifferentContact = $this->getTextChooseDifferentContact($type, $textChooseDifferentContact);
}
/**
@ -72,4 +96,104 @@ class SelectContactCard extends Component
return view('components.select-contact-card');
}
protected function getTextAddContact($type, $textAddContact)
{
if (!empty($textAddContact)) {
return $textAddContact;
}
switch ($type) {
case 'bill':
case 'expense':
case 'purchase':
$textAddContact = 'vendor';
break;
default:
$textAddContact = 'customer';
break;
}
return $textAddContact;
}
protected function getTextCreateNewContact($type, $textCreateNewContact)
{
if (!empty($textCreateNewContact)) {
return $textCreateNewContact;
}
switch ($type) {
case 'bill':
case 'expense':
case 'purchase':
$textCreateNewContact = 'vendor';
break;
default:
$textCreateNewContact = 'customer';
break;
}
return $textCreateNewContact;
}
protected function getTextEditContact($type, $textEditContact)
{
if (!empty($textEditContact)) {
return $textEditContact;
}
switch ($type) {
case 'bill':
case 'expense':
case 'purchase':
$textEditContact = 'vendor';
break;
default:
$textEditContact = 'customer';
break;
}
return $textEditContact;
}
protected function getTextContactInfo($type, $textContactInfo)
{
if (!empty($textContactInfo)) {
return $textContactInfo;
}
switch ($type) {
case 'bill':
case 'expense':
case 'purchase':
$textContactInfo = 'vendor';
break;
default:
$textContactInfo = 'customer';
break;
}
return $textContactInfo;
}
protected function getTextChooseDifferentContact($type, $textChooseDifferentContact)
{
if (!empty($textChooseDifferentContact)) {
return $textChooseDifferentContact;
}
switch ($type) {
case 'bill':
case 'expense':
case 'purchase':
$textChooseDifferentContact = 'vendor';
break;
default:
$textChooseDifferentContact = 'customer';
break;
}
return $textChooseDifferentContact;
}
}

View File

@ -10,7 +10,7 @@
<div class="document-contact-without-contact-box">
<button type="button" class="btn-aka-link aka-btn--fluid document-contact-without-contact-box-btn"
@click="onContactList">
<i class="far fa-user fa-2x"></i> Add a customer
<i class="far fa-user fa-2x"></i> {{ addContactText }}
</button>
</div>
</div>
@ -60,7 +60,7 @@
<div class="aka-select__footer" tabindex="0" @click="onContactCreate">
<span>
<i class="fas fa-plus"></i> Create a new customer
<i class="fas fa-plus"></i> {{ createNewContactText }}
</span>
</div>
</div>
@ -69,7 +69,7 @@
<div v-else class="invoice-customer__with-customer__bill-to">
<div>
<span class="aka-text aka-text--block-label">Bill to</span>
<span class="aka-text aka-text--block-label">{{ contactInfoText }}</span>
</div>
<div class="table-responsive">
@ -85,12 +85,12 @@
{{ contact.address }}
</th>
</tr>
<tr>
<tr v-if="contact.tax_number">
<th class="p-0">
general.tax_number: {{ contact.tax_number }}
{{ taxNumberText }}: {{ contact.tax_number }}
</th>
</tr>
<tr>
<tr v-if="contact.phone">
<th class="p-0">
{{ contact.phone }}
</th>
@ -104,7 +104,8 @@
</table>
</div>
<button type="button" class="btn btn-link" @click="onContactEdit">Edit Test Customer</button>&nbsp;&nbsp;<button type="button" class="btn btn-link" @click="onContactList">Choose a different customer</button>
<button type="button" class="btn btn-link" @click="onContactEdit">{{ editContactText.replace(':contact_name', contact.name) }}</button>&nbsp;&nbsp;
<button type="button" class="btn btn-link" @click="onContactList">{{ chooseDiffentContactText }}</button>
</div>
</div>
@ -198,6 +199,36 @@ export default {
},
description: "Selectbox Add New Item Feature"
},
addContactText: {
type: String,
default: 'Add a customer',
description: ""
},
createNewContactText: {
type: String,
default: 'Create a new customer',
description: ""
},
editContactText: {
type: String,
default: 'Edit :contact_name Customer',
description: ""
},
contactInfoText: {
type: String,
default: 'Bill to',
description: ""
},
taxNumberText: {
type: String,
default: 'Tax number',
description: ""
},
chooseDiffentContactText: {
type: String,
default: 'Choose a different customer',
description: ""
},
noDataText: {
type: String,
default: 'No Data',

View File

@ -6,7 +6,12 @@
create-route="{{ $create_route }}"
:contacts="{{ json_encode($contacts) }}"
:selected="{{ json_encode($contact) }}"
add-contact-text="{{ $textAddContact }}"
create-new-contact-text="{{ $textCreateNewContact }}"
editContactText="{{ $textEditContact }}"
contact-info-text="{{ $textContactInfo }}"
tax-number-text="{{ trans('general.tax_number') }}"
choose-different-contact-text="{{ $textChooseDifferentContact }}"
:add-new="{{ json_encode([
'status' => true,
'text' => trans('general.add_new'),