[open-ils-commits] r9576 - in
branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb:
public/oils/media/ui_js/oils/default/acq
public/oils/media/ui_js/oils/default/acq/picklist
templates/oils/default/acq/picklist
svn at svn.open-ils.org
svn at svn.open-ils.org
Tue May 13 10:21:09 EDT 2008
Author: erickson
Date: 2008-05-13 10:21:08 -0400 (Tue, 13 May 2008)
New Revision: 9576
Added:
branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/public/oils/media/ui_js/oils/default/acq/picklist/
branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/public/oils/media/ui_js/oils/default/acq/picklist/bib_search.js
Modified:
branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/picklist/bib_search.html
Log:
moved bib search JS to external file
Added: branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/public/oils/media/ui_js/oils/default/acq/picklist/bib_search.js
===================================================================
--- branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/public/oils/media/ui_js/oils/default/acq/picklist/bib_search.js (rev 0)
+++ branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/public/oils/media/ui_js/oils/default/acq/picklist/bib_search.js 2008-05-13 14:21:08 UTC (rev 9576)
@@ -0,0 +1,145 @@
+dojo.require('dojox.form.CheckedMultiSelect');
+dojo.require('fieldmapper.Fieldmapper');
+dojo.require('dijit.ProgressBar');
+dojo.require('dijit.form.Form');
+dojo.require('dijit.form.TextBox');
+dojo.require('openils.Event');
+
+var searchFields = [];
+var resultPicklist;
+var recvCount = 0;
+var sourceCount = 0; // how many sources are we searching
+var user = new openils.User();
+
+function drawForm() {
+
+ var sources = fieldmapper.standardRequest(
+ ['open-ils.search', 'open-ils.search.z3950.retrieve_services'],
+ [user.authtoken]
+ );
+
+ openils.Event.parse_and_raise(sources);
+
+ for(var name in sources) {
+ source = sources[name];
+ bibSourceSelect.addOption(name, name+':'+source.host);
+ for(var attr in source.attrs)
+ if(!attr.match(/^#/)) // xml comment nodes
+ searchFields.push(source.attrs[attr]);
+ }
+
+ searchFields = searchFields.sort(
+ function(a,b) {
+ if(a.label < b.label)
+ return -1;
+ if(a.label > b.label)
+ return 1;
+ return 0;
+ }
+ );
+
+ //alert(dojo.query('[name=label]', 'oils-acq-search-fields-template'));
+ var tbody = dojo.byId('oils-acq-search-fields-tbody');
+ var tmpl = tbody.removeChild(dojo.byId('oils-acq-search-fields-template'));
+
+ for(var f in searchFields) {
+ var field = searchFields[f];
+ if(dijit.byId('text_input_'+field.name)) continue;
+ var row = tmpl.cloneNode(true);
+ tbody.appendChild(row);
+ var labelCell = dojo.query('[name=label]', row)[0];
+ var inputCell = dojo.query('[name=input]', row)[0];
+ labelCell.appendChild(document.createTextNode(field.label));
+ input = new dijit.form.TextBox({name:field.name, label:field.label, id:'text_input_'+field.name});
+ inputCell.appendChild(input.domNode);
+ }
+}
+
+function doSearch(values) {
+ dojo.style('searchProgress', 'visibility', 'visible');
+
+ search = {
+ service : [],
+ username : [],
+ password : [],
+ search : {},
+ limit : searchLimit,
+ offset : searchOffset
+ }
+
+ var selected = bibSourceSelect.getValue();
+ for(var i = 0; i < selected.length; i++) {
+ search.service.push(selected[i]);
+ search.username.push('');
+ search.password.push('');
+ sourceCount++;
+ }
+
+ for(var v in values) {
+ if(values[v]) {
+ var input = dijit.byId('text_input_'+v);
+ search.search[v] = values[v];
+ }
+ }
+
+ fieldmapper.standardRequest(
+ ['open-ils.search', 'open-ils.search.z3950.search_class'],
+ { async: true,
+ params: [user.authtoken, search],
+ onresponse: handleResult,
+ oncomplete: viewPicklist
+ }
+ );
+}
+
+function handleResult(r) {
+ var result = r.recv().content();
+ if(!resultPicklist)
+ createResultPicklist();
+
+ searchProgress.update({maximum: sourceCount*searchLimit+1, progress: ++recvCount});
+
+ for(var idx in result.records) {
+ searchProgress.update({progress: ++recvCount});
+ var rec = result.records[idx];
+ var lineitem = new jub()
+
+ lineitem.picklist(resultPicklist.id());
+ lineitem.source_label(result.service)
+ lineitem.marc(rec.marcxml)
+ lineitem.eg_bib_id(rec.bibid)
+
+ var id = fieldmapper.standardRequest(
+ ['open-ils.acq', 'open-ils.acq.lineitem.create'],
+ [user.authtoken, lineitem]
+ );
+ }
+}
+
+function createResultPicklist() {
+ resultPicklist = new acqpl();
+ resultPicklist.name('');
+ resultPicklist.owner(user.user.id());
+
+ /* delete the old picklist with name = '' */
+ var pl = fieldmapper.standardRequest(
+ ['open-ils.acq', 'open-ils.acq.picklist.name.retrieve'],
+ [user.authtoken, '']
+ );
+
+ if(pl) {
+ fieldmapper.standardRequest(
+ ['open-ils.acq', 'open-ils.acq.picklist.delete'],
+ [user.authtoken, pl.id()]
+ );
+ }
+
+ resultPicklist.id(
+ fieldmapper.standardRequest(
+ ['open-ils.acq', 'open-ils.acq.picklist.create'],
+ [user.authtoken, resultPicklist]
+ )
+ );
+}
+
+dojo.addOnLoad(drawForm);
Modified: branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/picklist/bib_search.html
===================================================================
--- branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/picklist/bib_search.html 2008-05-13 14:17:21 UTC (rev 9575)
+++ branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/picklist/bib_search.html 2008-05-13 14:21:08 UTC (rev 9576)
@@ -2,166 +2,19 @@
<%inherit file='../base.html'/>
<%def name="page_title()">${_('Title Search')}</%def>
-
<%def name="block_content()">
-
+ <script src='${c.oils.core.media_prefix.value}/ui_js/oils/default/acq/picklist/bib_search.js'> </script>
<style>
+ /* import the checkedmultiselect css */
@import url(${c.oils.core.media_prefix.value}/js/dojo/dojox/form/resources/CheckedMultiSelect.css);
</style>
<script>
- dojo.require('dojox.form.CheckedMultiSelect');
- dojo.require('fieldmapper.Fieldmapper');
- dojo.require('dijit.ProgressBar');
- dojo.require('dijit.form.Form');
- dojo.require('dijit.form.TextBox');
- dojo.require('openils.Event');
-
var searchLimit = ${c.oils.acq.limit.value} || 10;
var searchOffset = ${c.oils.acq.offset.value} || 0;
- var searchFields = [];
- var resultPicklist;
- var recvCount = 0;
- var sourceCount = 0; // how many sources are we searching
- var user = new openils.User();
-
- function drawForm() {
-
- var sources = fieldmapper.standardRequest(
- ['open-ils.search', 'open-ils.search.z3950.retrieve_services'],
- [user.authtoken]
- );
-
- openils.Event.parse_and_raise(sources);
-
- for(var name in sources) {
- source = sources[name];
- bibSourceSelect.addOption(name, name+':'+source.host);
- for(var attr in source.attrs)
- if(!attr.match(/^#/)) // xml comment nodes
- searchFields.push(source.attrs[attr]);
- }
-
- searchFields = searchFields.sort(
- function(a,b) {
- if(a.label < b.label)
- return -1;
- if(a.label > b.label)
- return 1;
- return 0;
- }
- );
-
- //alert(dojo.query('[name=label]', 'oils-acq-search-fields-template'));
- var tbody = dojo.byId('oils-acq-search-fields-tbody');
- var tmpl = tbody.removeChild(dojo.byId('oils-acq-search-fields-template'));
-
- for(var f in searchFields) {
- var field = searchFields[f];
- if(dijit.byId('text_input_'+field.name)) continue;
- var row = tmpl.cloneNode(true);
- tbody.appendChild(row);
- var labelCell = dojo.query('[name=label]', row)[0];
- var inputCell = dojo.query('[name=input]', row)[0];
- labelCell.appendChild(document.createTextNode(field.label));
- input = new dijit.form.TextBox({name:field.name, label:field.label, id:'text_input_'+field.name});
- inputCell.appendChild(input.domNode);
- }
- }
-
- function doSearch(values) {
- dojo.style('searchProgress', 'visibility', 'visible');
-
- search = {
- service : [],
- username : [],
- password : [],
- search : {},
- limit : searchLimit,
- offset : searchOffset
- }
-
- var selected = bibSourceSelect.getValue();
- for(var i = 0; i < selected.length; i++) {
- search.service.push(selected[i]);
- search.username.push('');
- search.password.push('');
- sourceCount++;
- }
-
- for(var v in values) {
- if(values[v]) {
- var input = dijit.byId('text_input_'+v);
- search.search[v] = values[v];
- }
- }
-
- fieldmapper.standardRequest(
- ['open-ils.search', 'open-ils.search.z3950.search_class'],
- { async: true,
- params: [user.authtoken, search],
- onresponse: handleResult,
- oncomplete: viewPicklist
- }
- );
- }
-
function viewPicklist() {
location.href = '${c.oils.acq.prefix.value}/picklist/view/' + resultPicklist.id();
}
-
- function handleResult(r) {
- var result = r.recv().content();
- if(!resultPicklist)
- createResultPicklist();
-
- searchProgress.update({maximum: sourceCount*searchLimit+1, progress: ++recvCount});
-
- for(var idx in result.records) {
- searchProgress.update({progress: ++recvCount});
- var rec = result.records[idx];
- var lineitem = new jub()
-
- lineitem.picklist(resultPicklist.id());
- lineitem.source_label(result.service)
- lineitem.marc(rec.marcxml)
- lineitem.eg_bib_id(rec.bibid)
-
- var id = fieldmapper.standardRequest(
- ['open-ils.acq', 'open-ils.acq.lineitem.create'],
- [user.authtoken, lineitem]
- );
- }
- }
-
- function createResultPicklist() {
- resultPicklist = new acqpl();
- resultPicklist.name('');
- resultPicklist.owner(user.user.id());
-
- /* delete the old picklist with name = '' */
- var pl = fieldmapper.standardRequest(
- ['open-ils.acq', 'open-ils.acq.picklist.name.retrieve'],
- [user.authtoken, '']
- );
-
- if(pl) {
- fieldmapper.standardRequest(
- ['open-ils.acq', 'open-ils.acq.picklist.delete'],
- [user.authtoken, pl.id()]
- );
- }
-
- resultPicklist.id(
- fieldmapper.standardRequest(
- ['open-ils.acq', 'open-ils.acq.picklist.create'],
- [user.authtoken, resultPicklist]
- )
- );
- }
-
- dojo.addOnLoad(drawForm);
-
</script>
<div id='oils-acq-search-block' class='container'>
More information about the open-ils-commits
mailing list