From: Jason Etheridge <jason@esilibrary.com>
Date: Wed, 20 Jun 2012 15:47:54 +0000 (-0400)
Subject: lp1010187 eliminate redundant/unnecessary calls
X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=8f1b529f4df744d15a7bde48d560836cb37eff69;p=evergreen%2Fmasslnc.git

lp1010187 eliminate redundant/unnecessary calls

Particularly invocations of open-ils.circ.stat_cat.asset.retrieve.all in the
Item Attribute Editor

To test:

    login with a BR1 workstation
    load a pristine (non-stat-cat-laden) BR1 item with the editor
    there should be no call to open-ils.circ.stat_cat.asset.retrieve.all
    change the Circ Lib on the item to BR4
    reload the item in the editor
    there should be a call to open-ils.circ.stat_cat.asset.retrieve.all
    reload the item in the editor
    there should be no call to open-ils.circ.stat_cat.asset.retrieve.all
    assign the item a stat cat entry owned by CONS
    reload the item in the editor
    there should be no call to open-ils.circ.stat_cat.asset.retrieve.all

Signed-off-by: Jason Etheridge <jason@esilibrary.com>
Signed-off-by: Jason Stephenson <jstephenson@mvlc.org>
---

diff --git a/Open-ILS/xul/staff_client/server/cat/copy_editor.js b/Open-ILS/xul/staff_client/server/cat/copy_editor.js
index 3e701ec6b0..6af09ce326 100644
--- a/Open-ILS/xul/staff_client/server/cat/copy_editor.js
+++ b/Open-ILS/xul/staff_client/server/cat/copy_editor.js
@@ -1675,6 +1675,9 @@ g.populate_stat_cats = function() {
             var entries = g.copies[i].stat_cat_entries();
             if (!entries) entries = [];
             for (var j = 0; j < entries.length; j++) {
+                if (typeof g.data.hash.asc[ entries[j].stat_cat() ] != 'undefined') {
+                    continue; // We already have this stat cat, so assume we have everything we need for this lib
+                }
                 var lib = entries[j].owner(); if (typeof lib == 'object') lib = lib.id();
                 sc_libs[ lib ] = true;
             }
@@ -1685,6 +1688,9 @@ g.populate_stat_cats = function() {
         sc_libs = {};
         for (var i = 0; i < g.copies.length; i++) {
             var circ_lib = g.copies[i].circ_lib(); if (typeof circ_lib == 'object') circ_lib = circ_lib.id();
+            if (typeof g.data.hash.my_aou[ circ_lib ] != 'undefined') {
+                continue; // We should already have everything we need for this lib
+            }
             sc_libs[ circ_lib ] = true;
         }
         add_common_ancestors(sc_libs);
@@ -1703,6 +1709,9 @@ g.populate_stat_cats = function() {
                     }
                 }
                 var owning_lib = g.map_acn[ cn_id ].owning_lib(); if (typeof owning_lib == 'object') owning_lib = owning_lib.id();
+                if (typeof g.data.hash.my_aou[ owning_lib ] != 'undefined') {
+                    continue; // We should already have everything we need for this lib
+                }
                 sc_libs[ owning_lib ] = true;
             }
         }