list clipboard, and added it to copy status
authorphasefx <phasefx@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Fri, 4 Aug 2006 21:30:59 +0000 (21:30 +0000)
committerphasefx <phasefx@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Fri, 4 Aug 2006 21:30:59 +0000 (21:30 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@5312 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/xul/staff_client/chrome/content/main/constants.js
Open-ILS/xul/staff_client/chrome/content/util/list.js
Open-ILS/xul/staff_client/chrome/content/util/list_clipboard.xul [new file with mode: 0644]
Open-ILS/xul/staff_client/external/template.xul
Open-ILS/xul/staff_client/server/circ/copy_status.js
Open-ILS/xul/staff_client/server/circ/copy_status.xul
Open-ILS/xul/staff_client/server/circ/copy_status_overlay.xul
Open-ILS/xul/staff_client/server/skin/global.css

index d50b631..664237e 100644 (file)
@@ -172,6 +172,7 @@ const urls = {
        'XUL_HOLDS_BROWSER' : '/xul/server/patron/holds.xul',
        'XUL_HOLD_NOTICES' : '/xul/server/patron/hold_notices.xul',
        'XUL_IN_HOUSE_USE' : '/xul/server/circ/in_house_use.xul',
+       'XUL_LIST_CLIPBOARD' : '/xul/server/util/list_clipboard.xul',
        'XUL_LOCAL_ADMIN' : '/xul/server/admin/index.xhtml',
        'XUL_MARC_NEW' : '/xul/server/cat/marc_new.xul',
        'XUL_MARC_EDIT_LEGACY' : 'chrome://open_ils_staff_client/content/legacy/_marc.xul',
index 1607429..488ed34 100644 (file)
@@ -661,6 +661,48 @@ util.list.prototype = {
                return dump;
        },
 
+       'dump_selected_with_keys' : function(params) {
+               var obj = this;
+               switch(this.node.nodeName) {
+                       case 'tree' : return this._dump_tree_selection_with_keys(params); break;
+                       default: throw('NYI: Need .dump_selection_with_keys() for ' + this.node.nodeName); break;
+               }
+
+       },
+
+       '_dump_tree_selection_with_keys' : function(params) {
+               var obj = this;
+               var dump = [];
+               var list = obj._retrieve_selection_from_tree();
+               for (var i = 0; i < list.length; i++) {
+                       var row = {};
+                       var treeitem = list[i];
+                       var treerow = treeitem.firstChild;
+                       for (var j = 0; j < treerow.childNodes.length; j++) {
+                               var value = treerow.childNodes[j].getAttribute('label');
+                               //FIXME
+                               //if (params.skip_hidden_columns) if (obj.node.firstChild.childNodes[j].getAttribute('hidden')) continue;
+                               var id = obj.columns[j].id; if (params.labels_instead_of_ids) id = obj.columns[j].label;
+                               row[ id ] = value;
+                       }
+                       dump.push( row );
+               }
+               return dump;
+       },
+
+       'clipboard' : function() {
+               try {
+                       var obj = this;
+                       var dump = obj.dump_selected_with_keys({'skip_hidden_columns':true,'labels_instead_of_ids':true});
+                       JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.stash_retrieve();
+                       data.list_clipboard = dump; data.stash('list_clipboard');
+                       JSAN.use('util.window'); var win = new util.window();
+                       win.open(urls.XUL_LIST_CLIPBOARD,'list_clipboard','chrome,resizable,modal');
+               } catch(E) {
+                       this.error.standard_unexpected_error_alert('clipboard',E);
+               }
+       },
+
        'dump_retrieve_ids' : function(params) {
                var obj = this;
                switch(this.node.nodeName) {
diff --git a/Open-ILS/xul/staff_client/chrome/content/util/list_clipboard.xul b/Open-ILS/xul/staff_client/chrome/content/util/list_clipboard.xul
new file mode 100644 (file)
index 0000000..695fa67
--- /dev/null
@@ -0,0 +1,108 @@
+<?xml version="1.0"?>
+<!-- Application: Evergreen Staff Client -->
+<!-- Screen: Example Template for remote xul -->
+
+<!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
+<!-- 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"?>
+
+<!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
+<!-- LOCALIZATION -->
+<!DOCTYPE window PUBLIC "" ""[
+       <!--#include virtual="/opac/locale/en-US/lang.dtd"-->
+]>
+
+<!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
+<!-- OVERLAYS -->
+<?xul-overlay href="/xul/server/OpenILS/util_overlay.xul"?>
+
+<window id="util_list_clipboard_win" 
+       onload="try { my_init(); } catch(E) { alert(E); }"
+       width="300" height="300" persist="width height"
+       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 $(id) { return document.getElementById(id); }
+               function $c(n) { return document.createElement(n); }
+
+               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 util_list_clipboard.xul');
+
+                               JSAN.use('OpenILS.data'); g.data = new OpenILS.data(); g.data.stash_retrieve();
+                               if (! g.data.list_clipboard ) {
+                                       window.close();
+                               } else {
+                                       for (var i = 0; i < g.data.list_clipboard.length; i++) {
+                                               var data_row = g.data.list_clipboard[i];
+                                               make_grid(data_row);
+                                       }
+                               }
+
+                       } catch(E) {
+                               try { g.error.standard_unexpected_error_alert('util/list_clipboard.xul',E); } catch(F) { alert(E); }
+                       }
+               }
+
+               function make_grid(data_row) {
+                       try {
+                               var vbox = $c('vbox'); vbox.setAttribute('flex','1'); $('area').appendChild(vbox);
+                               var grid = $c('grid'); grid.setAttribute('flex','1'); grid.setAttribute('style','border: solid black');  vbox.appendChild(grid);
+                               var columns = $c('columns'); grid.appendChild(columns);
+                               var c1 = $c('column'); c1.setAttribute('flex','1'); columns.appendChild(c1);
+                               var c2 = $c('column'); c2.setAttribute('flex','1'); columns.appendChild(c2);
+                               var rows = $c('rows'); grid.appendChild(rows);
+                               var data_row2 = [];
+                               for (j in data_row) {
+                                       data_row2.push( { 'label' : j, 'value' : data_row[j] } );
+                               }
+                               data_row2.sort( function(a,b) { if ( a.label < b.label ) return -1; else return 1; } );
+                               for (var j = 0; j < data_row2.length; j++) {
+                                       var label = data_row2[j].label;
+                                       var value = data_row2[j].value;
+                                       if (value == '???' || value == '' || value == 'undefined') continue;
+                                       var row = $c('row'); 
+                                       var l1 = $c('label'); l1.setAttribute('value',label); row.appendChild(l1);
+                                       var l2 = $c('label'); l2.setAttribute('value',value); 
+                                       l2.setAttribute('style','text-decoration: underline; color: blue; -moz-user-focus: normal'); 
+                                       l2.setAttribute('onfocus','this.setAttribute("class","clipboard_outline_me")');
+                                       l2.setAttribute('onblur','this.setAttribute("class","")');
+                                       l2.setAttribute('onclick','copy_to_clipboard(event); window.close();');
+                                       row.appendChild(l2);
+                                       rows.appendChild(row);
+                                       if (!g.focus) { g.focus = true; l2.focus(); }
+                               }
+                       } catch(E) {
+                               try { g.error.standard_unexpected_error_alert('util/list_clipboard.xul, make_grid',E); } catch(F) { alert(E); }
+                       }
+               }
+
+       ]]>
+       </script>
+
+       <description style="font-weight: bold">Choose the data to copy into the clipboard:</description>
+
+       <hbox id="area" flex="1" style="overflow: scroll">
+       </hbox>
+
+       <hbox><spacer flex="1"/><button label="Close" accesskey="C" oncommand="window.close()"/></hbox>
+
+</window>
+
index 5c153d0..0980cad 100644 (file)
                                }
 
                        } catch(E) {
-                               var err_msg = "!! This software has encountered an error.  Please tell your friendly " +
-                                       "system administrator or software developer the following:\nexample/template.xul\n" + E + '\n';
-                               try { g.error.sdump('D_ERROR',err_msg); } catch(E) { dump(err_msg); }
-                               alert(err_msg);
+                               try { g.error.standard_unexpected_error_alert('example/template.xul',E); } catch(F) { alert(E); }
                        }
                }
 
index 4220b25..e7a4a4f 100644 (file)
@@ -50,6 +50,7 @@ circ.copy_status.prototype = {
                                                        obj.controller.view.sel_bucket.setAttribute('disabled','true');
                                                        obj.controller.view.sel_spine.setAttribute('disabled','true');
                                                        obj.controller.view.sel_transit_abort.setAttribute('disabled','true');
+                                                       obj.controller.view.sel_clip.setAttribute('disabled','true');
                                                } else {
                                                        obj.controller.view.sel_checkin.setAttribute('disabled','false');
                                                        obj.controller.view.sel_edit.setAttribute('disabled','false');
@@ -58,6 +59,7 @@ circ.copy_status.prototype = {
                                                        obj.controller.view.sel_bucket.setAttribute('disabled','false');
                                                        obj.controller.view.sel_spine.setAttribute('disabled','false');
                                                        obj.controller.view.sel_transit_abort.setAttribute('disabled','false');
+                                                       obj.controller.view.sel_clip.setAttribute('disabled','false');
                                                }
                                        } catch(E) {
                                                alert('FIXME: ' + E);
@@ -70,6 +72,10 @@ circ.copy_status.prototype = {
                obj.controller.init(
                        {
                                'control_map' : {
+                                       'sel_clip' : [
+                                               ['command'],
+                                               function() { obj.list.clipboard(); }
+                                       ],
                                        'sel_checkin' : [
                                                ['command'],
                                                function() {
index 4b16b00..d570659 100644 (file)
@@ -93,6 +93,7 @@
                <command id="sel_bucket" disabled="true"/>
                <command id="sel_spine" disabled="true"/>
                <command id="sel_transit_abort" disabled="true"/>
+               <command id="sel_clip" disabled="true"/>
        </commandset>
 
        <popupset id="copy_status_popupset"/>
index 07d6949..bc892c3 100644 (file)
 
 <popupset id="copy_status_popupset">
        <popup id="copy_status_actions" position="at_pointer"> 
+               <menuitem command="sel_clip" label="Copy to Clipboard" accesskey="C" />
                <menuitem command="sel_opac" label="Show in Catalog" accesskey="S" />
                <menuitem command="sel_patron" label="Show Last Few Circulations" accesskey="L"/>
                <menuitem command="sel_edit" label="Edit Item Attributes" accesskey="E" />
                <menuitem command="sel_transit_abort" label="Abort Transits" />
                <menuitem command="sel_bucket" label="Add to Item Bucket" accesskey="A"/>
                <menuitem command="sel_spine" label="Print Spine Label" accesskey="P"/>
-               <menuitem command="sel_checkin" label="Check In Items" accesskey="C" />
+               <menuitem command="sel_checkin" label="Check In Items" accesskey="I" />
        </popup>
 </popupset>
 
        <menubar>
        <menu label="Actions for Selected Items" accesskey="S">
                <menupopup>
+                       <menuitem command="sel_clip" label="Copy to Clipboard" accesskey="C" />
                        <menuitem command="sel_opac" label="Show in Catalog" accesskey="S" />
                        <menuitem command="sel_patron" label="Show Last Few Circulations" accesskey="L"/>
                        <menuitem command="sel_edit" label="Edit Item Attributes" accesskey="E" />
                        <menuitem command="sel_transit_abort" label="Abort Transits" />
                        <menuitem command="sel_bucket" label="Add to Item Bucket" accesskey="A"/>
                        <menuitem command="sel_spine" label="Print Spine Label" accesskey="P"/>
-                       <menuitem command="sel_checkin" label="Check In Items" accesskey="C" />
+                       <menuitem command="sel_checkin" label="Check In Items" accesskey="I" />
                </menupopup>
        </menu>
        </menubar>
index 1d166a6..750f5d0 100644 (file)
@@ -7,6 +7,7 @@ description { -moz-user-select: text; }
 *|input:focus { background-color: #DDFFDD; }
 
 .outline_me { -moz-outline: solid; }
+.clipboard_outline_me { -moz-outline: dotted thin gray; }
 
 tabpanel { border: 2px groove black; }
 caption { font-weight: bold; }