Z3950 Batch : xul dialog
authorBill Erickson <berick@esilibrary.com>
Tue, 19 Feb 2013 22:55:28 +0000 (17:55 -0500)
committerBill Erickson <berick@esilibrary.com>
Tue, 19 Feb 2013 22:55:28 +0000 (17:55 -0500)
Signed-off-by: Bill Erickson <berick@esilibrary.com>
Open-ILS/xul/staff_client/server/cat/bucketz39_dialog.js
Open-ILS/xul/staff_client/server/cat/bucketz39_dialog_overlay.xul
Open-ILS/xul/staff_client/server/cat/record_buckets.js

index 5845811..66e98d6 100644 (file)
@@ -2,6 +2,9 @@ var dialog;
 
 function Bucketz39Dialog() {
 
+    /**
+     * builds the  Z39 sources and Z39 search indexes grid
+    */
     this._build_options_grid = function(list, key, id_attr, label_attr) {
 
         // determine the number of columns per row dynamically
@@ -26,6 +29,9 @@ function Bucketz39Dialog() {
         });
     }
 
+    /**
+     * Fetches needed data
+     */
     this.init = function() {
         var self = this;
         var pcrud = new OpenSRF.ClientSession('open-ils.pcrud');
@@ -35,7 +41,7 @@ function Bucketz39Dialog() {
             method : 'open-ils.pcrud.search.vbq.atomic',
             params : [
                 this.authtoken, 
-                {owner : this.user_id}, 
+                {owner : this.user_id, queue_type : 'bib'}, 
                 {order_by : {vbq : 'name'}}
             ],
             oncomplete : function(r) {
@@ -79,6 +85,65 @@ function Bucketz39Dialog() {
                     'source_selector', 'name', 'label');
             }
         }).send();
+
+        pcrud.request({
+            method : 'open-ils.pcrud.search.vms.atomic',
+            params : [this.authtoken, {
+                owner : this._ws_ancestors(),
+                mtype : 'biblio'
+            }],
+            oncomplete : function(r) {
+                var sets = r.recv().content();
+                dojo.forEach(sets, function(set) {
+                    var attrs = {label : set.name(), value : set.id() };
+                    var item = dojo.create('menuitem', attrs);
+                    dojo.byId('match_set_selector').appendChild(item);
+                });
+            }
+        }).send();
+
+    }
+
+    /* my workstation org unit plus ancestors as a flat list */
+    this._ws_ancestors = function() {
+        JSAN.use('OpenILS.data');
+        var data = new OpenILS.data(); 
+        data.stash_retrieve();
+        var org = data.hash.aou[ this.ws_ou ]
+        var org_list = [];
+
+        while (org) {
+            org_list.push(org.id());
+            org = data.hash.aou[org.parent_ou()];
+        }
+        return org_list;
+    }
+
+    /**
+     * extracts params from UI form elements
+     */
+    this._collect_params = function() {
+
+        // request params
+        var params = [this.authtoken, this.bucket_id];
+
+        // Z39 sources
+        params.push(dojo.query('[source_selector]').filter(
+            function(cbox) { return cbox.checked }).map(
+                function(cbox) { return cbox.getAttribute('value') }));
+
+        // indexes
+        params.push(dojo.query('[index_selector]').filter(
+            function(cbox) { return cbox.checked }).map(
+                function(cbox) { return cbox.getAttribute('value') }));
+
+        // queue name / match set
+        params.push({
+            queue_name : dojo.byId('queue_selector').parentNode.value,
+            match_set : dojo.byId('match_set_selector').parentNode.value
+        });
+
+        return params;
     }
 
     this.submit = function() {
@@ -98,24 +163,7 @@ function Bucketz39Dialog() {
             function(row) { dojo.removeClass(row, 'hideme') }
         );
 
-        
-        // request params
-        var params = [this.authtoken, this.bucket_id];
-
-        // Z39 sources
-        params.push(dojo.query('[source_selector]').filter(
-            function(cbox) { return cbox.checked }).map(
-                function(cbox) { return cbox.getAttribute('value') }));
-
-        // indexes
-        params.push(dojo.query('[index_selector]').filter(
-            function(cbox) { return cbox.checked }).map(
-                function(cbox) { return cbox.getAttribute('value') }));
-
-        // queue name
-        params.push({queue_name : 
-            dojo.byId('queue_selector').parentNode.value});
-
+        var params = this._collect_params();
         dump('Submitting z39 search with: ' + js2JSON(params) + '\n');
 
         var ses = new OpenSRF.ClientSession('open-ils.search');
@@ -149,6 +197,7 @@ function my_init() {
     dialog = new Bucketz39Dialog();
     dialog.user_id   = window.arguments[0];
     dialog.authtoken = window.arguments[1];
-    dialog.bucket_id = window.arguments[2];
+    dialog.ws_ou     = window.arguments[2];
+    dialog.bucket_id = window.arguments[3];
     dialog.init();
 }
index 734e397..aa16378 100644 (file)
                             </menupopup>
                         </menulist>
                     </row>
+                    <row style='border-bottom:1px solid black; padding:5px;'>
+                        <label class='header' value="Match Set:"/>
+                        <menulist>
+                            <menupopup id='match_set_selector'>
+                                <menuitem value='' label='-- Select Match Set --'/>
+                            </menupopup>
+                        </menulist>
+                    </row>
+
                     <row style='padding:5px;' id='search-submit-row'>
                         <button oncommand="window.close();" 
                             icon="remove" accesskey="C" label="Cancel" />  
index c437387..df83602 100644 (file)
@@ -848,6 +848,7 @@ cat.record_buckets.prototype = {
                                     "width=800,height=400",
                                     obj.data.list.au[0].id(),
                                     ses(), 
+                                    ses('ws_ou'),
                                     bucket_id
                                 );
                             } catch(E) {