copy buckets
authorphasefx <phasefx@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 21 Feb 2006 19:52:56 +0000 (19:52 +0000)
committerphasefx <phasefx@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 21 Feb 2006 19:52:56 +0000 (19:52 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@3151 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/xul/staff_client/server/cat/copy_buckets.js [new file with mode: 0644]
Open-ILS/xul/staff_client/server/cat/copy_buckets.xul [new file with mode: 0644]
Open-ILS/xul/staff_client/server/cat/copy_buckets_overlay.xul [new file with mode: 0644]

diff --git a/Open-ILS/xul/staff_client/server/cat/copy_buckets.js b/Open-ILS/xul/staff_client/server/cat/copy_buckets.js
new file mode 100644 (file)
index 0000000..7df2f5d
--- /dev/null
@@ -0,0 +1,221 @@
+dump('entering cat.copy_buckets.js\n');
+
+if (typeof cat == 'undefined') cat = {};
+cat.copy_buckets = function (params) {
+
+       JSAN.use('util.error'); this.error = new util.error();
+       JSAN.use('util.network'); this.network = new util.network();
+       JSAN.use('util.date');
+       JSAN.use('OpenILS.data'); this.data = new OpenILS.data(); this.data.init({'via':'stash'});
+}
+
+cat.copy_buckets.prototype = {
+       'selection_list' : [],
+
+       'init' : function( params ) {
+
+               var obj = this;
+
+               obj.session = params['session'];
+               obj.copy_ids = params['copy_ids'];
+
+               JSAN.use('circ.util');
+               var columns = circ.util.columns( 
+                       { 
+                               'barcode' : { 'hidden' : false },
+                               'title' : { 'hidden' : false },
+                               'location' : { 'hidden' : false },
+                               'call_number' : { 'hidden' : false },
+                               'status' : { 'hidden' : false },
+                       } 
+               );
+
+               JSAN.use('util.list'); 
+
+               obj.list1 = new util.list('pending_copies_list');
+               obj.list1.init(
+                       {
+                               'columns' : columns,
+                               'map_row_to_column' : circ.util.std_map_row_to_column(),
+                       }
+               );
+               for (var i = 0; i < obj.copy_ids.length; i++) {
+                       var item = obj.flesh_item_for_list( obj.copy_ids[i] );
+                       if (item) obj.list1.append( item );
+               }
+               
+               obj.list2 = new util.list('copies_in_bucket_list');
+               obj.list2.init(
+                       {
+                               'columns' : columns,
+                               'map_row_to_column' : circ.util.std_map_row_to_column(),
+                               'on_select' : function(ev) {
+                                       try {
+                                               JSAN.use('util.functional');
+                                               var sel = obj.list2.retrieve_selection();
+                                               obj.selection_list = util.functional.map_list(
+                                                       sel,
+                                                       function(o) { return JSON2js(o.getAttribute('retrieve_id')); }
+                                               );
+                                               obj.error.sdump('D_TRACE','circ/copy_buckets: selection list = ' + js2JSON(obj.selection_list) );
+                                               if (obj.selection_list.length == 0) {
+                                                       obj.controller.view.copy_buckets_delete_item.disabled = true;
+                                               } else {
+                                                       obj.controller.view.copy_buckets_delete_item.disabled = false;
+                                               }
+                                       } catch(E) {
+                                               alert('FIXME: ' + E);
+                                       }
+                               },
+                       }
+               );
+               
+               JSAN.use('util.controller'); obj.controller = new util.controller();
+               obj.controller.init(
+                       {
+                               'control_map' : {
+                                       'copy_buckets_menulist_placeholder' : [
+                                               ['render'],
+                                               function(e) {
+                                                       return function() {
+                                                               JSAN.use('util.widgets'); JSAN.use('util.functional');
+                                                               var items = util.functional.map_list(
+                                                                       obj.network.simple_request(
+                                                                               'BUCKET_RETRIEVE_VIA_USER',
+                                                                               [ obj.session, obj.data.list.au[0].id() ]
+                                                                       ).copy,
+                                                                       function(o) {
+                                                                               return [ o.name(), o.id() ];
+                                                                       }
+                                                               );
+                                                               g.error.sdump('D_TRACE','items = ' + js2JSON(items));
+                                                               util.widgets.remove_children( e );
+                                                               var ml = util.widgets.make_menulist(
+                                                                       items
+                                                               );
+                                                               e.appendChild( ml );
+                                                               ml.setAttribute('id','bucket_menulist');
+                                                               ml.setAttribute('accesskey','');
+                                                               ml.addEventListener(
+                                                                       'command',
+                                                                       function(ev) {
+                                                                               alert(ev.target.value)
+                                                                       }, false
+                                                               );
+                                                               obj.controller.view.bucket_menulist = ml;
+                                                       };
+                                               },
+                                       ],
+
+                                       'copy_buckets_add' : [
+                                               ['command'],
+                                               function() {
+                                                       for (var i = 0; i < obj.copy_ids.length; i++) {
+                                                               var item = obj.flesh_item_for_list( obj.copy_ids[i] );
+                                                               if (item) obj.list2.append( item );
+                                                       }
+                                               }
+                                       ],
+                                       'copy_buckets_delete_item' : [
+                                               ['command'],
+                                               function() {
+                                                        JSAN.use('circ.util');
+                                                        for (var i = 0; i < obj.selection_list.length; i++) {
+                                                                var acp_id = obj.selection_list[i][0];
+                                                                var barcode = obj.selection_list[i][1];
+                                                        }
+                                               }
+                                       ],
+                                       'copy_buckets_delete_bucket' : [
+                                               ['command'],
+                                               function() {
+                                               }
+                                       ],
+                                       'copy_buckets_new_bucket' : [
+                                               ['command'],
+                                               function() {
+                                                       try {
+                                                               obj.data.new_bucket_value = ''; obj.data.stash('new_bucket_value');
+                                                               JSAN.use('util.window'); var win = new util.window();
+                                                               win.open(
+                                                                       obj.data.server + urls.XUL_BUCKET_NAME,
+                                                                       'new_bucket_win' + win.window_name_increment(),
+                                                                       'chrome,resizable,modal,center'
+                                                               );
+
+                                                               obj.data.stash_retrieve();
+                                                               var name = obj.data.new_bucket_value;
+
+                                                               if (name) {
+                                                                       var bucket = new ccb();
+                                                                       bucket.btype('staff_client');
+                                                                       bucket.owner( obj.data.list.au[0].id() );
+                                                                       bucket.name( name );
+
+                                                                       obj.network.simple_request('BUCKET_CREATE',[obj.session,'copy',bucket]);
+
+                                                                       obj.controller.render('copy_buckets_menulist_placeholder');
+                                                               }
+                                                       } catch(E) {
+                                                               alert('FIXME -- ' + E);
+                                                       }
+                                               }
+                                       ],
+                                       'cmd_broken' : [
+                                               ['command'],
+                                               function() { alert('Not Yet Implemented'); }
+                                       ],
+                                       'cmd_copy_buckets_print' : [
+                                               ['command'],
+                                               function() {
+                                                       dump( js2JSON( obj.list2.dump() ) );
+                                                       alert( js2JSON( obj.list2.dump() ) );
+                                               }
+                                       ],
+                                       'cmd_copy_buckets_reprint' : [
+                                               ['command'],
+                                               function() {
+                                               }
+                                       ],
+                                       'cmd_copy_buckets_done' : [
+                                               ['command'],
+                                               function() {
+                                                       window.close();
+                                               }
+                                       ],
+                               }
+                       }
+               );
+               this.controller.render();
+
+       },
+
+       'flesh_item_for_list' : function(acp_id) {
+               var obj = this;
+               try {
+                       JSAN.use('circ.util');
+                       var copy = obj.network.simple_request( 'FM_ACP_RETRIEVE', [ acp_id ]);
+                       if (copy == null) {
+                               throw('COPY NOT FOUND');
+                       } else {
+                               var item = {
+                                       'retrieve_id' : js2JSON( [ copy.id(), copy.barcode() ] ),
+                                       'row' : {
+                                               'my' : {
+                                                       'mvr' : obj.network.simple_request('MODS_SLIM_RECORD_RETRIEVE_VIA_COPY', [ copy.id() ]),
+                                                       'acp' : copy,
+                                               }
+                                       }
+                               };
+                               return item;
+                       }
+               } catch(E) {
+                       alert('FIXME: need special alert and error handling\n' + js2JSON(E));
+                       return null;
+               }
+
+       },
+       
+}
+
+dump('exiting cat.copy_buckets.js\n');
diff --git a/Open-ILS/xul/staff_client/server/cat/copy_buckets.xul b/Open-ILS/xul/staff_client/server/cat/copy_buckets.xul
new file mode 100644 (file)
index 0000000..27ed9d0
--- /dev/null
@@ -0,0 +1,78 @@
+<?xml version="1.0"?>
+<!-- Application: Evergreen Staff Client -->
+<!-- Screen: Patron Display -->
+
+<!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
+<!-- STYLESHEETS -->
+<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
+<?xml-stylesheet href="chrome://open_ils_staff_client/skin/global.css" type="text/css"?>
+<?xml-stylesheet href="/xul/server/skin/global.css" type="text/css"?>
+<?xml-stylesheet href="/xul/server/skin/cat.css" type="text/css"?>
+
+<!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
+<!-- LOCALIZATION -->
+<!DOCTYPE window SYSTEM "chrome://open_ils_staff_client/locale/lang.dtd">
+
+<!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
+<!-- OVERLAYS -->
+<?xul-overlay href="/xul/server/OpenILS/util_overlay.xul"?>
+<?xul-overlay href="/xul/server/cat/copy_buckets_overlay.xul"?>
+
+<window id="copy_buckets_win" title="Copy Buckets"
+       onload="my_init()" height="600" width="800" persist="height,width"
+       xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+
+       <!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
+       <!-- BEHAVIOR -->
+        <script type="text/javascript">var myPackageDir = 'open_ils_staff_client'; var IAMXUL = true; var g = {};</script>
+        <scripts id="openils_util_scripts"/>
+
+       <script type="text/javascript" src="/xul/server/main/JSAN.js"/>
+       <script>
+       <![CDATA[
+               function my_init() {
+                       try {
+                               netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+                               if (typeof JSAN == 'undefined') { throw( "The JSAN library object is missing."); }
+                               JSAN.errorLevel = "die"; // none, warn, or die
+                               JSAN.addRepository('/xul/server/');
+                               JSAN.use('util.error'); g.error = new util.error();
+                               g.error.sdump('D_TRACE','my_init() for copy_buckets.xul');
+
+                               g.cgi = new CGI();
+
+                               JSAN.use('cat.copy_buckets'); g.copy_buckets = new cat.copy_buckets();
+                               g.copy_buckets.init( 
+                                       { 
+                                               'session' : g.cgi.param('session'),
+                                               'copy_ids' : JSON2js( g.cgi.param('copy_ids') ),
+                                       } 
+                               );
+       
+                               if (typeof window.xulG == 'object' && typeof window.xulG.set_tab_name == 'function') {
+                                       try { window.xulG.set_tab_name('Copy Status'); } catch(E) { alert(E); }
+                               }
+
+                       } catch(E) {
+                               var err_msg = "!! This software has encountered an error.  Please tell your friendly " +
+                                       "system administrator or software developer the following:\n" 
+                                       + 'cat.copy_buckets.xul\n' + E + '\n';
+                               try { g.error.sdump('D_ERROR',err_msg); } catch(E) { dump(err_msg); }
+                               alert(err_msg);
+                       }
+               }
+
+       ]]>
+       </script>
+
+       <commandset id="copy_buckets_cmds">
+               <command id="cmd_copy_buckets_submit_barcode" />
+               <command id="cmd_copy_buckets_print" />
+               <command id="cmd_copy_buckets_reprint" />
+               <command id="cmd_copy_buckets_done" />
+       </commandset>
+
+       <box id="copy_buckets_main" />
+
+</window>
+
diff --git a/Open-ILS/xul/staff_client/server/cat/copy_buckets_overlay.xul b/Open-ILS/xul/staff_client/server/cat/copy_buckets_overlay.xul
new file mode 100644 (file)
index 0000000..02b7843
--- /dev/null
@@ -0,0 +1,50 @@
+<?xml version="1.0"?>
+<!DOCTYPE overlay SYSTEM "chrome://open_ils_staff_client/locale/lang.dtd">
+<overlay id="copy_buckets_overlay" 
+       xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+
+<script>dump('loading copy_buckets_overlay.xul\n');</script>
+
+<commandset id="copy_buckets_cmds" />
+
+<box id="copy_buckets_main" flex="1" orient="vertical" class="my_overflow">
+       <vbox id="cmvb1" flex="1"/>
+</box>
+
+<vbox id="cmvb1" flex="1">
+       <groupbox flex="2">
+               <caption label="Pending Copies" />
+               <hbox id="pending_buckets_top_ui" />
+               <tree id="pending_copies_list" flex="1" enableColumnDrag="true"/>
+               <hbox id="pending_buckets_bottom_ui" />
+       </groupbox>
+       <splitter><grippy /></splitter>
+       <groupbox flex="2">
+               <caption label="Bucket View" />
+               <hbox id="copy_buckets_top_ui" />
+               <tree id="copies_in_bucket_list" flex="1" enableColumnDrag="true"/>
+               <hbox id="copy_buckets_bottom_ui" />
+       </groupbox>
+</vbox>
+
+<hbox id="pending_buckets_bottom_ui">
+       <button label="Add copies above to bucket below" id="copy_buckets_add" accesskey="A"/>
+</hbox>
+
+<hbox id="copy_buckets_top_ui">
+       <label value="Select:"/>
+       <hbox id="copy_buckets_menulist_placeholder" />
+       <spacer flex="1"/>
+       <button id="copy_buckets_new_bucket" label="New Bucket"/>
+       <button id="copy_buckets_delete_bucket" label="Delete Bucket"/>
+       <button id="copy_buckets_delete_item" label="Delete Item" disabled="true"/>
+</hbox>
+
+<hbox id="copy_buckets_bottom_ui">
+       <button id="copy_buckets_print" label="Print" command="cmd_copy_buckets_print" accesskey="P"/>
+       <button id="copy_buckets_reprint" label="Print Last" command="cmd_copy_buckets_reprint" accesskey_disabled="L"/>
+       <spacer flex="1"/>
+       <button id="copy_buckets_done" label="Done" command="cmd_copy_buckets_done" accesskey="D"/>
+</hbox>
+
+</overlay>