</div>
</div>
+ <div ng-if="addr.pending" class="row">
+ <div class="col-md-6 patron-reg-pending-address">
+ <div class="row">
+ <div class="col-md-6">
+ [% l('This is a pending address') %]
+ </div>
+ <div class="col-md-6">
+ <button class="btn btn-success"
+ ng-click="approve_pending_address(addr)">[% l('Approve') %]</button>
+ </div>
+ </div>
+ <div class="row" ng-if="addr._replaces">
+ <div class="col-md-6">
+ [% | l(
+ '{{addr._replaces.street1}}',
+ '{{addr._replaces.street2}}',
+ '<br/>'
+ '{{addr._replaces.city}}',
+ '{{addr._replaces.state}}',
+ '{{addr._replaces.post_code}}') %]
+ Replaces: [_1] [_2] [_3] [_4], [_5] [_6]
+ [% END %]
+ </div>
+ </div>
+ </div>
+ <!-- make sure we occupy the entire row -->
+ <div class="col-md-6"> </div>
+ </div>
+
<!-- ADDRESS_TYPE -->
<div class="row reg-field-row" ng-show="show_field('aua.address_type')">
[% draw_field_label('aua', 'address_type') %]
addr.id == patron.mailing_address.id);
addr._is_billing = (patron.billing_address &&
addr.id == patron.billing_address.id);
+ addr.pending = addr.pending === 't';
}
/*
angular.forEach(patron.addresses,
function(addr) { service.ingest_address(patron, addr) });
+ // Link replaced address to its pending address.
+ angular.forEach(patron.addresses, function(addr) {
+ if (addr.replaces) {
+ addr._replaces = patron.addresses.filter(
+ function(a) {return a.id == addr.replaces})[0];
+ }
+ });
+
service.get_linked_addr_users(patron.addresses);
// Remove stat cat entries that link to out-of-scope stat
patron.addresses().push(addr);
addr.valid(addr.valid() ? 't' : 'f');
addr.within_city_limits(addr.within_city_limits() ? 't' : 'f');
+ addr.pending(addr.pending() ? 't' : 'f');
if (addr_hash._is_mailing) patron.mailing_address(addr);
if (addr_hash._is_billing) patron.billing_address(addr);
});
$scope.patron.addresses = addresses;
}
+ $scope.approve_pending_address = function(addr) {
+
+ egCore.net.request(
+ 'open-ils.actor',
+ 'open-ils.actor.user.pending_address.approve',
+ egCore.auth.token(), addr.id
+ ).then(function(replaced_id) {
+ var evt = egCore.evt.parse(replaced_id);
+ if (evt) { alert(evt); return; }
+
+ // Remove the pending address and the replaced address
+ // from the local list of patron addresses.
+ var addresses = [];
+ angular.forEach($scope.patron.addresses, function(a) {
+ if (a.id != addr.id && a.id != replaced_id) {
+ addresses.push(a);
+ }
+ });
+ $scope.patron.addresses = addresses;
+
+ // Fetch a fresh copy of the modified address from the server.
+ // and add it back to the list.
+ egCore.pcrud.retrieve('aua', replaced_id, {}, {authoritative: true})
+ .then(null, null, function(new_addr) {
+ new_addr = egCore.idl.toHash(new_addr);
+ patronRegSvc.ingest_address($scope.patron, new_addr);
+ $scope.patron.addresses.push(new_addr);
+ });
+ });
+ }
+
$scope.post_code_changed = function(addr) {
egCore.net.request(
'open-ils.search', 'open-ils.search.zip', addr.post_code)