Skip to content

Commit 40ad815

Browse files
committed
Added more details to autocomplete inputs
1 parent 91bacfa commit 40ad815

21 files changed

+657
-85426
lines changed

resources/assets/css/app.css

Lines changed: 8 additions & 10071 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

resources/assets/css/document.css

Lines changed: 1 addition & 9266 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

resources/assets/js/app.js

Lines changed: 2 additions & 65983 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

resources/assets/js/app.js.LICENSE.txt

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,12 @@
5252
*/
5353

5454
/*!
55-
* jQuery Mousewheel 3.1.13
56-
*
57-
* Copyright jQuery Foundation and other contributors
58-
* Released under the MIT license
59-
* http://jquery.org/license
55+
* jQuery Mousewheel 3.2.2
56+
* Copyright OpenJS Foundation and other contributors
6057
*/
6158

59+
/*! @license DOMPurify 3.2.5 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.2.5/LICENSE */
60+
6261
/*! Select2 4.1.0-rc.0 | https://github.com/select2/select2/blob/master/LICENSE.md */
6362

6463
/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
@@ -104,7 +103,7 @@
104103
*/
105104

106105
/**!
107-
* Sortable 1.15.2
106+
* Sortable 1.15.6
108107
* @author RubaXa <[email protected]>
109108
* @author owenm <[email protected]>
110109
* @license MIT

resources/js/app.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,8 @@ const appJquery = function() {
327327

328328
$('input[name="person_name"]').autocomplete({
329329
source: people,
330+
value: 'value',
331+
label: 'label',
330332
onSelectItem: appJquery.onSelectPerson,
331333
highlightClass: 'text-danger',
332334
treshold: 2,
@@ -357,6 +359,8 @@ const appJquery = function() {
357359
bindOrganisationAutocomplete: function (){
358360
$('input[name="organisation_name"]').autocomplete({
359361
source: organisations,
362+
value: 'value',
363+
label: 'label',
360364
onSelectItem: appJquery.onSelectOrganisation,
361365
highlightClass: 'text-danger',
362366
treshold: 2,

resources/views/invoices/partials/fields.blade.php

Lines changed: 7 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -4,44 +4,13 @@
44
'name' => 'order_id',
55
'value' => old('order_id', $invoice->order->id ?? $order->id ?? null),
66
])
7-
<span class="autocomplete">
8-
@include('laravel-crm::partials.form.hidden',[
9-
'name' => 'person_id',
10-
'value' => old('person_id', $invoice->person->id ?? $person->id ?? null),
11-
])
12-
<script type="text/javascript">
13-
let people = {!! \VentureDrake\LaravelCrm\Http\Helpers\AutoComplete\people() !!}
14-
</script>
15-
@include('laravel-crm::partials.form.text',[
16-
'name' => 'person_name',
17-
'label' => ucfirst(__('laravel-crm::lang.contact_person')),
18-
'prepend' => '<span class="fa fa-user" aria-hidden="true"></span>',
19-
'value' => old('person_name', $invoice->person->name ?? $person->name ?? null),
20-
'attributes' => [
21-
'autocomplete' => \Illuminate\Support\Str::random()
22-
],
23-
'required' => 'true'
24-
])
25-
</span>
26-
<span class="autocomplete">
27-
@include('laravel-crm::partials.form.hidden',[
28-
'name' => 'organisation_id',
29-
'value' => old('organisation_id', $invoice->organisation->id ?? $organisation->id ?? null),
30-
])
31-
<script type="text/javascript">
32-
let organisations = {!! \VentureDrake\LaravelCrm\Http\Helpers\AutoComplete\organisations() !!}
33-
</script>
34-
@include('laravel-crm::partials.form.text',[
35-
'name' => 'organisation_name',
36-
'label' => ucfirst(__('laravel-crm::lang.organization')),
37-
'prepend' => '<span class="fa fa-building" aria-hidden="true"></span>',
38-
'value' => old('organisation_name',$invoice->organisation->name ?? $organisation->name ?? null),
39-
'attributes' => [
40-
'autocomplete' => \Illuminate\Support\Str::random()
41-
],
42-
'required' => 'true'
43-
])
44-
</span>
7+
8+
@livewire('invoice-form',[
9+
'invoice' => $invoice ?? null,
10+
'organisation' => $organisation ?? null,
11+
'person' => $person ?? null
12+
])
13+
4514
<div class="row">
4615
<div class="col-sm-6">
4716
@include('laravel-crm::partials.form.text',[

resources/views/livewire/deal-form.blade.php

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
]
88
])
99
<script type="text/javascript">
10-
let clients = {!! \VentureDrake\LaravelCrm\Http\Helpers\AutoComplete\clients() !!}
10+
let clients = {!! \VentureDrake\LaravelCrm\Http\Helpers\AutoComplete\clientsWithDetails() !!}
1111
</script>
1212
<span wire:ignore>
1313
@include('laravel-crm::partials.form.text',[
@@ -45,7 +45,7 @@
4545
]
4646
])
4747
<script type="text/javascript">
48-
let organisations = {!! \VentureDrake\LaravelCrm\Http\Helpers\AutoComplete\organisations() !!}
48+
let organisations = {!! \VentureDrake\LaravelCrm\Http\Helpers\AutoComplete\organisationsWithDetails() !!}
4949
</script>
5050
<span wire:ignore>
5151
@include('laravel-crm::partials.form.text',[
@@ -86,7 +86,7 @@
8686
]
8787
])
8888
<script type="text/javascript">
89-
let people = {!! \VentureDrake\LaravelCrm\Http\Helpers\AutoComplete\people() !!}
89+
let people = {!! \VentureDrake\LaravelCrm\Http\Helpers\AutoComplete\peopleWithDetails() !!}
9090
</script>
9191
<span wire:ignore>
9292
@include('laravel-crm::partials.form.text',[
@@ -167,9 +167,10 @@ function bindClientAutocomplete(){
167167
168168
$('input[name="client_name"]').autocomplete({
169169
source: clients,
170+
value: 'value',
171+
label: 'label',
170172
onSelectItem: function (item, element) {
171173
@this.set('client_id',item.value);
172-
@this.set('client_name',item.label);
173174
@this.set('organisation_id', $(element).closest('form').find("input[name='organisation_id']").val());
174175
@this.set('person_id', $(element).closest('form').find("input[name='person_id']").val());
175176
@this.set('person_name', $(element).closest('form').find("input[name='person_name']").val());
@@ -210,9 +211,10 @@ function bindPersonAutocomplete(){
210211
211212
$('input[name="person_name"]').autocomplete({
212213
source: people,
214+
value: 'value',
215+
label: 'label',
213216
onSelectItem: function (item, element) {
214217
@this.set('person_id',item.value);
215-
@this.set('person_name',item.label);
216218
@this.set('organisation_id', $(element).closest('form').find("input[name='organisation_id']").val());
217219
218220
$(element).closest('.autocomplete').find('input[name="person_id"]').val(item.value).trigger('change');
@@ -263,6 +265,8 @@ function bindPersonAutocomplete(){
263265
function bindOrganisationAutocomplete(){
264266
$('input[name="organisation_name"]').autocomplete({
265267
source: organisations,
268+
value: 'value',
269+
label: 'label',
266270
onSelectItem: function (item, element) {
267271
@this.set('person_id', $(element).closest('form').find("input[name='person_id']").val());
268272
@this.set('person_name', $(element).closest('form').find("input[name='person_name']").val());
Lines changed: 163 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,163 @@
1+
<div>
2+
<span class="autocomplete">
3+
@include('laravel-crm::partials.form.hidden',[
4+
'name' => 'organisation_id',
5+
'attributes' => [
6+
'wire:model' => 'organisation_id'
7+
]
8+
])
9+
<script type="text/javascript">
10+
let organisations = {!! \VentureDrake\LaravelCrm\Http\Helpers\AutoComplete\organisationsWithDetails() !!}
11+
</script>
12+
13+
<span wire:ignore>
14+
@include('laravel-crm::partials.form.text',[
15+
'name' => 'organisation_name',
16+
'label' => ucfirst(__('laravel-crm::lang.organization')),
17+
'prepend' => '<span class="fa fa-building" aria-hidden="true"></span>',
18+
'attributes' => [
19+
'autocomplete' => \Illuminate\Support\Str::random(),
20+
'wire:model' => 'organisation_name'
21+
],
22+
'required' => 'true'
23+
])
24+
</span>
25+
</span>
26+
27+
<span class="autocomplete">
28+
@include('laravel-crm::partials.form.hidden',[
29+
'name' => 'person_id',
30+
'attributes' => [
31+
'wire:model' => 'person_id'
32+
]
33+
])
34+
<script type="text/javascript">
35+
let people = {!! \VentureDrake\LaravelCrm\Http\Helpers\AutoComplete\peopleWithDetails() !!}
36+
</script>
37+
38+
<span wire:ignore>
39+
@include('laravel-crm::partials.form.text',[
40+
'name' => 'person_name',
41+
'label' => ucfirst(__('laravel-crm::lang.contact_person')),
42+
'prepend' => '<span class="fa fa-user" aria-hidden="true"></span>',
43+
'attributes' => [
44+
'autocomplete' => \Illuminate\Support\Str::random(),
45+
'wire:model' => 'person_name'
46+
],
47+
'required' => 'true'
48+
])
49+
</span>
50+
</span>
51+
52+
@push('livewire-js')
53+
<script>
54+
$(document).ready(function () {
55+
56+
bindOrganisationAutocomplete();
57+
bindPersonAutocomplete();
58+
59+
function bindOrganisationAutocomplete(){
60+
$('input[name="organisation_name"]').autocomplete({
61+
source: organisations,
62+
value: 'value',
63+
label: 'label',
64+
onSelectItem: function (item, element) {
65+
@this.set('person_id', $(element).closest('form').find("input[name='person_id']").val());
66+
@this.set('person_name', $(element).closest('form').find("input[name='person_name']").val());
67+
@this.set('organisation_id', item.value);
68+
69+
$(element).closest('.autocomplete').find('input[name="organisation_id"]').val(item.value).trigger('change');
70+
71+
$.ajax({
72+
url: "/crm/organisations/" + item.value + "/autocomplete",
73+
cache: false
74+
}).done(function( data ) {
75+
76+
$('.autocomplete-organisation').find('input[name="line1"]').val(data.address_line1);
77+
$('.autocomplete-organisation').find('input[name="line2"]').val(data.address_line2);
78+
$('.autocomplete-organisation').find('input[name="line3"]').val(data.address_line3);
79+
$('.autocomplete-organisation').find('input[name="city"]').val(data.address_city);
80+
$('.autocomplete-organisation').find('input[name="state"]').val(data.address_state);
81+
$('.autocomplete-organisation').find('input[name="code"]').val(data.address_code);
82+
$('.autocomplete-organisation').find('select[name="country"]').val(data.address_country);
83+
84+
});
85+
},
86+
highlightClass: 'text-danger',
87+
treshold: 2,
88+
});
89+
90+
$('input[name="organisation_name"]').on('input', function() {
91+
$(this).closest('.autocomplete').find('input[name="organisation_id"]').val('');
92+
$('.autocomplete-organisation').find('input,select').val('');
93+
$(this).closest('.autocomplete').find('input[name="organisation_id"]').trigger('change');
94+
});
95+
96+
$('input[name="organisation_id"]').on('change', function() {
97+
if($(this).val() == '' && $.trim($(this).closest('.autocomplete').find('input[name="organisation_name"]').val()) != ''){
98+
$(this).closest('.autocomplete').find(".autocomplete-new").show()
99+
$('.autocomplete-organisation').find('input,select').removeAttr('disabled');
100+
Livewire.emit('invoiceOrganisationDeselected');
101+
}else{
102+
$(this).closest('.autocomplete').find(".autocomplete-new").hide()
103+
$('.autocomplete-organisation').find('input,select').attr('disabled','disabled');
104+
}
105+
@this.set('organisation_id',$(this).val());
106+
});
107+
108+
if($('input[name="organisation_id"]').val() == '' && $.trim($('input[name="organisation_id"]').closest('.autocomplete').find('input[name="organisation_name"]').val()) != ''){
109+
$('input[name="organisation_id"]').closest('.autocomplete').find(".autocomplete-new").show();
110+
$('.autocomplete-organisation').find('input,select').removeAttr('disabled');
111+
}
112+
113+
if($('input[name="organisation_name"]').closest('.autocomplete').find('input[name="organisation_id"]').val() == ''){
114+
$('.autocomplete-organisation').find('input,select').removeAttr('disabled');
115+
}
116+
}
117+
118+
function bindPersonAutocomplete(){
119+
120+
$('input[name="person_name"]').autocomplete({
121+
source: people,
122+
value: 'value',
123+
label: 'label',
124+
onSelectItem: function (item, element) {
125+
@this.set('person_id',item.value);
126+
@this.set('organisation_id', $(element).closest('form').find("input[name='organisation_id']").val());
127+
@this.set('organisation_name', $(element).closest('form').find("input[name='organisation_name']").val());
128+
$(element).closest('.autocomplete').find('input[name="person_id"]').val(item.value).trigger('change');
129+
},
130+
highlightClass: 'text-danger',
131+
treshold: 2,
132+
});
133+
134+
$('input[name="person_name"]').on('input', function() {
135+
$(this).closest('.autocomplete').find('input[name="person_id"]').val('');
136+
$('.autocomplete-person').find('input,select').val('');
137+
$(this).closest('.autocomplete').find('input[name="person_id"]').trigger('change');
138+
});
139+
140+
$('input[name="person_id"]').on('change', function() {
141+
if($(this).val() == '' && $.trim($(this).closest('.autocomplete').find('input[name="person_name"]').val()) != ''){
142+
$(this).closest('.autocomplete').find(".autocomplete-new").show()
143+
$('.autocomplete-person').find('input,select').removeAttr('disabled');
144+
}else{
145+
$(this).closest('.autocomplete').find(".autocomplete-new").hide()
146+
$('.autocomplete-person').find('input,select').attr('disabled','disabled');
147+
}
148+
@this.set('person_id',$(this).val());
149+
});
150+
151+
if($('input[name="person_id"]').val() == '' && $.trim($('input[name="person_id"]').closest('.autocomplete').find('input[name="person_name"]').val()) != ''){
152+
$('input[name="person_id"]').closest('.autocomplete').find(".autocomplete-new").show()
153+
$('.autocomplete-person').find('input,select').removeAttr('disabled');
154+
}
155+
156+
if($('input[name="person_name"]').closest('.autocomplete').find('input[name="person_id"]').val() == ''){
157+
$('.autocomplete-person').find('input,select').removeAttr('disabled');
158+
}
159+
}
160+
});
161+
</script>
162+
@endpush
163+
</div>

resources/views/livewire/live-lead-form.blade.php

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
]
88
])
99
<script type="text/javascript">
10-
let clients = {!! \VentureDrake\LaravelCrm\Http\Helpers\AutoComplete\clients() !!}
10+
let clients = {!! \VentureDrake\LaravelCrm\Http\Helpers\AutoComplete\clientsWithDetails() !!}
1111
</script>
1212
<span wire:ignore>
1313
@include('laravel-crm::partials.form.text',[
@@ -45,7 +45,7 @@
4545
]
4646
])
4747
<script type="text/javascript">
48-
let organisations = {!! \VentureDrake\LaravelCrm\Http\Helpers\AutoComplete\organisations() !!}
48+
let organisations = {!! \VentureDrake\LaravelCrm\Http\Helpers\AutoComplete\organisationsWithDetails() !!}
4949
</script>
5050
<span wire:ignore>
5151
@include('laravel-crm::partials.form.text',[
@@ -86,7 +86,7 @@
8686
]
8787
])
8888
<script type="text/javascript">
89-
let people = {!! \VentureDrake\LaravelCrm\Http\Helpers\AutoComplete\people() !!}
89+
let people = {!! \VentureDrake\LaravelCrm\Http\Helpers\AutoComplete\peopleWithDetails() !!}
9090
</script>
9191
<span wire:ignore>
9292
@include('laravel-crm::partials.form.text',[
@@ -167,9 +167,10 @@ function bindClientAutocomplete(){
167167
168168
$('input[name="client_name"]').autocomplete({
169169
source: clients,
170+
value: 'value',
171+
label: 'label',
170172
onSelectItem: function (item, element) {
171173
@this.set('client_id',item.value);
172-
@this.set('client_name',item.label);
173174
@this.set('organisation_id', $(element).closest('form').find("input[name='organisation_id']").val());
174175
@this.set('person_id', $(element).closest('form').find("input[name='person_id']").val());
175176
@this.set('person_name', $(element).closest('form').find("input[name='person_name']").val());
@@ -210,9 +211,10 @@ function bindPersonAutocomplete(){
210211
211212
$('input[name="person_name"]').autocomplete({
212213
source: people,
214+
value: 'value',
215+
label: 'label',
213216
onSelectItem: function (item, element) {
214217
@this.set('person_id',item.value);
215-
@this.set('person_name',item.label);
216218
@this.set('organisation_id', $(element).closest('form').find("input[name='organisation_id']").val());
217219
218220
$(element).closest('.autocomplete').find('input[name="person_id"]').val(item.value).trigger('change');
@@ -263,6 +265,8 @@ function bindPersonAutocomplete(){
263265
function bindOrganisationAutocomplete(){
264266
$('input[name="organisation_name"]').autocomplete({
265267
source: organisations,
268+
value: 'value',
269+
label: 'label',
266270
onSelectItem: function (item, element) {
267271
@this.set('person_id', $(element).closest('form').find("input[name='person_id']").val());
268272
@this.set('person_name', $(element).closest('form').find("input[name='person_name']").val());

0 commit comments

Comments
 (0)