LP#1638299: adjust staff-side authority browse
authorGalen Charlton <gmc@equinoxinitiative.org>
Thu, 31 Aug 2017 21:22:36 +0000 (17:22 -0400)
committerKathy Lussier <klussier@masslnc.org>
Fri, 1 Sep 2017 19:44:48 +0000 (15:44 -0400)
Now that the primary key of the authority.thesarus table
has changed from the single-character code to the LC-assigned
authority code, a bit of additional translation is required.

Signed-off-by: Galen Charlton <gmc@equinoxinitiative.org>
Signed-off-by: Kathy Lussier <klussier@masslnc.org>
Open-ILS/web/js/ui/default/cat/authority/list.js

index 17b59a8..cdafb93 100644 (file)
@@ -23,24 +23,37 @@ var auth_strings = dojo.i18n.getLocalization("openils.authority", "authority");
 var cgi = new openils.CGI();
 var pcrud = new openils.PermaCrud();
 
+var _thes_short_code_map = {
+    "a" : "lcsh",
+    "b" : "lcshac",
+    "c" : "mesh",
+    "d" : "nal",
+    "k" : "cash",
+    "r" : 'aat',
+    "s" : "sears",
+    "v" : "rvm"
+}
 var _acs_cache_by_at = {};
 function fetch_control_set(thesaurus) {
-    if (!_acs_cache_by_at[thesaurus]) {
+    var thes_code = (thesaurus in _thes_short_code_map) ?
+                        _thes_short_code_map[thesaurus] :
+                        thesaurus;
+    if (!_acs_cache_by_at[thes_code]) {
         var at = pcrud.retrieve(
-            "at", thesaurus,
+            "at", thes_code,
             {"flesh": 1, "flesh_fields": {"at": ["control_set"]}}
         );
         var cs;
-        if (at.control_set()) {
+        if (at && at.control_set()) {
             cs = at.control_set();
         } else {
             cs = new fieldmapper.acs();
             cs.name("None");    // XXX i18n
 
         }
-        _acs_cache_by_at[thesaurus] = cs;
+        _acs_cache_by_at[thes_code] = cs;
     }
-    return _acs_cache_by_at[thesaurus];
+    return _acs_cache_by_at[thes_code];
 }
 
 /*