KMAIN-383 - Manage Authorities Interface - Search ID Enhancement
authorBill Erickson <berickxx@gmail.com>
Wed, 29 Oct 2014 21:06:51 +0000 (17:06 -0400)
committerBill Erickson <berickxx@gmail.com>
Thu, 21 Mar 2019 19:46:23 +0000 (15:46 -0400)
    Cross-port: 046a96d

Conflicts:
Open-ILS/src/perlmods/lib/OpenILS/Application/SuperCat.pm

13 files changed:
KCLS/openils/var/templates_kcls/cat/authority/list.tt2
KCLS/openils/var/templates_kcls/cat/authority/list_id.tt2 [new file with mode: 0644]
Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/authority.pm
Open-ILS/src/perlmods/lib/OpenILS/Application/SuperCat.pm
Open-ILS/src/perlmods/lib/OpenILS/WWW/SuperCat.pm
Open-ILS/web/js/ui/kcls/cat/authority/list_id.js [new file with mode: 0644]
Open-ILS/web/opac/locale/en-US/lang.dtd
Open-ILS/xul/staff_client/chrome/content/main/constants.js
Open-ILS/xul/staff_client/chrome/content/main/menu.js
Open-ILS/xul/staff_client/chrome/content/main/menu_frame_menus.xul
Open-ILS/xul/staff_client/chrome/content/main/menu_frame_overlay.xul
Open-ILS/xul/staff_client/chrome/locale/en-US/offline.properties
Open-ILS/xul/staff_client/chrome/skin/global.css

index 58237b6..754a847 100644 (file)
 <!-- Not currently useful - see authOUListInit() above -->
 <!--    <label for="authOU">[% l('Library: ') %]</label><select dojoType="openils.widget.OrgUnitFilteringSelect" id="authOU" name="authOU" searchAttr="shortname" labelAttr="shortname"></select> -->
 
+    <!-- Search submit button -->
     <span style="white-space: nowrap;">
+        <span dojoType="dijit.form.Button" type="button" value="Submit">[% l('Submit') %]
+            <script type="dojo/method" event="onClick" args="evt">
+                displayRecords();
+            </script>
+        </span>
+    </span>
+
+    <!-- Authority Navigation -->
+    <span style="white-space: nowrap; float: right; padding-right:25px;">
         <span dojoType="dijit.form.Button" type="button" value="Previous">[% l('Previous') %]
             <script type="dojo/method" event="onClick" args="evt">
                 displayRecords({"page":"prev"});
             </script>
         </span>
     </span>
-
-    <span style="white-space: nowrap;">
-        <span dojoType="dijit.form.Button" type="button" value="Submit">[% l('Submit') %]
-            <script type="dojo/method" event="onClick" args="evt">
-                displayRecords();
-            </script>
-        </span>
-    </span>
 </div>
 
 <hr />
diff --git a/KCLS/openils/var/templates_kcls/cat/authority/list_id.tt2 b/KCLS/openils/var/templates_kcls/cat/authority/list_id.tt2
new file mode 100644 (file)
index 0000000..855e001
--- /dev/null
@@ -0,0 +1,78 @@
+[% ctx.page_title = l('Authority record list') %]
+[% WRAPPER base.tt2 %]
+
+<script type="text/javascript" src='[% ctx.media_prefix %]/js/ui/kcls/cat/authority/list_id.js'> </script>
+<style type="text/css">
+    .authEntry { clear: both; }
+    .authEntry > *:first-child { float: left; width: 20%; }
+    .authEntry > .text { float: left; width: 46%; }
+    .authEntry > .authority-control-set { float: right; width: 16%; ; font-style: italic; }
+    .authority-control-set .acs-name { font-weight: bold; }
+    .authority-control-set .acs-id { }
+</style>
+<div dojoType="dijit.form.Form" id="myForm" jsId="myForm" encType="multipart/form-data" action="" method="">
+
+    <!-- Find by authority id field -->
+    <span style="white-space: nowrap;">
+        <label for="authTerm">[% l('Find Authority by ID: ') %]</label>
+        <input type="text" name="authTerm" value="" dojoType="dijit.form.TextBox" trim="true" id="authTerm" propercase="false"/>
+    </span>
+<!-- Not currently useful - see authOUListInit() above -->
+<!--    <label for="authOU">[% l('Library: ') %]</label><select dojoType="openils.widget.OrgUnitFilteringSelect" id="authOU" name="authOU" searchAttr="shortname" labelAttr="shortname"></select> -->
+
+    <!-- Search submit button -->
+    <span style="white-space: nowrap;">
+        <span dojoType="dijit.form.Button" type="button" value="Submit">[% l('Submit') %]
+            <script type="dojo/method" event="onClick" args="evt">
+                updateNavFromTerm();
+                displayRecords();
+            </script>
+        </span>
+    </span>
+
+    <!-- Authority Navigation -->
+    <span style="white-space: nowrap; float: right; padding-right:25px;">
+        <label for="authPage">[% l('Navigate Authority by ID: ') %]</label>
+        <input dojoType="dijit.form.TextBox" value="" id="authPage" name="authPage" style="width:5em; text-align:center;" disabled/>
+
+        <span dojoType="dijit.form.Button" type="button" value="Previous">[% l('Previous') %]
+            <script type="dojo/method" event="onClick" args="evt">
+                displayRecords({"authId":"prev"});
+            </script>
+        </span>
+
+        <span dojoType="dijit.form.Button" type="button" value="Next">[% l('Next') %]
+            <script type="dojo/method" event="onClick" args="evt">
+                displayRecords({"authId":"next"});
+            </script>
+        </span>
+    </span>
+</div>
+
+<hr />
+
+<div id='mergebox-div' class='hidden' style='float:right; border: 4px solid; width: 25%;'>
+    <div style="border-bottom: 4px solid; text-align: center;">
+        <div dojoType="dijit.form.Form" encType="multipart/form-data" action="" method="">
+            <div dojoType="dijit.form.Button" type="button" value="Merge">[% l('Merge') %]
+                <script type="dojo/method" event="onClick" args="evt">
+                    mergeRecords();
+                </script>
+            </div>
+            <div dojoType="dijit.form.Button" type="button" value="Clear">[% l('Clear') %]
+                <script type="dojo/method" event="onClick" args="evt">
+                    clearMergeRecords();
+                </script>
+            </div>
+        </div>
+    </div>
+    <table>
+        <tbody id='mergebox-tbody'>
+        </tbody>
+    </table>
+</div>
+
+
+<div id='authlist-div'></div>
+
+[% END %]
index 7a27a7f..5e4b9c9 100644 (file)
@@ -304,7 +304,42 @@ sub authority_in_db_browse_or_search {
         /,
         {}, @args
     );
+    return $list;
+}
 
+__PACKAGE__->register_method(
+    api_name   => "open-ils.storage.authority.id_find",
+    method             => "authority_id_find",
+    api_level  => 1,
+    argc        => 5,
+    signature   => {
+        desc => q/Use stored procedures to perform authorities-based
+        browses or searches/,
+        params => [
+            {name => "method", type => "string", desc => q/
+                The name of a method within the authority schema to call.  This
+                is an API call on a private service for a reason.  Do not pass
+                unfiltered user input into this API call, especially in this
+                parameter./},
+            {name => "what", type => "string", desc => q/
+                What to search. Could be an axis name, an authority tag
+                number, or a bib tag number/},
+            {name => "term", type => "string", desc => "Search term"},
+            {name => "page", type => "number", desc => "Zero-based page number"},
+            {name => "page_size", type => "number",
+                desc => "Number of records per page"}
+        ],
+        return => {
+            desc => "A list of authority record IDs",
+            type => "array"
+        }
+    }
+);
+
+sub authority_id_find {
+    my ($self, $shift, $method, @args) = @_;
+    return unless $method =~ /^\w+$/;
+    my $list = ["@args[1]"];
     return $list;
 }
 
index 2715571..40ffbbd 100644 (file)
@@ -303,17 +303,24 @@ sub generic_new_authorities_method {
     $term = naco_normalize($term);
 
     my $storage = create OpenSRF::AppSession("open-ils.storage");
-    my $list = $storage->request(
-        "open-ils.storage.authority.in_db.browse_or_search",
-        $method, $what, $term, $page, $page_size, $thesauruses
-    )->gather(1);
+    my $list;
+    if ($what eq "id") {
+        $list = $storage->request(
+            "open-ils.storage.authority.id_find",
+            $method, $what, $term, $page, $page_size
+        )->gather(1);
+    }
+    else {
+        $list = $storage->request(
+            "open-ils.storage.authority.in_db.browse_or_search",
+            $method, $what, $term, $page, $page_size, $thesauruses
+        )->gather(1);
+    }
 
     $storage->kill_me;
-
     return $list;
 }
 
-
 sub tree_walker {
     my $tree = shift;
     my $field = shift;
index b43d266..94b27b2 100644 (file)
@@ -1697,9 +1697,11 @@ sub string_browse {
     my $next = join('/', $base,$format,$axis,$site,$string,$page + 1,$page_size,$thesauruses);
 
     unless ($string and $axis and grep { $axis eq $_ } keys %browse_types) {
-        warn "something's wrong...";
-        warn " >>> format: $format -> axis: $axis -> site: $site -> string: $string -> page: $page -> page_size: $page_size ";
-        return undef;
+        unless ($axis eq "authority.id") {
+            warn "something's wrong...";
+            warn " >>> format: $format -> axis: $axis -> site: $site -> string: $string -> page: $page -> page_size: $page_size ";
+            return undef;
+        }
     }
 
     $string = decode_utf8($string);
@@ -1734,7 +1736,9 @@ sub string_browse {
     }
 
     (my $norm_format = $format) =~ s/(-full|-uris)$//o;
-
+    if($axis eq 'authority.id') {
+        $axis = 'authority.title';
+    };
     my ($header,$content) = $browse_types{$axis}{$norm_format}->($tree,$prev,$next,$format,$unapi,$base,$site);
     print $header.$content;
     return Apache2::Const::OK;
@@ -1822,7 +1826,6 @@ sub string_startwith {
     }
 
     (my $norm_format = $format) =~ s/(-full|-uris)$//o;
-
     my ($header,$content) = $browse_types{$axis}{$norm_format}->($tree,$prev,$next,$format,$unapi,$base,$site);
     print $header.$content;
     return Apache2::Const::OK;
diff --git a/Open-ILS/web/js/ui/kcls/cat/authority/list_id.js b/Open-ILS/web/js/ui/kcls/cat/authority/list_id.js
new file mode 100644 (file)
index 0000000..e28627f
--- /dev/null
@@ -0,0 +1,435 @@
+dojo.require('dijit.Dialog');
+dojo.require('dijit.form.Button');
+dojo.require('dijit.form.DropDownButton');
+dojo.require('dijit.form.FilteringSelect');
+dojo.require('dijit.form.Form');
+dojo.require('dijit.form.NumberSpinner');
+dojo.require('dijit.form.TextBox');
+dojo.require("dijit.Menu");
+dojo.require("dijit.MenuItem");
+dojo.require('dojox.xml.parser');
+dojo.require('DojoSRF');
+dojo.require("fieldmapper.Fieldmapper");
+dojo.require('openils.CGI');
+dojo.require('openils.PermaCrud');
+dojo.require('openils.XUL');
+dojo.require('openils.widget.OrgUnitFilteringSelect');
+dojo.require("openils.widget.PCrudAutocompleteBox");
+dojo.require("MARC.FixedFields");
+dojo.requireLocalization("openils.authority", "authority");
+var auth_strings = dojo.i18n.getLocalization("openils.authority", "authority");
+
+var cgi = new openils.CGI();
+var pcrud = new openils.PermaCrud();
+
+var _acs_cache_by_at = {};
+function fetch_control_set(thesaurus) {
+    if (!_acs_cache_by_at[thesaurus]) {
+        var at = pcrud.retrieve(
+            "at", thesaurus,
+            {"flesh": 1, "flesh_fields": {"at": ["control_set"]}}
+        );
+        var cs;
+        if (at.control_set()) {
+            cs = at.control_set();
+        } else {
+            cs = new fieldmapper.acs();
+            cs.name("None");    // XXX i18n
+
+        }
+        _acs_cache_by_at[thesaurus] = cs;
+    }
+    return _acs_cache_by_at[thesaurus];
+}
+
+/*
+// OrgUnits do not currently affect the retrieval of authority records,
+// but this is how to display them if they become OrgUnit-aware
+function authOUListInit() {
+    new openils.User().buildPermOrgSelector(
+        "STAFF_LOGIN", // anywhere you can log in
+        dijit.byId("authOU"),
+        null, // pre-selected org
+        null
+    );
+}
+dojo.addOnLoad(authOUListInit);
+*/
+function displayAuthorities(data) {
+    var idArr = [];
+    var foundOne = 0;
+    
+    // Grab each record from the returned authority records
+    dojo.query("record", data).forEach(function(node) {
+        foundOne = 1;
+        var auth = {};
+        auth.text = '';
+        auth.thesaurus = '|';
+        auth.id = 0;
+        auth.expand = '';
+
+        // Grab each authority record field from the authority record
+        dojo.query("datafield[tag^='1']", node).forEach(function(dfNode) {
+            auth.text += dojox.xml.parser.textContent(dfNode);
+            auth.name = dojo.attr(dfNode, 'tag');
+            auth.ind1 = dojo.attr(dfNode, 'ind1');
+            auth.ind2 = dojo.attr(dfNode, 'ind2');
+        });
+
+        // Grab the ID of the authority record
+        dojo.query("datafield[tag='901']", node).query("subfield[code='c']").forEach(function(dfNode) {
+            auth.id = dojox.xml.parser.textContent(dfNode);
+        });
+
+        /* I wrap this in try/catch only because:
+         *  a) this interface hasn't hitherto relied on MARC.Record, and
+         *  b) the functionality we need it for is optional
+         */
+        try {
+            var marc = new MARC.Record({"rtype": "AUT", "xml": node});
+            auth.thesaurus = marc.extractFixedField("Subj", "|");
+        } catch (E) {
+            console.warn(
+                "MARC.Record didn't work for authority record " +
+                auth.id + ": " + E
+            );
+        }
+
+        idArr.push(parseInt(auth.id));
+
+        // Create the authority record listing entry. XXX i18n
+        dojo.place(
+            '<div class="authEntry" id="auth' + auth.id + '">' +
+            '<div class="text" id="authLabel' + auth.id + '">' +
+            '<span class="text">' + auth.text + '</span></div><div class="authority-control-set"><span>ID: ' +
+            auth.id + '</span></div>' +
+            '<div class="authority-control-set">Control Set: <span class="acs-name">' +
+            fetch_control_set(auth.thesaurus).name() +
+            '</span> <span class="acs-id">(#' +
+            fetch_control_set(auth.thesaurus).id() + ')</span></div>',
+            "authlist-div", "last"
+        );
+
+        // Add the menu of new/edit/delete/mark-for-merge options
+        var auth_menu = new dijit.Menu({});
+
+        // "Edit" menu item
+        new dijit.MenuItem({"id": "edit_" + auth.id, "onClick": function(){
+            var auth_rec = pcrud.retrieve("are", auth.id);
+            if (auth_rec) {
+                loadMarcEditor(pcrud, auth_rec);
+            }
+        }, "label":auth_strings.MENU_EDIT}).placeAt(auth_menu, "first");
+
+        // "Merge" menu item
+        new dijit.MenuItem({"id": "merge_" + auth.id, "onClick":function(){
+            auth.text = '';
+            dojo.query('#auth' + auth.id).query('span.text').forEach(function(node) {
+                auth.text += dojox.xml.parser.textContent(node);
+            });
+
+            // If there is a toMerge item already, this is a target record
+            var mergeRole = '<td style="border: 1px solid black; padding-left: 0.5em; padding-right: 1em;">';
+            var isTarget = dojo.query('.toMerge').length;
+            if (isTarget) {
+                mergeRole += auth_strings.TARGET_RECORD + '</td>';
+            } else {
+                mergeRole += auth_strings.MASTER_RECORD + '</td>';
+            }
+
+            dojo.place('<tr class="toMerge" id="toMerge_' + auth.id + '"><td>' + mergeRole + '</td><td  style="border: 1px solid black;" id="mergeMeta_' + auth.id + '"></td><td style="border: 1px solid black; padding-left: 1em; padding-right: 1em;" >' + auth.text + '</td></tr>', 'mergebox-tbody', 'last');
+            dojo.place('<span class="authmeta" style="font-family: monospace;">' + auth.name + ' ' + auth.ind1 + auth.ind2 + '</span>', 'mergeMeta_' + auth.id, 'last');
+            dojo.removeClass('mergebox-div', 'hidden');
+        }, "label":auth_strings.MENU_MERGE}).placeAt(auth_menu, "last");
+
+        // "Delete" menu item
+        new dijit.MenuItem({
+            "id": "delete_" + auth.id,
+            "onClick":function(){
+                auth.text = '';
+
+                var auth_rec = pcrud.retrieve("are", auth.id);
+
+                // Bit of a hack to get the linked bib count until an explicit ID
+                var linkedBibs = dojox.xml.parser.textContent(
+                    dojo.query("#authLabel" + auth.id)[0].previousSibling
+                );
+
+                var delDlg = dijit.byId("delDialog_" + auth.id);
+
+                dojo.query('#auth' + auth.id).query('span.text').forEach(function(node) {
+                    auth.text += dojo.trim(dojox.xml.parser.textContent(node));
+                });
+
+                if (!delDlg) {
+                    var content = '<div>' + dojo.string.substitute(auth_strings.CONFIRM_DELETE_TITLE, [auth.text]) + '</div>';
+                    if (parseInt(linkedBibs) > 0) {
+                        content = "<div id='delAuthSum_" + auth.id + "'>"
+                            + dojo.string.substitute(auth_strings.LINKED_BIBS, [linkedBibs])
+                            + "</div>";
+                    }
+                    content += "<div id='authMARC" + auth.id + "' style='width: 100%; display:none;'>";
+                    content += "<hr style='width: 100%;' />";
+                    content += marcToHTML(auth_rec.marc());
+                    content += "</div><hr style='width: 100%;' /><div>";
+                    content += "<input type='button' dojoType='dijit.form.Button' label='" + auth_strings.CANCEL + "' onClick='cancelDelete(" + auth.id + ")'/>";
+                    content += "<input type='button' dojoType='dijit.form.Button' label='" + auth_strings.DELETE + "' onClick='confirmDelete(" + auth.id + ")'/>";
+                    content += "<input id='viewMARC" + auth.id + "' type='button' "
+                        + "style='float:right;' dojoType='dijit.form.Button' "
+                        + "label='" + auth_strings.VIEW_MARC + "' onClick='viewMARC(" + auth.id + ")'/>";
+                    content += "<input id='hideMARC" + auth.id + "' type='button' "
+                        + "style='display: none; float:right;' dojoType='dijit.form.Button' "
+                        + "label='" + auth_strings.HIDE_MARC + "' onClick='hideMARC(" + auth.id + ")'/>";
+                    content += "</div>";
+                    delDlg = new dijit.Dialog({
+                        "id":"delDialog_" + auth.id,
+                        "title": dojo.string.substitute(auth_strings.CONFIRM_DELETE_PROMPT, [auth.id]),
+                        "content": content
+                    });
+                }
+                delDlg.show();
+
+        }, "label":auth_strings.DELETE}).placeAt(auth_menu, "last");
+
+        auth_mb = new dijit.form.DropDownButton({dropDown: auth_menu, label: auth_strings.ACTIONS, id:"menu" + auth.id});
+        auth_mb.placeAt(dojo.create("div", null, "auth" + auth.id, "first"), "first");
+        auth_menu.startup();
+    });
+
+    showBibCount(idArr);
+    if (foundOne == 0) {
+        window.alert("No Authority Record was found. \nPlease enter a valid Authority ID.");
+    }
+}
+
+function viewMARC(recId) {
+    dojo.style(dojo.byId("authMARC" + recId), 'display', 'block');
+    dojo.style(dijit.byId("viewMARC" + recId).domNode, 'display', 'none');
+    dojo.style(dijit.byId("hideMARC" + recId).domNode, 'display', 'block');
+}
+
+function hideMARC(recId) {
+    dojo.style(dojo.byId("authMARC" + recId), 'display', 'none');
+    dojo.style(dijit.byId("hideMARC" + recId).domNode, 'display', 'none');
+    dojo.style(dijit.byId("viewMARC" + recId).domNode, 'display', 'block');
+}
+
+function marcToHTML(marc) {
+    var html = '<table><tbody>';
+    marc = dojox.xml.parser.parse(marc);
+    dojo.query('leader', marc).forEach(function(node) {
+        html += '<tr><td>LDR</td><td>&nbsp;</td><td>&nbsp;</td><td>' + dojox.xml.parser.textContent(node) + '</td></tr>';
+    });
+    dojo.query('controlfield', marc).forEach(function(node) {
+        html += '<tr><td>' + dojo.attr(node, "tag") + '</td><td>&nbsp;</td><td>&nbsp;</td><td>' + dojox.xml.parser.textContent(node) + '</td></tr>';
+    });
+    dojo.query('datafield', marc).forEach(function(node) {
+        var cnt = 0;
+        html += '<tr><td>' + dojo.attr(node, "tag") + '</td><td>' + dojo.attr(node, "ind1") + '</td><td>' + dojo.attr(node, "ind2") + '</td>';
+        dojo.query('subfield', node).forEach(function(sf) {
+            if (cnt == 0) {
+                html += '<td>$' + dojo.attr(sf, "code") + ' ' + dojox.xml.parser.textContent(sf) + '</td></tr>';
+                cnt = 1;
+            } else {
+                html += '<tr><td colspan="3"></td><td>$' + dojo.attr(sf, "code") + ' ' + dojox.xml.parser.textContent(sf) + '</td></tr>';
+            }
+        });
+    });
+    html += '</tbody></table>';
+    return html;
+}
+
+function cancelDelete(recId) {
+    dijit.byId("delDialog_" + recId).hide();
+}
+
+function confirmDelete(recId) {
+    var auth_rec = pcrud.retrieve("are", recId);
+    if (auth_rec) {
+        pcrud.eliminate(auth_rec);
+        dijit.byId("delDialog_" + recId).attr("content", dojo.string.substitute(auth_strings.CONFIRM_DELETE_RESULT, [recId]));
+        setTimeout(function() {
+            dijit.byId("delDialog_" + recId).hide();
+        }, 3000);
+    }
+}
+
+function showBibCount(authIds) {
+    /* Decorate the list with # of bibs linked to each authority record */
+    var ses = new OpenSRF.ClientSession('open-ils.cat');
+    var req = ses.request('open-ils.cat.authority.records.count_linked_bibs', authIds);
+    var linkedIds = [];
+    req.oncomplete = function(r) {
+        var msg = r.recv().content();
+        dojo.forEach(msg, function(auth) {
+                linkedIds.push(auth.authority);
+                dojo.place('<span class="bibcount">' + auth.bibs + '</span> ', 'authLabel' + auth.authority, 'first');
+            }
+        );
+
+        /* Assign counts of 0 for every non-linked authority */
+        dojo.forEach(authIds, function (id) {
+            var found = false;
+            dojo.forEach(linkedIds, function (lid) {
+                if (id == lid) {
+                    found = true;
+                }
+            });
+            if (!found) {
+                dojo.place('<span class="bibcount">0</span> ', 'authLabel' + id, 'first');
+            }
+        });
+    }
+    req.send();
+}
+
+function loadMarcEditor(pcrud, rec) {
+
+    /* Prevent the spawned MARC editor from making its title bar inaccessible */
+    var initHeight = self.outerHeight - 40;
+    /* Setting an explicit height results in a super skinny window, so fix that up */
+    var initWidth = self.outerWidth / 2;
+
+    /*
+       To run in Firefox directly, must set signed.applets.codebase_principal_support
+       to true in about:config
+     */
+    win = window.open('/xul/server/cat/marcedit.xul','',    // XXX version?
+        'chrome,resizable=yes,height=' + initHeight + ',width=' + initWidth);
+
+    win.xulG = {
+        "record": {"marc": rec.marc(), "rtype": "are"},
+        "save": {
+            "label": auth_strings.SAVE,
+            "func": function(xmlString) {
+                rec.marc(xmlString);
+                rec.edit_date('now');
+                rec.ischanged(true);
+                pcrud.update(rec);
+                alert(auth_strings.SAVE_RESULT_SUCCESS);
+                win.close();
+            }
+        },
+        'lock_tab' : typeof xulG != 'undefined' ? (typeof xulG['lock_tab'] != 'undefined' ? xulG.lock_tab : undefined) : undefined,
+        'unlock_tab' : typeof xulG != 'undefined' ? (typeof xulG['unlock_tab'] != 'undefined' ? xulG.unlock_tab : undefined) : undefined
+    };
+}
+
+function authListInit() {
+    var term = cgi.param('authTerm') || 0;
+    var page = cgi.param('authPage') || 0;
+
+    if (page) {
+        dijit.byId('authPage').attr('value', page);
+    }
+    if (term) {
+        dijit.byId('authTerm').attr('value', term);
+        displayRecords();
+    }
+
+    dojo.connect(dijit.byId('authPage'), 'onKeyPress', function(evt) {
+        if (evt.keyCode == dojo.keys.ENTER) {
+            dijit.byId('authPage').attr('value', dijit.byId('authTerm').attr('value'));
+            displayRecords();
+        }
+    });
+
+    dojo.connect(dijit.byId('authTerm'), 'onKeyPress', function(evt) {
+        if (evt.keyCode == dojo.keys.ENTER) {
+            dijit.byId('authPage').attr('value', dijit.byId('authTerm').attr('value'));
+            displayRecords();
+        }
+    });
+
+    dijit.byId('authTerm').focus();
+
+}
+dojo.addOnLoad(authListInit);
+
+function updateNavFromTerm() {
+    dijit.byId('authPage').attr('value', dijit.byId('authTerm').attr('value'));
+}
+
+function displayRecords(parms) {
+
+    if (parms && parms.page) {
+        if (parms.page == 'next') {
+            page = dijit.byId('authPage').attr('value');
+            dijit.byId('authPage').attr('value', page + 1);
+        } else if (parms.page == 'prev') {
+            page = dijit.byId('authPage').attr('value');
+            dijit.byId('authPage').attr('value', page - 1);
+        } else {
+            dijit.byId('authPage').attr('value', parms.page);
+        }
+    }
+
+    if (parms && parms.authId) {
+        if (parms.authId == 'next') {
+            term = dijit.byId('authTerm').attr('value');
+            term++;
+            dijit.byId('authTerm').attr('value', term);
+            dijit.byId('authPage').attr('value', term);
+        } else if (parms.authId == 'prev') {
+            term = dijit.byId('authTerm').attr('value');
+            term--;
+            dijit.byId('authTerm').attr('value', term);
+            dijit.byId('authPage').attr('value', term);
+        } else {
+            dijit.byId('authTerm').attr('value', parms.authId);
+            dijit.byId('authPage').attr('value', parms.authId);
+        }
+    }
+
+    /* Protect against null input */
+    if (!dijit.byId('authTerm').attr('value')) {
+        window.alert ("Please enter a valid Authority ID.");
+        return;
+    }
+
+    /* Verify that Authority ID is a number */
+    if(!dijit.byId('authTerm').attr('value').match(/^\d+$/)) {
+        window.alert ("Invalid Authority ID entered. \n Please enter a valid Authority ID.");
+        return;
+    }
+
+    /* Clear out the current contents of the page */
+    var widgets = dijit.findWidgets(dojo.byId('authlist-div'));
+    dojo.forEach(widgets, function(w) { w.destroyRecursive(true); });
+
+    dojo.query("#authlist-div").query("div").orphan();
+
+    var url = '/opac/extras/browse/marcxml/authority.id'
+        // + '/' + dijit.byId('authOU').attr('value')
+        + '/1' // replace with preceding line if OUs gain some meaning
+        + '/' + dijit.byId('authTerm').attr('value')
+        + '/' + dijit.byId('authPage').attr('value')
+        + '/' + '20' // 20 results per page
+    ;
+    dojo.xhrGet({"url":url, "handleAs":"xml", "content":{"format":"marcxml"}, "preventCache": true, "load":displayAuthorities });
+}
+
+function clearMergeRecords() {
+    var records = dojo.query('.toMerge').orphan();
+    dojo.addClass('mergebox-div', 'hidden');
+}
+
+function mergeRecords() {
+    var records = dojo.query('.toMerge').attr('id');
+    dojo.forEach(records, function(item, idx) {
+        records[idx] = parseInt(item.slice(item.lastIndexOf('_') + 1));
+    });
+
+    /* Take the first record in the list and use that as the master */
+    fieldmapper.standardRequest(
+        ['open-ils.cat', 'open-ils.cat.authority.records.merge'],
+        {   async: false,
+            params: [openils.User.authtoken, records.shift(), records],
+            oncomplete : function(r) {
+                alert(auth_strings.MERGE_RESULT_SUCCESS);
+                clearMergeRecords();
+                displayRecords();
+            }
+        }
+    );
+}
index b755ef9..512b3d5 100644 (file)
 <!ENTITY staff.main.button_bar.hotkeys_toggle "Toggle Hotkeys">
 <!ENTITY staff.main.button_bar.create_marc "Create MARC Record">
 <!ENTITY staff.main.button_bar.authority_manage "Manage Authorities">
+<!ENTITY staff.main.button_bar.find_authority_by_id "Find Authority by ID">
 <!ENTITY staff.main.button_bar.retrieve_last_record "Retrieve Last Record">
 <!ENTITY staff.main.menu.acquisitions.accesskey "q">
 <!ENTITY staff.main.menu.acquisitions.label "Acquisitions">
 <!ENTITY staff.main.menu.cat.add_volume.label "Add Volume">
 <!ENTITY staff.main.menu.cat.authority_manage.accesskey "t">
 <!ENTITY staff.main.menu.cat.authority_manage.label "Manage Authorities">
+<!ENTITY staff.main.menu.cat.find_authority_by_id.accesskey "F">
+<!ENTITY staff.main.menu.cat.find_authority_by_id.label "Find Authority by ID">
 <!ENTITY staff.main.menu.cat.bib_search.accesskey "S">
 <!ENTITY staff.main.menu.cat.bib_search.label "Search the Catalog">
 <!ENTITY staff.main.menu.cat.bib_status.key "B">
index 5b465a4..b741282 100644 (file)
@@ -400,6 +400,7 @@ var urls = {
     'AUDIO_event_ASSET_COPY_NOT_FOUND' : '/xul/server/skin/media/audio/redalert.wav',
 
     'AUTHORITY_MANAGE' : 'cat/authority/list',
+    'FIND_AUTHORITY_BY_ID' : 'cat/authority/list_id',
     'MANAGE_MULTI_HOME_ITEMS' : 'oils://remote/xul/server/cat/manage_multi_home_items.xul',
     'XUL_AUTH_SIMPLE' : 'oils://remote/xul/server/main/simple_auth.xul',
     'XUL_BIB_BRIEF' : 'oils://remote/xul/server/cat/bib_brief.xul',
index 65af057..67c7ef6 100644 (file)
@@ -1394,6 +1394,17 @@ main.menu.prototype = {
                 }
             ],
 
+            'cmd_find_authority_by_id' : [
+                ['oncommand'],
+                function(event) {
+                    open_eg_web_page(
+                        urls.FIND_AUTHORITY_BY_ID,
+                        "menu.cmd_find_authority_by_id.tab",
+                        event
+                    );
+                }
+            ],
+
             'cmd_marc_batch_edit' : [
                 ['oncommand'],
                 function(event) {
index ca21c6c..b333d0d 100644 (file)
@@ -26,6 +26,7 @@
     <command id="cmd_cat_main" />
     <command id="cmd_create_marc" />
     <command id="cmd_authority_manage" />
+    <command id="cmd_find_authority_by_id" />
     <command id="cmd_url_verify" />
     <command id="cmd_circ_checkout" />
     <command id="cmd_patron_search" />
         <menuitem label="&staff.main.menu.cat.retrieve_last_record.label;" accesskey="&staff.main.menu.cat.retrieve_last_record.accesskey;" command="cmd_retrieve_last_record"/>
         <menuseparator />
         <menuitem label="&staff.main.menu.cat.authority_manage.label;" accesskey="&staff.main.menu.cat.authority_manage.accesskey;" command="cmd_authority_manage"/>
+        <menuitem label="&staff.main.menu.cat.find_authority_by_id.label;" accesskey="&staff.main.menu.cat.find_authority_by_id.accesskey;" command="cmd_find_authority_by_id"/>
         <menuseparator />
         <menuitem label="&staff.main.menu.cat.url_verify.label;" accesskey="&staff.main.menu.cat.url_verify.accesskey;" command="cmd_url_verify"/>
     </menupopup>
index c96cefc..3b0fed9 100644 (file)
         label="&staff.main.button_bar.authority_manage;"
         tooltiptext="&staff.main.button_bar.authority_manage;" />
     <toolbarbutton
+        templateid="find_authority_by_id"
+        command="cmd_find_authority_by_id"
+        label="&staff.main.button_bar.find_authority_by_id;"
+        tooltiptext="&staff.main.button_bar.find_authority_by_id;" />
+    <toolbarbutton
         templateid="retrieve_last_record"
         command="cmd_retrieve_last_record"
         label="&staff.main.button_bar.retrieve_last_record;"
index d75651e..ae58e5d 100644 (file)
@@ -260,6 +260,7 @@ menu.cmd_server_admin_conify_remote_account.tab=Remote Accounts
 menu.cmd_booking_pull_list.tab=Booking Pull List
 menu.cmd_booking_capture.tab=Booking Capture
 menu.cmd_authority_manage.tab=Manage Authorities
+menu.cmd_find_authority_by_id.tab=Find Authority by ID
 menu.cmd_search_prefs.tab=Search Preferences
 menu.local_admin.barcode_completion.tab=Barcode Completion
 menu.local_admin.circ_matrix_matchpoint.tab=Circulation Policies
index bcd6961..6514dcf 100644 (file)
@@ -161,4 +161,5 @@ help { -moz-binding: url('chrome://open_ils_staff_client/content/main/bindings.x
 /* Temp icons because tsbere is lazy - Someone please find/make new ones ;) */
 #main_toolbox toolbarbutton[command="cmd_create_marc"] { list-style-image: url("chrome://open_ils_staff_client/skin/media/images/HILLBLU_indici_toolbar.png"); }
 #main_toolbox toolbarbutton[command="cmd_authority_manage"] { list-style-image: url("chrome://open_ils_staff_client/skin/media/images/HILLBLU_indici_toolbar.png"); }
+#main_toolbox toolbarbutton[command="cmd_find_authority_by_id"] { list-style-image: url("chrome://open_ils_staff_client/skin/media/images/HILLBLU_indici_toolbar.png"); }
 #main_toolbox toolbarbutton[command="cmd_retrieve_last_record"] { list-style-image: url("chrome://open_ils_staff_client/skin/media/images/HILLBLU_indici_toolbar.png"); }