toward usable meat grinder
authorphasefx <phasefx@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 22 Feb 2006 19:40:07 +0000 (19:40 +0000)
committerphasefx <phasefx@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 22 Feb 2006 19:40:07 +0000 (19:40 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@3168 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/xul/staff_client/server/cat/copy_buckets.js
Open-ILS/xul/staff_client/server/cat/copy_buckets_overlay.xul
Open-ILS/xul/staff_client/server/cat/copy_editor.js

index 8e9e97e..e2682e6 100644 (file)
@@ -14,12 +14,21 @@ cat.copy_buckets.prototype = {
        'selection_list2' : [],
        'bucket_id_name_map' : {},
 
+       'render_pending_copies' : function() {
+               var obj = this;
+               obj.list1.clear();
+               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 );
+               }
+       },
+
        'init' : function( params ) {
 
                var obj = this;
 
                obj.session = params['session'];
-               obj.copy_ids = params['copy_ids'];
+               obj.copy_ids = params['copy_ids'] || [];
 
                JSAN.use('circ.util');
                var columns = circ.util.columns( 
@@ -60,11 +69,9 @@ cat.copy_buckets.prototype = {
 
                        }
                );
-               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.render_pending_copies();
+       
                obj.list2 = new util.list('copies_in_bucket_list');
                obj.list2.init(
                        {
@@ -212,9 +219,11 @@ cat.copy_buckets.prototype = {
                                                                //var barcode = obj.selection_list1[i][1];
                                                                //var bucket_item_id = obj.selection_list1[i][2];
                                                                var item = obj.flesh_item_for_list( acp_id );
-                                                               if (item) obj.list1.append( item );
+                                                               if (item) {
+                                                                       obj.list1.append( item );
+                                                                       obj.copy_ids.push( acp_id );
+                                                               }
                                                        }
-
                                                }
                                        ],
 
@@ -276,6 +285,34 @@ cat.copy_buckets.prototype = {
                                                        }
                                                }
                                        ],
+                                       'copy_buckets_batch_copy_edit' : [
+                                               ['command'],
+                                               function() {
+                                                       try {
+                                                               JSAN.use('util.functional');
+                                                               JSAN.use('util.window'); var win = new util.window();
+                                                               win.open(
+                                                                       urls.XUL_COPY_EDITOR 
+                                                                       + '?session=' + window.escape(obj.session)
+                                                                       + '&copy_ids=' + window.escape( js2JSON(
+                                                                               util.functional.map_list(
+                                                                                       obj.list2.dump_retrieve_ids(),
+                                                                                       function (o) {
+                                                                                               return JSON2js(o)[0]; // acp_id
+                                                                                       }
+                                                                               )
+                                                                       ) )
+                                                                       + '&single_edit=1',
+                                                                       'batch_copy_editor_win_' + win.window_name_increment(),
+                                                                       'chrome,resizable,modal'
+                                                               );
+                                                               obj.controller.render('copy_buckets_menulist_placeholder');             
+                                                               obj.render_pending_copies(); // FIXME -- need a generic refresh for lists
+                                                       } catch(E) {
+                                                               alert( js2JSON(E) );
+                                                       }
+                                               }
+                                       ],
                                        'cmd_broken' : [
                                                ['command'],
                                                function() { alert('Not Yet Implemented'); }
index fddbd3f..74a88a8 100644 (file)
@@ -12,7 +12,7 @@
 </box>
 
 <vbox id="cmvb1" flex="1">
-       <groupbox flex="2">
+       <groupbox flex="1">
                <caption label="Pending Copies" />
                <hbox id="pending_buckets_top_ui" />
                <tree id="pending_copies_list" flex="1" enableColumnDrag="true"/>
@@ -47,6 +47,7 @@
        <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_batch_copy_edit" label="Batch Edit" image="/xul/server/skin/media/images/grinder.gif"/>
        <button id="copy_buckets_done" label="Done" command="cmd_copy_buckets_done" accesskey="D"/>
 </hbox>
 
index 7991a0e..052d8e6 100644 (file)
@@ -57,6 +57,12 @@ function my_init() {
                        document.getElementById('nav').setAttribute('hidden','false'); 
                }
 
+               if (g.cgi.param('single_edit') == '1') {
+                       g.single_edit = true;
+                       document.getElementById('caption').setAttribute('label','Copy Editor'); 
+                       document.getElementById('nav').setAttribute('hidden','false'); 
+               }
+
                /******************************************************************************************************/
                /* Show the Record Details? */
 
@@ -564,6 +570,33 @@ g.render = function() {
        /******************************************************************************************************/
        /* Prepare the right panel, which is different for 1-copy view and multi-copy view */
 
+       if (g.single_edit) {
+               
+               /******************************************************************************************************/
+               /* For a less dangerous batch edit, choose one field here */
+
+               var gb = document.createElement('groupbox'); rp.appendChild(gb);
+               var c = document.createElement('caption'); gb.appendChild(c);
+               c.setAttribute('label','Choose a field to edit');
+               JSAN.use('util.widgets'); JSAN.use('util.functional');
+               var ml = util.widgets.make_menulist(
+                       util.functional.map_list(
+                               g.right_pane_field_names,
+                               function(o,i) { return [ o[0], i ]; }
+                       )
+               );
+               gb.appendChild(ml);
+               ml.addEventListener(
+                       'command',
+                       function(ev) {
+                               g.render_input(gb, g.right_pane_field_names[ ev.target.value ][1].input);
+                               ml.disabled = true;
+                       }, 
+                       false
+               );
+
+       }
+
        if (g.copies.length == 1) {
 
                /******************************************************************************************************/
@@ -608,23 +641,11 @@ g.render = function() {
                                /* Render the input widget */
 
                                var hbox = document.createElement('hbox'); 
+                               hbox.setAttribute('id',fn);
                                row.setAttribute('style','border-bottom: dotted black thin');
                                row.appendChild(hbox);
                                if (f[1].input && g.edit) {
-                                       try {
-                                               var spacer = document.createElement('spacer'); hbox.appendChild(spacer);
-                                               spacer.setAttribute('flex','1');
-                                               var deck = document.createElement('deck'); hbox.appendChild(deck);
-                                               var btn = document.createElement('button'); deck.appendChild(btn);
-                                               deck.setAttribute('style','width: 200px; min-width: 200px;');
-                                               btn.setAttribute('label','Change');
-                                               btn.setAttribute('oncommand','this.parentNode.selectedIndex = 1;');
-                                               var x; eval( f[1].input );
-                                               if (x) deck.appendChild(x);
-
-                                       } catch(E) {
-                                               g.error.sdump('D_ERROR',E + '\n');
-                                       }
+                                       g.render_input(hbox,f[1].input);
                                }
 
                        } catch(E) {
@@ -672,26 +693,14 @@ g.render = function() {
 
                                }
                                var hbox = document.createElement('hbox'); 
+                               hbox.setAttribute('id',fn);
                                vbox.appendChild(hbox);
 
                                /**************************************************************************************/
                                /* Render the input widget */
 
                                if (f[1].input && g.edit) {
-                                       try {
-                                               var spacer = document.createElement('spacer'); hbox.appendChild(spacer);
-                                               spacer.setAttribute('flex','1');
-                                               var deck = document.createElement('deck'); hbox.appendChild(deck);
-                                               var btn = document.createElement('button'); deck.appendChild(btn);
-                                               deck.setAttribute('style','width: 200px; min-width: 200px;');
-                                               btn.setAttribute('label','Change');
-                                               btn.setAttribute('oncommand','this.parentNode.selectedIndex = 1;');
-                                               var x; eval( f[1].input );
-                                               if (x) deck.appendChild(x);
-
-                                       } catch(E) {
-                                               g.error.sdump('D_ERROR',E + '\n');
-                                       }
+                                       g.render_input(hbox,f[1].input);
                                }
                        } catch(E) {
                                g.error.sdump('D_ERROR','copy editor: ' + E + '\n');
@@ -701,6 +710,25 @@ g.render = function() {
 }
 
 /******************************************************************************************************/
+/* This actually draws the change button and input widget for a given field */
+g.render_input = function(node,input_cmd) {
+       try {
+               var spacer = document.createElement('spacer'); node.appendChild(spacer);
+               spacer.setAttribute('flex','1');
+               var deck = document.createElement('deck'); node.appendChild(deck);
+               var btn = document.createElement('button'); deck.appendChild(btn);
+               deck.setAttribute('style','width: 200px; min-width: 200px;');
+               btn.setAttribute('label','Change');
+               btn.setAttribute('oncommand','this.parentNode.selectedIndex = 1;');
+               var x; eval( input_cmd );
+               if (x) deck.appendChild(x);
+
+       } catch(E) {
+               g.error.sdump('D_ERROR',E + '\n');
+       }
+}
+
+/******************************************************************************************************/
 /* store the copies in the global xpcom stash */
 
 g.stash_and_close = function() {