From: Bill Erickson Date: Fri, 1 Apr 2016 00:35:00 +0000 (-0400) Subject: LP#1564685 Avoid referencing out-of-scope stat cats X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=f25e0567bda92cc0e635cd427bd27ceb4328c957;p=evergreen%2Ftadl.git LP#1564685 Avoid referencing out-of-scope stat cats Fixes a bug in the patron editor where out-of-scope stat cats would be incorrectly bundled in the patron save operation, resulting in a server-side error on save. In short, ignore out-of-scope stat cat entries for patrons in the editor. Signed-off-by: Bill Erickson Signed-off-by: Kathy Lussier Signed-off-by: Galen Charlton --- 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 106bdb09c0..437c4019c2 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 @@ -611,6 +611,19 @@ angular.module('egCoreMod') angular.forEach(patron.addresses, function(addr) { service.ingest_address(patron, addr) }); + // Remove stat cat entries that link to out-of-scope stat + // cats. With this, we avoid unnecessarily updating (or worse, + // modifying) stat cat values that are not ours to modify. + patron.stat_cat_entries = patron.stat_cat_entries.filter( + function(map) { + return Boolean( + // service.stat_cats only contains in-scope stat cats. + service.stat_cats.filter(function(cat) { + return (cat.id() == map.stat_cat.id) })[0] + ); + } + ); + // toss entries for existing stat cat maps into our living // stat cat entry map, which is modified within the template. angular.forEach(patron.stat_cat_entries, function(map) {