mirror of
				https://github.com/invoiceninja/invoiceninja.git
				synced 2025-11-03 23:47:32 -05:00 
			
		
		
		
	Improve postal code lookup
This commit is contained in:
		
							parent
							
								
									807c1e4db3
								
							
						
					
					
						commit
						8420b3f36d
					
				@ -94,7 +94,7 @@
 | 
			
		||||
						{!! Former::text('city') !!}
 | 
			
		||||
						{!! Former::text('state') !!}
 | 
			
		||||
						{!! Former::text('postal_code')
 | 
			
		||||
								->onchange(config('ninja.google_maps_api_key') ? 'lookupPostalCode()' : '') !!}
 | 
			
		||||
								->oninput(config('ninja.google_maps_api_key') ? 'lookupPostalCode()' : '') !!}
 | 
			
		||||
						{!! Former::select('country_id')->addOption('','')
 | 
			
		||||
							->fromQuery($countries, 'name', 'id') !!}
 | 
			
		||||
 | 
			
		||||
@ -112,7 +112,7 @@
 | 
			
		||||
						{!! Former::text('shipping_city')->label('city') !!}
 | 
			
		||||
						{!! Former::text('shipping_state')->label('state') !!}
 | 
			
		||||
						{!! Former::text('shipping_postal_code')
 | 
			
		||||
								->onchange(config('ninja.google_maps_api_key') ? 'lookupPostalCode(true)' : '')
 | 
			
		||||
								->oninput(config('ninja.google_maps_api_key') ? 'lookupPostalCode(true)' : '')
 | 
			
		||||
								->label('postal_code') !!}
 | 
			
		||||
						{!! Former::select('shipping_country_id')->addOption('','')
 | 
			
		||||
							->fromQuery($countries, 'name', 'id')->label('country_id') !!}
 | 
			
		||||
 | 
			
		||||
@ -64,10 +64,12 @@ function lookupPostalCode(isShipping) {
 | 
			
		||||
    var countryId = $('#' + countryField).val() || {{ $account->getCountryId() }};
 | 
			
		||||
    var countryCode = countryMap[countryId].iso_3166_2;
 | 
			
		||||
 | 
			
		||||
    if (! postalCode) {
 | 
			
		||||
    if (! postalCode || postalCode.length < 5) {
 | 
			
		||||
        return;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    $('#' + cityField).attr('placeholder', {!! json_encode(trans('texts.loading') . '...') !!});
 | 
			
		||||
 | 
			
		||||
    var geocoder = new google.maps.Geocoder;
 | 
			
		||||
    geocoder.geocode({
 | 
			
		||||
        componentRestrictions: {
 | 
			
		||||
@ -97,8 +99,9 @@ function lookupPostalCode(isShipping) {
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            $('#' + cityField).attr('placeholder', '');
 | 
			
		||||
        } else {
 | 
			
		||||
            $('#' + cityField).attr("placeholder", {!! json_encode(trans('texts.no_match_found')) !!});
 | 
			
		||||
            $('#' + cityField).attr('placeholder', {!! json_encode(trans('texts.no_match_found')) !!});
 | 
			
		||||
        }
 | 
			
		||||
        showGeocodePlaceholder(isShipping);
 | 
			
		||||
    });
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										2
									
								
								resources/views/vendors/edit.blade.php
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								resources/views/vendors/edit.blade.php
									
									
									
									
										vendored
									
									
								
							@ -65,7 +65,7 @@
 | 
			
		||||
			{!! Former::text('state') !!}
 | 
			
		||||
 | 
			
		||||
			{!! Former::text('postal_code')
 | 
			
		||||
					->onchange(config('ninja.google_maps_api_key') ? 'lookupPostalCode()' : '') !!}
 | 
			
		||||
					->oninput(config('ninja.google_maps_api_key') ? 'lookupPostalCode()' : '') !!}
 | 
			
		||||
			{!! Former::select('country_id')->addOption('','')
 | 
			
		||||
				->fromQuery($countries, 'name', 'id') !!}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user