From: Jason Etheridge Date: Fri, 19 Feb 2021 05:29:13 +0000 (-0500) Subject: lp1863252 fix Get Coordinates button in org admin X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=2ca0ae33a98a73a2f625311aaa4ee0878994cbe6;p=Evergreen.git lp1863252 fix Get Coordinates button in org admin The underlying method can now handle org objects or org id's, and the UI will also alert the user with any non-catastrophic error such as the location not being found. Signed-off-by: Jason Etheridge Signed-off-by: Terran McCanna --- diff --git a/Open-ILS/src/eg2/src/app/staff/admin/server/org-addr.component.ts b/Open-ILS/src/eg2/src/app/staff/admin/server/org-addr.component.ts index cea8fd1154..4156ba2311 100644 --- a/Open-ILS/src/eg2/src/app/staff/admin/server/org-addr.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/admin/server/org-addr.component.ts @@ -5,6 +5,7 @@ import {PcrudService} from '@eg/core/pcrud.service'; import {NetService} from '@eg/core/net.service'; import {AuthService} from '@eg/core/auth.service'; import {NgbTabChangeEvent} from '@ng-bootstrap/ng-bootstrap'; +import {ToastService} from '@eg/share/toast/toast.service'; const ADDR_TYPES = ['billing_address', 'holds_address', 'mailing_address', 'ill_address']; @@ -38,9 +39,10 @@ export class OrgAddressComponent { constructor( private idl: IdlService, private org: OrgService, - private pcrud: PcrudService, - private auth: AuthService, - private net: NetService + private pcrud: PcrudService, + private auth: AuthService, + private net: NetService, + private toast: ToastService ) { this.addrChange = new EventEmitter(); this.tabName = 'billing_address'; @@ -165,22 +167,26 @@ export class OrgAddressComponent { getCoordinates($event: any) { const addr = $event.record; - this.net.request( 'open-ils.actor', - 'open-ils.actor.geo.retrieve_coordinates', - this.auth.token(), - addr.org_unit(), + 'open-ils.actor.geo.retrieve_coordinates', + this.auth.token(), + typeof addr.org_unit() === 'object' ? addr.org_unit().id() : addr.org_unit(), addr.street1() + ' ' + addr.street2() + ', ' + addr.city() + ', ' + addr.state() + ' ' + addr.post_code() + ' ' + addr.country() ).subscribe( (res) => { - addr.latitude( res.latitude ); - addr.longitude( res.longitude ); + console.log('geo',res); + if (typeof res.ilsevent == 'undefined') { + addr.latitude( res.latitude ); + addr.longitude( res.longitude ); + } else { + this.toast.danger(res.desc); + } }, (err) => { - console.error(err); + console.error('geo',err); } ); } diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Geo.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Geo.pm index cb0d92adfb..3f735e5547 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Geo.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Geo.pm @@ -140,6 +140,8 @@ sub retrieve_coordinates { # invoke 3rd party API for latitude/longitude lookup # implementing some options for limiting outgoing geo-coding API calls # return $e->die_event unless $e->checkauth; + $org = ref($org) ? $org->id : $org; # never trust the caller :-) + my $use_geo = $e->retrieve_config_global_flag('opac.use_geolocation'); $use_geo = ($use_geo and $U->is_true($use_geo->enabled)); return new OpenILS::Event("GEOCODING_NOT_ENABLED") unless ($U->is_true($use_geo));