lp1010187 eliminate redundant/unnecessary calls collab/phasefx/item_editor_stat_cats
authorJason Etheridge <jason@esilibrary.com>
Wed, 20 Jun 2012 15:47:54 +0000 (11:47 -0400)
committerJason Etheridge <jason@esilibrary.com>
Wed, 20 Jun 2012 15:47:54 +0000 (11:47 -0400)
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>
Open-ILS/xul/staff_client/server/cat/copy_editor.js

index f4af660..9acd687 100644 (file)
@@ -1632,6 +1632,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;
             }
@@ -1642,6 +1645,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);
@@ -1660,6 +1666,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;
             }
         }