Select Contact Card dynamic language text

This commit is contained in:
Cüneyt Şentürk 2020-12-29 11:54:36 +03:00
parent 50b6385ed4
commit 8eb020211f
6 changed files with 87 additions and 33 deletions

View File

@ -368,10 +368,16 @@ abstract class DocumentForm extends Component
case 'bill': case 'bill':
case 'expense': case 'expense':
case 'purchase': case 'purchase':
$textAddContact = 'vendor'; $textAddContact = [
'general.form.add',
'general.vendors'
];
break; break;
default: default:
$textAddContact = 'customer'; $textAddContact = [
'general.form.add',
'general.customers'
];
break; break;
} }
@ -388,10 +394,16 @@ abstract class DocumentForm extends Component
case 'bill': case 'bill':
case 'expense': case 'expense':
case 'purchase': case 'purchase':
$textCreateNewContact = 'vendor'; $textCreateNewContact = [
'general.form.add_new',
'general.vendors'
];
break; break;
default: default:
$textCreateNewContact = 'customer'; $textCreateNewContact = [
'general.form.add_new',
'general.customers'
];
break; break;
} }
@ -408,10 +420,16 @@ abstract class DocumentForm extends Component
case 'bill': case 'bill':
case 'expense': case 'expense':
case 'purchase': case 'purchase':
$textEditContact = 'vendor'; $textEditContact = [
'general.form.contact_edit',
'general.vendors'
];
break; break;
default: default:
$textEditContact = 'customer'; $textEditContact = [
'general.form.contact_edit',
'general.customers'
];
break; break;
} }
@ -428,10 +446,10 @@ abstract class DocumentForm extends Component
case 'bill': case 'bill':
case 'expense': case 'expense':
case 'purchase': case 'purchase':
$textContactInfo = 'vendor'; $textContactInfo = 'bills.bill_from';
break; break;
default: default:
$textContactInfo = 'customer'; $textContactInfo = 'invoices.bill_to';
break; break;
} }
@ -448,10 +466,16 @@ abstract class DocumentForm extends Component
case 'bill': case 'bill':
case 'expense': case 'expense':
case 'purchase': case 'purchase':
$textChooseDifferentContact = 'vendor'; $textChooseDifferentContact = [
'general.form.choose_different',
'general.vendors'
];
break; break;
default: default:
$textChooseDifferentContact = 'customer'; $textChooseDifferentContact = [
'general.form.choose_different',
'general.customers'
];
break; break;
} }

View File

@ -42,7 +42,7 @@ class SelectContactCard extends Component
*/ */
public function __construct( public function __construct(
$type, $contact = false, $contacts = [], $search_route = '', $create_route = '', $type, $contact = false, $contacts = [], $search_route = '', $create_route = '',
string $textAddContact = '', string $textCreateNewContact = '', string $textEditContact = '', string $textContactInfo = '', string $textChooseDifferentContact = '' $textAddContact = '', $textCreateNewContact = '', $textEditContact = '', $textContactInfo = '', $textChooseDifferentContact = ''
) )
{ {
$this->type = $type; $this->type = $type;
@ -107,10 +107,16 @@ class SelectContactCard extends Component
case 'bill': case 'bill':
case 'expense': case 'expense':
case 'purchase': case 'purchase':
$textAddContact = 'vendor'; $textAddContact = [
'general.form.add',
'general.vendors'
];
break; break;
default: default:
$textAddContact = 'customer'; $textAddContact = [
'general.form.add',
'general.customers'
];
break; break;
} }
@ -127,10 +133,16 @@ class SelectContactCard extends Component
case 'bill': case 'bill':
case 'expense': case 'expense':
case 'purchase': case 'purchase':
$textCreateNewContact = 'vendor'; $textCreateNewContact = [
'general.form.add_new',
'general.vendors'
];
break; break;
default: default:
$textCreateNewContact = 'customer'; $textCreateNewContact = [
'general.form.add_new',
'general.customers'
];
break; break;
} }
@ -147,10 +159,16 @@ class SelectContactCard extends Component
case 'bill': case 'bill':
case 'expense': case 'expense':
case 'purchase': case 'purchase':
$textEditContact = 'vendor'; $textEditContact = [
'general.form.contact_edit',
'general.vendors'
];
break; break;
default: default:
$textEditContact = 'customer'; $textEditContact = [
'general.form.contact_edit',
'general.customers'
];
break; break;
} }
@ -167,10 +185,10 @@ class SelectContactCard extends Component
case 'bill': case 'bill':
case 'expense': case 'expense':
case 'purchase': case 'purchase':
$textContactInfo = 'vendor'; $textContactInfo = 'bills.bill_from';
break; break;
default: default:
$textContactInfo = 'customer'; $textContactInfo = 'invoices.bill_to';
break; break;
} }
@ -187,10 +205,16 @@ class SelectContactCard extends Component
case 'bill': case 'bill':
case 'expense': case 'expense':
case 'purchase': case 'purchase':
$textChooseDifferentContact = 'vendor'; $textChooseDifferentContact = [
'general.form.choose_different',
'general.vendors'
];
break; break;
default: default:
$textChooseDifferentContact = 'customer'; $textChooseDifferentContact = [
'general.form.choose_different',
'general.customers'
];
break; break;
} }

View File

@ -105,7 +105,7 @@
</div> </div>
<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="onContactEdit">{{ editContactText.replace(':contact_name', contact.name) }}</button>&nbsp;&nbsp;
<button type="button" class="btn btn-link" @click="onContactList">{{ chooseDiffentContactText }}</button> <button type="button" class="btn btn-link" @click="onContactList">{{ chooseDifferentContactText }}</button>
</div> </div>
</div> </div>
@ -224,7 +224,7 @@ export default {
default: 'Tax number', default: 'Tax number',
description: "" description: ""
}, },
chooseDiffentContactText: { chooseDifferentContactText: {
type: String, type: String,
default: 'Choose a different customer', default: 'Choose a different customer',
description: "" description: ""

View File

@ -185,7 +185,13 @@ return [
'field' => '- Select :field -', 'field' => '- Select :field -',
'file' => 'Select File', 'file' => 'Select File',
], ],
'add' => 'Add a :field',
'add_an' => 'Add an :field',
'add_new' => 'Add New :field', 'add_new' => 'Add New :field',
'edit' => 'Edit :field',
'contact_edit' => 'Edit :contact_name :field',
'choose' => 'Choose :field',
'choose_different' => 'Choose a different :field',
'no_file_selected' => 'No file selected...', 'no_file_selected' => 'No file selected...',
], ],

View File

@ -8,11 +8,11 @@
:contacts="$contacts" :contacts="$contacts"
:search_route="$contactSearchRoute" :search_route="$contactSearchRoute"
:create_route="$contactCreateRoute" :create_route="$contactCreateRoute"
text-add-contact="{{ $textAddContact }}" :text-add-contact="$textAddContact"
text-create-new-contact="{{ $textCreateNewContact }}" :text-create-new-contact="$textCreateNewContact"
text-edit-contact="{{ $textEditContact }}" :text-edit-contact="$textEditContact"
text-contact-info="{{ $textContactInfo }}" :text-contact-info="$textContactInfo"
text-choose-different-contact="{{ $textChooseDifferentContact }}" :text-choose-different-contact="$textChooseDifferentContact"
/> />
</div> </div>
@endif @endif

View File

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