[open-ils-commits] r7642 -
trunk/Open-ILS/xul/staff_client/server/cat
svn at svn.open-ils.org
svn at svn.open-ils.org
Wed Aug 8 14:55:05 EDT 2007
Author: miker
Date: 2007-08-08 14:52:07 -0400 (Wed, 08 Aug 2007)
New Revision: 7642
Modified:
trunk/Open-ILS/xul/staff_client/server/cat/record_buckets.js
Log:
trying out a menu-button
Modified: trunk/Open-ILS/xul/staff_client/server/cat/record_buckets.js
===================================================================
--- trunk/Open-ILS/xul/staff_client/server/cat/record_buckets.js 2007-08-08 18:48:44 UTC (rev 7641)
+++ trunk/Open-ILS/xul/staff_client/server/cat/record_buckets.js 2007-08-08 18:52:07 UTC (rev 7642)
@@ -10,6 +10,63 @@
this.first_pause = true;
}
+cat.record_buckets.pick_file = function (default) {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+
+ var nsIFilePicker = Components.interfaces.nsIFilePicker;
+ var fp = Components.classes["@mozilla.org/filepicker;1"].createInstance( nsIFilePicker );
+
+ fp.init( window, "Save File As", nsIFilePicker.modeSave );
+ if (default)
+ fp.defaultString = default;
+
+ fp.appendFilters( nsIFilePicker.filterAll );
+
+ var result = fp.show();
+ if ( (result == nsIFilePicker.returnOK || result == nsIFilePicker.returnReplace) && fp.file ) {
+ return fp.file;
+ } else {
+ return null;
+ }
+}
+
+cat.record_buckets.export_records = function(output_type) {
+ try {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ obj.list2.select_all();
+ obj.data.stash_retrieve();
+ JSAN.use('util.functional');
+
+ var record_ids = util.functional.map_list(
+ obj.list2.dump_retrieve_ids(),
+ function (o) { return JSON2js(o).docid }
+ );
+
+ var persist = Components.classes["@mozilla.org/embedding/browser/nsWebBrowserPersist;1"]
+ .createInstance(Components.interfaces.nsIWebBrowserPersist);
+
+ var proto_uri = 'http://' + window.location.hostname + '/exporter';
+
+ dump('Record Export URI is ' + proto_uri + '?id=' + record_ids.join('&id=') + '\n');
+
+ var uri = Components.classes["@mozilla.org/network/io-service;1"]
+ .getService(Components.interfaces.nsIIOService)
+ .newURI( proto_uri + '?id=' + record_ids.join('&id='), null, null );
+
+ var file = pick_file('bucket.' + output_type);
+
+ if (file) {
+ persist.saveURI(uri,null,null,null,null,file);
+ } else {
+ alert("File not downloaded.");
+ }
+
+ } catch(E) {
+ obj.error.standard_unexpected_error_alert('Records could not be exported.',E);
+ }
+}
+
+
cat.record_buckets.prototype = {
'selection_list1' : [],
'selection_list2' : [],
@@ -469,22 +526,22 @@
'cmd_export_records_usmarc' : [
['command'],
- function () { return cat.export_records('usmarc') }
+ function () { return cat.record_buckets.export_records('usmarc') }
],
'cmd_export_records_unimarc' : [
['command'],
- function () { return cat.export_records('unimarc') }
+ function () { return cat.record_buckets.export_records('unimarc') }
],
'cmd_export_records_xml' : [
['command'],
- function () { return cat.export_records('xml') }
+ function () { return cat.record_buckets.export_records('xml') }
],
'cmd_export_records_bre' : [
['command'],
- function () { return cat.export_records('bre') }
+ function () { return cat.record_buckets.export_records('bre') }
],
'cmd_merge_records' : [
@@ -728,62 +785,6 @@
},
-};
-
-cat.pick_file = function (default) {
- netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
-
- var nsIFilePicker = Components.interfaces.nsIFilePicker;
- var fp = Components.classes["@mozilla.org/filepicker;1"].createInstance( nsIFilePicker );
-
- fp.init( window, "Save File As", nsIFilePicker.modeSave );
- if (default)
- fp.defaultString = default;
-
- fp.appendFilters( nsIFilePicker.filterAll );
-
- var result = fp.show();
- if ( (result == nsIFilePicker.returnOK || result == nsIFilePicker.returnReplace) && fp.file ) {
- return fp.file;
- } else {
- return null;
- }
}
-cat.export_records = function(output_type) {
- try {
- netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
- obj.list2.select_all();
- obj.data.stash_retrieve();
- JSAN.use('util.functional');
-
- var record_ids = util.functional.map_list(
- obj.list2.dump_retrieve_ids(),
- function (o) { return JSON2js(o).docid }
- );
-
- var persist = Components.classes["@mozilla.org/embedding/browser/nsWebBrowserPersist;1"]
- .createInstance(Components.interfaces.nsIWebBrowserPersist);
-
- var proto_uri = 'http://' + window.location.hostname + '/exporter';
-
- dump('Record Export URI is ' + proto_uri + '?id=' + record_ids.join('&id=') + '\n');
-
- var uri = Components.classes["@mozilla.org/network/io-service;1"]
- .getService(Components.interfaces.nsIIOService)
- .newURI( proto_uri + '?id=' + record_ids.join('&id='), null, null );
-
- var file = pick_file('bucket.' + output_type);
-
- if (file) {
- persist.saveURI(uri,null,null,null,null,file);
- } else {
- alert("File not downloaded.");
- }
-
- } catch(E) {
- obj.error.standard_unexpected_error_alert('Records could not be exported.',E);
- }
-}
-
dump('exiting cat.record_buckets.js\n');
More information about the open-ils-commits
mailing list