[open-ils-commits] r7641 -
trunk/Open-ILS/xul/staff_client/server/cat
svn at svn.open-ils.org
svn at svn.open-ils.org
Wed Aug 8 14:51:41 EDT 2007
Author: miker
Date: 2007-08-08 14:48:44 -0400 (Wed, 08 Aug 2007)
New Revision: 7641
Modified:
trunk/Open-ILS/xul/staff_client/server/cat/record_buckets.js
trunk/Open-ILS/xul/staff_client/server/cat/record_buckets.xul
trunk/Open-ILS/xul/staff_client/server/cat/record_buckets_overlay.xul
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:37:34 UTC (rev 7640)
+++ trunk/Open-ILS/xul/staff_client/server/cat/record_buckets.js 2007-08-08 18:48:44 UTC (rev 7641)
@@ -467,58 +467,24 @@
}
],
- 'cmd_export_records' : [
+ 'cmd_export_records_usmarc' : [
['command'],
- function() {
- function pick_file() {
- 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 );
- fp.defaultString = 'bucket.mrc';
- fp.appendFilters( nsIFilePicker.filterAll );
- var result = fp.show();
- if ( (result == nsIFilePicker.returnOK || result == nsIFilePicker.returnReplace) && fp.file ) {
- return fp.file;
- } else {
- return null;
- }
- }
+ function () { return cat.export_records('usmarc') }
+ ],
- try {
- netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
- obj.list2.select_all();
- obj.data.stash_retrieve();
- JSAN.use('util.functional');
+ 'cmd_export_records_unimarc' : [
+ ['command'],
+ function () { return cat.export_records('unimarc') }
+ ],
- var record_ids = util.functional.map_list(
- obj.list2.dump_retrieve_ids(),
- function (o) { return JSON2js(o).docid }
- );
+ 'cmd_export_records_xml' : [
+ ['command'],
+ function () { return cat.export_records('xml') }
+ ],
- 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();
-
- 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);
- }
- }
+ 'cmd_export_records_bre' : [
+ ['command'],
+ function () { return cat.export_records('bre') }
],
'cmd_merge_records' : [
@@ -762,6 +728,62 @@
},
+};
+
+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');
Modified: trunk/Open-ILS/xul/staff_client/server/cat/record_buckets.xul
===================================================================
--- trunk/Open-ILS/xul/staff_client/server/cat/record_buckets.xul 2007-08-08 18:37:34 UTC (rev 7640)
+++ trunk/Open-ILS/xul/staff_client/server/cat/record_buckets.xul 2007-08-08 18:48:44 UTC (rev 7641)
@@ -93,7 +93,10 @@
<command id="cmd_record_buckets_reprint" />
<command id="cmd_record_buckets_done" />
<command id="cmd_merge_records" />
- <command id="cmd_export_records" />
+ <command id="cmd_export_records_usmarc" />
+ <command id="cmd_export_records_unimarc" />
+ <command id="cmd_export_records_xml" />
+ <command id="cmd_export_records_bre" />
<command id="cmd_delete_records" />
<command id="cmd_sel_opac" />
</commandset>
Modified: trunk/Open-ILS/xul/staff_client/server/cat/record_buckets_overlay.xul
===================================================================
--- trunk/Open-ILS/xul/staff_client/server/cat/record_buckets_overlay.xul 2007-08-08 18:37:34 UTC (rev 7640)
+++ trunk/Open-ILS/xul/staff_client/server/cat/record_buckets_overlay.xul 2007-08-08 18:48:44 UTC (rev 7641)
@@ -72,12 +72,12 @@
<button command="cmd_sel_opac" label="Show All in Catalog" accesskey="S"/>
<button id="record_buckets_delete_records" command="cmd_delete_records" label="Delete All Records"/>
<button id="record_buckets_merge_records" command="cmd_merge_records" label="Merge All Records"/>
- <button id="record_buckets_export_records" command="cmd_export_records" label="Export All Records" type="menu">
+ <button id="record_buckets_export_records" label="Export All Records" type="menu">
<menupopup id="record_buckets_export_record_types">
- <menuitem value="usmarc" label="MARC21"/>
- <menuitem value="unimarc" label="UNIMARC"/>
- <menuitem value="xml" label="XML"/>
- <menuitem value="bre" label="Evergreen BRE"/>
+ <menuitem command="cmd_export_records_usmarc" value="usmarc" label="MARC21"/>
+ <menuitem command="cmd_export_records_unimarc" value="unimarc" label="UNIMARC"/>
+ <menuitem command="cmd_export_records_xml" value="xml" label="XML"/>
+ <menuitem command="cmd_export_records_bre" value="bre" label="Evergreen BRE"/>
</menupopup>
</button>
</hbox>
More information about the open-ils-commits
mailing list