Signed-off-by: Bill Erickson <berickxx@gmail.com>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
[% IF field == 'alert_message' %]
<textarea class="form-control" ng-model="[% model %]"/>
+ [% ELSIF field == 'post_code' %]
+ <input type="text" ng-blur="post_code_changed(patron.[% path %])"
+ class="form-control" ng-model="[% model %]"/>
[% ELSE %]
<input type="[% input_type %]"
class="form-control" ng-model="[% model %]"/>
}
});
$scope.patron.addresses = addresses;
+ }
+
+ $scope.post_code_changed = function(addr) {
+ console.log('post code ' + addr.post_code);
+ egCore.net.request(
+ 'open-ils.search', 'open-ils.search.zip', addr.post_code)
+ .then(function(resp) {
+ if (!resp) return;
+ if (resp.city) addr.city = resp.city;
+ if (resp.state) addr.state = resp.state;
+ if (resp.county) addr.county = resp.county;
+ if (resp.alert) alert(resp.alert);
+ });
}
}