From b6d197000576d45d9acbb63509ee85f092acf6ad Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Thu, 4 Aug 2011 18:14:00 -0400 Subject: [PATCH 1/1] Show copy status/location names in Vandelay items grid Signed-off-by: Bill Erickson Signed-off-by: Lebbeous Fogle-Weekley --- .../web/js/ui/default/vandelay/vandelay.js | 37 ++++++++++++++++++- .../default/vandelay/inc/import_errors.tt2 | 4 ++ 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/Open-ILS/web/js/ui/default/vandelay/vandelay.js b/Open-ILS/web/js/ui/default/vandelay/vandelay.js index 97be36bf03..44898bb22c 100644 --- a/Open-ILS/web/js/ui/default/vandelay/vandelay.js +++ b/Open-ILS/web/js/ui/default/vandelay/vandelay.js @@ -88,13 +88,15 @@ var vlBibSources = []; var importItemDefs = []; var matchSets = {}; var mergeProfiles = []; +var copyStatusCache = {}; +var copyLocationCache = {}; /** * Grab initial data */ function vlInit() { authtoken = openils.User.authtoken; - var initNeeded = 7; // how many async responses do we need before we're init'd + var initNeeded = 8; // how many async responses do we need before we're init'd var initCount = 0; // how many async reponses we've received openils.Util.registerEnterHandler( @@ -184,6 +186,16 @@ function vlInit() { } ); + new openils.PermaCrud().retrieveAll('ccs', + { async: true, + oncomplete: function(r) { + var stats = openils.Util.readResponse(r); + dojo.forEach(stats, function(stat){copyStatusCache[stat.id()] = stat}); + checkInitDone(); + } + } + ); + vlAttrEditorInit(); vlExportInit(); } @@ -792,6 +804,29 @@ function vlGetOrg(rowIdx, item) { return ''; } +function vlCopyStatus(rowIdx, item) { + if(!item) return ''; + var value = this.grid.store.getValue(item, this.field); + if(value) return copyStatusCache[value].name(); + return ''; +} + +// Note, we don't pre-fetch all copy locations because there could be +// a lot of them. Instead, fetch-and-cache on demand. +function vlCopyLocation(rowIdx, item) { + if(item) { + var value = this.grid.store.getValue(item, this.field); + if(value) { + if(!copyLocationCache[value]) { + copyLocationCache[value] = + new openils.PermaCrud().retrieve('acpl', value); + } + return copyLocationCache[value].name(); + } + } + return ''; +} + function vlFormatViewMatchMARC(id) { return '' + this.name + ''; diff --git a/Open-ILS/web/templates/default/vandelay/inc/import_errors.tt2 b/Open-ILS/web/templates/default/vandelay/inc/import_errors.tt2 index 5554f0006c..588260e86f 100644 --- a/Open-ILS/web/templates/default/vandelay/inc/import_errors.tt2 +++ b/Open-ILS/web/templates/default/vandelay/inc/import_errors.tt2 @@ -37,6 +37,8 @@ + + @@ -69,6 +71,8 @@ + + -- 2.43.2