service.user_setting_types[stype.name()] = stype;
});
- if(service.patron_id) {
+ if (service.patron_id) {
// retrieve applied values for the current user
// for the setting types we care about.
).then(function(settings) {
service.user_settings = settings;
});
- }
+ } else {
- // apply default user setting values
- angular.forEach(setting_types, function(stype, index) {
- if (stype.reg_default() != undefined) {
- service.modified_user_settings[setting.name()] =
+ // apply default user setting values
+ angular.forEach(setting_types, function(stype, index) {
+ if (stype.reg_default() != undefined) {
service.user_settings[setting.name()] =
- setting.reg_default();
- }
- });
+ setting.reg_default();
+ }
+ });
+ }
});
}
angular.forEach(patron.cards, function(card) {
card.active = card.active == 't';
- if (card.id == patron.card.id)
+ if (card.id == patron.card.id) {
+ patron.card = card;
card._primary = 'on';
+ }
});
angular.forEach(patron.addresses,
var addr = {
valid : true,
+ address_type : 'MAILING', // TODO: i18n
within_city_limits : true
// default state, etc.
};
active : true,
card : {},
home_ou : egCore.org.get(egCore.auth.user().ws_ou()),
+
// TODO default profile group?
mailing_address : addr,
addresses : [addr]
patron.cards([]);
angular.forEach(card_hashes, function(chash) {
var card = new egCore.idl.ac();
- patron.cards().push(card);
for (var key in chash) {
if (typeof card[key] == 'function')
card[key](chash[key]);
}
card.usr(patron.id());
card.active(chash.active ? 't' : 'f');
+ patron.cards().push(card);
if (chash._primary) {
patron.card(card);
if (addr_hash._is_billing) patron.billing_address(addr);
});
+ // TODO extract hold_notify_phone, etc.
+
egCore.net.request(
'open-ils.actor',
'open-ils.actor.patron.update',
if ($scope.org_settings['ui.patron.edit.default_suggested'])
$scope.edit_passthru.vis_level = 1;
+
+ if ($scope.patron.isnew) {
+ $scope.generate_password();
+ $scope.hold_notify_phone = true;
+ $scope.hold_notify_email = true;
+
+ if (prs.org_settings['ui.patron.default_ident_type']) {
+ $scope.patron.ident_type =
+ prs.org_settings['ui.patron.default_ident_type'];
+ }
+ if (prs.org_settings['ui.patron.default_inet_access_level']) {
+ $scope.patron.ident_type =
+ prs.org_settings['ui.patron.default_inet_access_level'];
+ }
+ if (prs.org_settings['ui.patron.default_country']) {
+ $scope.patron.addresses[0].country =
+ prs.org_settings['ui.patron.default_country'];
+ }
+ }
+
});
// returns the tree depth of the selected profile group tree node.
$scope.replace_card = function() {
$scope.patron.card.active = false;
$scope.patron.card.ischanged = true;
+
var new_card = egCore.idl.toHash(new egCore.idl.ac());
new_card.id = new_card_id--;
new_card.isnew = true;
new_card.active = true;
- new_card._primary = true;
+ new_card._primary = 'on';
$scope.patron.card = new_card;
$scope.patron.cards.push(new_card);
}