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'];
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<IdlObject>();
this.tabName = 'billing_address';
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);
}
);
}
# 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));