3 function Bucketz39Dialog() {
6 * builds the Z39 sources and Z39 search indexes grid
8 this._build_options_grid = function(list, key, id_attr, label_attr) {
10 // determine the number of columns per row dynamically
11 var grid = dojo.byId(key).parentNode;
12 var colcount = grid.getElementsByTagName('column').length;
15 dojo.forEach(list, function(obj, idx) {
17 if (idx % colcount == 0) {
18 row = dojo.create('row');
19 dojo.byId(key).appendChild(row);
23 value : obj[id_attr](),
24 label : obj[label_attr]()
28 row.appendChild(dojo.create('checkbox', attrs));
35 this.init = function() {
37 var pcrud = new OpenSRF.ClientSession('open-ils.pcrud');
41 method : 'open-ils.pcrud.search.vbq.atomic',
44 {owner : this.user_id, queue_type : 'bib'},
45 {order_by : {vbq : 'name'}}
47 oncomplete : function(r) {
48 if (resp = r.recv()) {
49 var qlist = resp.content();
50 dojo.forEach(qlist, function(q) {
51 var attrs = {label : q.name()};
52 var item = dojo.create('menuitem', attrs);
53 dojo.byId('queue_selector').appendChild(item);
59 // z39 index field maps
61 method : 'open-ils.pcrud.search.czifm.atomic',
65 {order_by : {czifm : 'label'}}
67 oncomplete : function(r) {
68 self._build_options_grid(
70 'index_selector', 'id', 'label');
76 method : 'open-ils.pcrud.search.czs.atomic',
79 {name : {'!=' : null}},
80 {order_by : {czs : 'name'}}
82 oncomplete : function(r) {
83 self._build_options_grid(
85 'source_selector', 'name', 'label');
90 method : 'open-ils.pcrud.search.vms.atomic',
91 params : [this.authtoken, {
92 owner : this._ws_ancestors(),
95 oncomplete : function(r) {
96 var sets = r.recv().content();
97 dojo.forEach(sets, function(set) {
98 var attrs = {label : set.name(), value : set.id() };
99 var item = dojo.create('menuitem', attrs);
100 dojo.byId('match_set_selector').appendChild(item);
107 /* my workstation org unit plus ancestors as a flat list */
108 this._ws_ancestors = function() {
109 JSAN.use('OpenILS.data');
110 var data = new OpenILS.data();
111 data.stash_retrieve();
112 var org = data.hash.aou[ this.ws_ou ]
116 org_list.push(org.id());
117 org = data.hash.aou[org.parent_ou()];
123 * extracts params from UI form elements
125 this._collect_params = function() {
128 var params = [this.authtoken, this.bucket_id];
131 params.push(dojo.query('[source_selector]').filter(
132 function(cbox) { return cbox.checked }).map(
133 function(cbox) { return cbox.getAttribute('value') }));
136 params.push(dojo.query('[index_selector]').filter(
137 function(cbox) { return cbox.checked }).map(
138 function(cbox) { return cbox.getAttribute('value') }));
141 // queue name (editable menulist)
142 queue_name : dojo.byId('queue_selector').parentNode.value,
144 match_set : dojo.byId('match_set_selector').parentNode.value
150 this.submit = function() {
154 this.search_bib_count = dojo.byId('search-bib-count');
155 this.search_queue_count = dojo.byId('search-queue-count');
156 this.search_progress = dojo.byId('search-progress');
159 dojo.addClass(dojo.byId('search-submit-row'), 'hideme');
161 // show progress rows
163 dojo.query('.search_result_row'),
164 function(row) { dojo.removeClass(row, 'hideme') }
167 var params = this._collect_params();
168 dump('Submitting z39 search with: ' + js2JSON(params) + '\n');
170 var ses = new OpenSRF.ClientSession('open-ils.search');
172 method : 'open-ils.search.z3950.bucket_search_queue',
174 onresponse : function(r) {
177 var stat = resp.content();
179 dojo.attr(self.search_bib_count, 'value', ''+stat.bre_count);
180 dojo.attr(self.search_queue_count, 'value', ''+stat.queue_count);
182 var scount = Number(stat.search_count);
184 dojo.attr(self.search_progress, 'value', ''+Math.floor(
185 (Number(stat.search_complete) / scount) * 100
189 // queue object is returned in the final response
190 self.queue = stat.queue;
192 oncomplete : function() {
193 dojo.removeClass(dojo.byId('final-actions-row'), 'hideme');
198 // Open a new XUL tab focused on the Vandelay queue containing the results.
199 this.open_queue = function() {
201 labelKey = labelKey || 'menu.cmd_open_conify.tab';
202 var label = offlineStrings.getString(labelKey);
204 var label = 'MARC Import/Export'; // TODO
208 var url_prefix = this.xulG.url_prefix || window.url_prefix;
210 var urls = this.xulG.urls || window.urls;
211 var loc = urls.XUL_BROWSER + '?url=' +
212 window.encodeURIComponent(
213 this.xulG.url_prefix('EG_WEB_BASE/') +
214 'vandelay/vandelay?qtype=bib&qid=' + this.queue.id()
217 var content_params = {
219 'show_print_button': true,
220 'show_nav_buttons': true
223 this.xulG.new_tab(loc, {tab_name: label}, content_params);
229 dialog = new Bucketz39Dialog();
230 dialog.user_id = window.arguments[0];
231 dialog.authtoken = window.arguments[1];
232 dialog.ws_ou = window.arguments[2];
233 dialog.bucket_id = window.arguments[3];
234 dialog.xulG = window.arguments[4];