From 340dd74e9f387207331cfc7c5941d76af4816f1d Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Sun, 13 Sep 2015 22:03:47 -0400 Subject: [PATCH] LP#1452950 patron reg initial save operation Signed-off-by: Bill Erickson Signed-off-by: Galen Charlton --- .../templates/staff/circ/patron/reg_actions.tt2 | 3 +- .../web/js/ui/default/staff/circ/patron/regctl.js | 74 +++++++++++++++++++++- 2 files changed, 75 insertions(+), 2 deletions(-) diff --git a/Open-ILS/src/templates/staff/circ/patron/reg_actions.tt2 b/Open-ILS/src/templates/staff/circ/patron/reg_actions.tt2 index 12aa57f7af..a35b949fd8 100644 --- a/Open-ILS/src/templates/staff/circ/patron/reg_actions.tt2 +++ b/Open-ILS/src/templates/staff/circ/patron/reg_actions.tt2 @@ -23,7 +23,8 @@
- + diff --git a/Open-ILS/web/js/ui/default/staff/circ/patron/regctl.js b/Open-ILS/web/js/ui/default/staff/circ/patron/regctl.js index 5fd227354f..c88dbee6e8 100644 --- a/Open-ILS/web/js/ui/default/staff/circ/patron/regctl.js +++ b/Open-ILS/web/js/ui/default/staff/circ/patron/regctl.js @@ -299,7 +299,7 @@ angular.module('egCoreMod') ); angular.forEach(patron.cards, function(card) { - card.active = card.active == 't' + card.active = card.active == 't'; if (card.id == patron.card.id) card._primary = 'on'; }); @@ -329,6 +329,74 @@ angular.module('egCoreMod') }; } + // translate the patron back into IDL form + service.save_patron = function(phash) { + + var patron = new egCore.idl.au(); + + for (var key in phash) { + if (typeof patron[key] == 'function') + patron[key](phash[key]); + } + + patron.home_ou(patron.home_ou().id()); + patron.expire_date( + patron.expire_date().toISOString().replace(/T.*/,'')); + patron.dob(patron.dob().toISOString().replace(/T.*/,'')); + patron.profile(patron.profile().id()); + patron.net_access_level(patron.net_access_level().id()); + patron.ident_type(patron.ident_type().id()); + + angular.forEach( + ['juvenile', 'barred', 'active', 'master_account'], + function(field) { patron[field](phash[field] ? 't' : 'f'); } + ); + + var card_hashes = patron.cards(); + 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'); + + if (chash._primary) { + patron.card(card); + } + }); + + var addr_hashes = patron.addresses(); + patron.addresses([]); + angular.forEach(addr_hashes, function(addr_hash) { + var addr = new egCore.idl.aua(); + patron.addresses().push(addr); + for (var key in addr_hash) { + if (typeof addr[key] == 'function') + addr[key](addr_hash[key]); + } + + addr.valid(addr.valid() ? 't' : 'f'); + addr.within_city_limits(addr.within_city_limits() ? 't' : 'f'); + if (addr_hash._is_mailing) patron.mailing_address(addr); + if (addr_hash._is_billing) patron.billing_address(addr); + }); + + egCore.net.request( + 'open-ils.actor', + 'open-ils.actor.patron.update', + egCore.auth.token(), patron) + .then(function(resp) { + // TODO: see original + console.log(js2JSON(resp)); + }); + + console.log(js2JSON(patron)); + } + return service; }]); @@ -542,6 +610,10 @@ function PatronRegCtrl($scope, $routeParams, ); } + $scope.edit_passthru.save = function() { + patronRegSvc.save_patron($scope.patron); + } + } -- 2.11.0