[open-ils-commits] r11970 - in branches/staff-client-experiment/Open-ILS/xul/staff_client: chrome/content/util chrome/locale/en-US server/circ

svn at svn.open-ils.org svn at svn.open-ils.org
Mon Jan 26 02:38:05 EST 2009


Author: phasefx
Date: 2009-01-26 02:38:01 -0500 (Mon, 26 Jan 2009)
New Revision: 11970

Modified:
   branches/staff-client-experiment/Open-ILS/xul/staff_client/chrome/content/util/list.js
   branches/staff-client-experiment/Open-ILS/xul/staff_client/chrome/locale/en-US/offline.properties
   branches/staff-client-experiment/Open-ILS/xul/staff_client/server/circ/copy_status.js
   branches/staff-client-experiment/Open-ILS/xul/staff_client/server/circ/copy_status.xul
   branches/staff-client-experiment/Open-ILS/xul/staff_client/server/circ/copy_status_overlay.xul
Log:
some I18N for lists; an easier way to give standard actions to lists; and a refactored example with the item status interface

Modified: branches/staff-client-experiment/Open-ILS/xul/staff_client/chrome/content/util/list.js
===================================================================
--- branches/staff-client-experiment/Open-ILS/xul/staff_client/chrome/content/util/list.js	2009-01-26 05:54:23 UTC (rev 11969)
+++ branches/staff-client-experiment/Open-ILS/xul/staff_client/chrome/content/util/list.js	2009-01-26 07:38:01 UTC (rev 11970)
@@ -74,7 +74,7 @@
 						}
 
 						if (obj.row_count.total != obj.row_count.fleshed && (obj.row_count.total - obj.row_count.fleshed) > 50) {
-							var r = window.confirm('WARNING: Only ' + obj.row_count.fleshed + ' out of ' + obj.row_count.total + ' rows in this list have been retrieved for immediate viewing.  Sorting this list requires that all these rows be retrieved, and this may take some time and lag the staff client.  Would you like to proceed?');
+							var r = window.confirm(document.getElementById('offlineStrings').getFormattedString('list.row_fetch_warning',[obj.row_count.fleshed,obj.row_count.total]));
 
 							if (r) {
 								setTimeout( do_it, 0 );
@@ -94,13 +94,20 @@
 			this.node.appendChild(treechildren);
 			this.treechildren = treechildren;
 		}
-		if (typeof params.on_select == 'function') {
-			this.node.addEventListener(
-				'select',
-				params.on_select,
-				false
-			);
-		}
+        this.node.addEventListener(
+            'select',
+            function(ev) {
+                if (typeof params.on_select == 'function') {
+                    params.on_select(ev);
+                }
+                var x = document.getElementById(obj.node.id + '_clipfield');
+                if (x) {
+                    var sel = obj.retrieve_selection();
+                    x.setAttribute('disabled', sel.length == 0);
+                }
+            },
+            false
+        );
 		if (typeof params.on_click == 'function') {
 			this.node.addEventListener(
 				'click',
@@ -203,7 +210,7 @@
 			JSAN.use('util.file'); var file = new util.file('tree_columns_for_'+window.escape(id));
 			file.set_object(my_cols);
 			file.close();
-			alert('Columns saved.');
+			alert(document.getElementById('offlineStrings').getString('list.columns_saved'));
 		} catch(E) {
 			obj.error.standard_unexpected_error_alert('_save_columns_tree',E);
 		}
@@ -658,7 +665,7 @@
 			}
 			*/
 			for (var i = 0; i < obj.columns.length; i++) {
-			var treecell = document.createElement('treecell'); treecell.setAttribute('label','Retrieving...');
+			var treecell = document.createElement('treecell'); treecell.setAttribute('label',document.getElementById('offlineStrings').getString('list.row_retrieving'));
 			treerow.appendChild(treecell);
 			}
 			/*
@@ -1105,14 +1112,14 @@
         if (params.no_full_retrieve) {
             params.data = obj.dump_csv( params );
             params.not_json = true;
-            if (!params.title) params.title = 'Save List CSV As';
+            if (!params.title) params.title = document.getElementById('offlineStrings').getString('list.save_csv_as');
             f.export_file( params );
         } else {
             obj.wrap_in_full_retrieve( 
                 function() { 
                     params.data = obj.dump_csv( params );
                     params.not_json = true;
-                    if (!params.title) params.title = 'Save List CSV As';
+                    if (!params.title) params.title = document.getElementById('offlineStrings').getString('list.save_csv_as');
                     f.export_file( params );
                 }
             );
@@ -1188,7 +1195,7 @@
 		return dump;
 	},
 
-	'clipboard' : function() {
+	'clipboard' : function(params) {
 		try {
 			var obj = this;
 			var dump = obj.dump_selected_with_keys({'skip_hidden_columns':true,'labels_instead_of_ids':true});
@@ -1296,7 +1303,142 @@
 		} catch(E) {
 			obj.error.standard_unexpected_error_alert('pre sorting', E);
 		}
-	}
+	},
 
+	'render_list_actions' : function(params) {
+		var obj = this;
+		switch(this.node.nodeName) {
+			case 'tree' : return this._render_list_actions_for_tree(params); break;
+			default: throw('NYI: Need ._render_list_actions() for ' + this.node.nodeName); break;
+		}
+	},
+
+    '_render_list_actions_for_tree' : function(params) {
+        var obj = this;
+        try {
+            var btn = document.createElement('button');
+            btn.setAttribute('id',obj.node.id + '_list_actions');
+            btn.setAttribute('type','menu');
+            btn.setAttribute('allowevents','true');
+            //btn.setAttribute('oncommand','this.firstChild.showPopup();');
+            btn.setAttribute('label',document.getElementById('offlineStrings').getString('list.actions.menu.label'));
+            btn.setAttribute('accesskey',document.getElementById('offlineStrings').getString('list.actions.menu.accesskey'));
+            var mp = document.createElement('menupopup');
+            btn.appendChild(mp);
+            var mi = document.createElement('menuitem');
+            mi.setAttribute('id',obj.node.id + '_clipfield');
+            mi.setAttribute('disabled','true');
+            mi.setAttribute('label',document.getElementById('offlineStrings').getString('list.actions.field_to_clipboard.label'));
+            mi.setAttribute('accesskey',document.getElementById('offlineStrings').getString('list.actions.field_to_clipboard.accesskey'));
+            mp.appendChild(mi);
+            mi = document.createElement('menuitem');
+            mi.setAttribute('id',obj.node.id + '_csv_to_clipboard');
+            mi.setAttribute('label',document.getElementById('offlineStrings').getString('list.actions.csv_to_clipboard.label'));
+            mi.setAttribute('accesskey',document.getElementById('offlineStrings').getString('list.actions.csv_to_clipboard.accesskey'));
+            mp.appendChild(mi);
+            mi = document.createElement('menuitem');
+            mi.setAttribute('id',obj.node.id + '_csv_to_printer');
+            mi.setAttribute('label',document.getElementById('offlineStrings').getString('list.actions.csv_to_printer.label'));
+            mi.setAttribute('accesskey',document.getElementById('offlineStrings').getString('list.actions.csv_to_printer.accesskey'));
+            mp.appendChild(mi);
+            mi = document.createElement('menuitem');
+            mi.setAttribute('id',obj.node.id + '_csv_to_file');
+            mi.setAttribute('label',document.getElementById('offlineStrings').getString('list.actions.csv_to_file.label'));
+            mi.setAttribute('accesskey',document.getElementById('offlineStrings').getString('list.actions.csv_to_file.accesskey'));
+            mp.appendChild(mi);
+            mi = document.createElement('menuitem');
+            mi.setAttribute('id',obj.node.id + '_save_columns');
+            mi.setAttribute('label',document.getElementById('offlineStrings').getString('list.actions.save_column_configuration.label'));
+            mi.setAttribute('accesskey',document.getElementById('offlineStrings').getString('list.actions.save_column_configuration.accesskey'));
+            mp.appendChild(mi);
+            return btn;
+        } catch(E) {
+            obj.error.standard_unexpected_error_alert('rendering list actions',E);
+        }
+    },
+
+	'set_list_actions' : function(params) {
+		var obj = this;
+		switch(this.node.nodeName) {
+			case 'tree' : return this._set_list_actions_for_tree(params); break;
+			default: throw('NYI: Need ._set_list_actions() for ' + this.node.nodeName); break;
+		}
+	},
+
+    '_set_list_actions_for_tree' : function(params) {
+        // This should be called after the button element from render_list_actions has been appended to the DOM
+        var obj = this;
+        try {
+            var x = document.getElementById(obj.node.id + '_clipfield');
+            if (x) {
+                x.addEventListener(
+                    'command',
+                    function() {
+                        obj.clipboard(params);
+                        if (params && typeof params.on_complete == 'function') {
+                            params.on_complete(params);
+                        }
+                    },
+                    false
+                );
+            }
+            x = document.getElementById(obj.node.id + '_csv_to_clipboard');
+            if (x) {
+                x.addEventListener(
+                    'command',
+                    function() {
+                        obj.dump_csv_to_clipboard(params);
+                        if (params && typeof params.on_complete == 'function') {
+                            params.on_complete(params);
+                        }
+                    },
+                    false
+                );
+            }
+            x = document.getElementById(obj.node.id + '_csv_to_printer');
+            if (x) {
+                x.addEventListener(
+                    'command',
+                    function() {
+                        obj.dump_csv_to_printer(params);
+                        if (params && typeof params.on_complete == 'function') {
+                            params.on_complete(params);
+                        }
+                    },
+                    false
+                );
+            }
+            x = document.getElementById(obj.node.id + '_csv_to_file');
+            if (x) {
+                x.addEventListener(
+                    'command',
+                    function() {
+                        obj.dump_csv_to_file(params);
+                        if (params && typeof params.on_complete == 'function') {
+                            params.on_complete(params);
+                        }
+                    },
+                    false
+                );
+            }
+            x = document.getElementById(obj.node.id + '_save_columns');
+            if (x) {
+                x.addEventListener(
+                    'command',
+                    function() {
+                        obj.save_columns(params);
+                        if (params && typeof params.on_complete == 'function') {
+                            params.on_complete(params);
+                        }
+                    },
+                    false
+                );
+            }
+
+        } catch(E) {
+            obj.error.standard_unexpected_error_alert('setting list actions',E);
+        }
+    }
+
 }
 dump('exiting util.list.js\n');

Modified: branches/staff-client-experiment/Open-ILS/xul/staff_client/chrome/locale/en-US/offline.properties
===================================================================
--- branches/staff-client-experiment/Open-ILS/xul/staff_client/chrome/locale/en-US/offline.properties	2009-01-26 05:54:23 UTC (rev 11969)
+++ branches/staff-client-experiment/Open-ILS/xul/staff_client/chrome/locale/en-US/offline.properties	2009-01-26 07:38:01 UTC (rev 11970)
@@ -187,4 +187,19 @@
 openils.global_util.content_window_jsobject.error=Error with get_contentWindow(%1$s) and wrappedJSObject: %2$s
 openils.global_util.content_window.error=Error with get_contentWindow(%1$s): %2$s
 openils.global_util.font_size.error=Error adjusting the font size: %1$s
-
+list.row_fetch_warning=WARNING: Only %1$s out of %2$s rows in this list have been retrieved for immediate viewing.  Sorting this list requires that all these rows be retrieved, and this may take some time and lag the staff client.  Would you like to proceed?
+list.columns_saved=Column configuration saved.
+list.row_retrieving=Retrieving...
+list.save_csv_as=Save List CSV As...
+list.actions.menu.label=List Actions
+list.actions.menu.accesskey=L
+list.actions.field_to_clipboard.label=Copy Field from Selected Row to Clipboard
+list.actions.field_to_clipboard.accesskey=C
+list.actions.csv_to_clipboard.label=Copy List CSV to Clipboard
+list.actions.csv_to_clipboard.accesskey=L
+list.actions.csv_to_printer.label=Print List CSV
+list.actions.csv_to_printer.accesskey=P
+list.actions.csv_to_file.label=Save List CSV to File
+list.actions.csv_to_file.accesskey=F
+list.actions.save_column_configuration.label=Save Column Configuration
+list.actions.save_column_configuration.accesskey=S

Modified: branches/staff-client-experiment/Open-ILS/xul/staff_client/server/circ/copy_status.js
===================================================================
--- branches/staff-client-experiment/Open-ILS/xul/staff_client/server/circ/copy_status.js	2009-01-26 05:54:23 UTC (rev 11969)
+++ branches/staff-client-experiment/Open-ILS/xul/staff_client/server/circ/copy_status.js	2009-01-26 07:38:01 UTC (rev 11970)
@@ -110,14 +110,21 @@
 		obj.controller.init(
 			{
 				'control_map' : {
-					'save_columns' : [ [ 'command' ], function() { obj.list.save_columns(); } ],
-					'sel_clip' : [
-						['command'],
-						function() { 
-							obj.list.clipboard(); 
-							obj.controller.view.copy_status_barcode_entry_textbox.focus();
-						}
-					],
+                    'list_actions' : [
+                        ['render'],
+                        function(e) {
+                            return function() {
+                                e.appendChild( obj.list.render_list_actions() );
+                                obj.list.set_list_actions(
+                                    {
+                                        'on_complete' : function() { obj.controller.view.copy_status_barcode_entry_textbox.focus(); } 
+                                    }
+                                );
+                            };
+                        }
+                    ],
+                    'sel_clip' : [ ['command'], function() { obj.list.clipboard(); obj.controller.view.copy_status_barcode_entry_textbox.focus(); } ],
+                    'save_columns' : [ ['command'], function() { obj.list.save_columns(); obj.controller.view.copy_status_barcode_entry_textbox.focus(); } ],
 					'sel_checkin' : [
 						['command'],
 						function() {
@@ -327,19 +334,6 @@
 							}
 						}
 					],
-					'cmd_csv_to_clipboard' : [ ['command'], function() { 
-						obj.list.dump_csv_to_clipboard(); 
-						obj.controller.view.copy_status_barcode_entry_textbox.focus();
-					} ],
-					'cmd_csv_to_printer' : [ ['command'], function() { 
-						obj.list.dump_csv_to_printer(); 
-						obj.controller.view.copy_status_barcode_entry_textbox.focus();
-					} ],
-					'cmd_csv_to_file' : [ ['command'], function() { 
-						obj.list.dump_csv_to_file( { 'defaultFileName' : 'item_status.txt' } ); 
-						obj.controller.view.copy_status_barcode_entry_textbox.focus();
-					} ],
-
 					'cmd_add_items' : [
 						['command'],
 						function() {

Modified: branches/staff-client-experiment/Open-ILS/xul/staff_client/server/circ/copy_status.xul
===================================================================
--- branches/staff-client-experiment/Open-ILS/xul/staff_client/server/circ/copy_status.xul	2009-01-26 05:54:23 UTC (rev 11969)
+++ branches/staff-client-experiment/Open-ILS/xul/staff_client/server/circ/copy_status.xul	2009-01-26 07:38:01 UTC (rev 11970)
@@ -101,9 +101,6 @@
 		<command id="cmd_copy_status_submit_barcode" />
 		<command id="cmd_copy_status_upload_file" />
 		<command id="cmd_copy_status_print" />
-		<command id="cmd_csv_to_clipboard" />
-		<command id="cmd_csv_to_printer" />
-		<command id="cmd_csv_to_file" />
 		<command id="save_columns" />
 		<command id="sel_copy_details" disabled="true"/>
 		<command id="sel_mark_items_damaged" disabled="true"/>

Modified: branches/staff-client-experiment/Open-ILS/xul/staff_client/server/circ/copy_status_overlay.xul
===================================================================
--- branches/staff-client-experiment/Open-ILS/xul/staff_client/server/circ/copy_status_overlay.xul	2009-01-26 05:54:23 UTC (rev 11969)
+++ branches/staff-client-experiment/Open-ILS/xul/staff_client/server/circ/copy_status_overlay.xul	2009-01-26 07:38:01 UTC (rev 11970)
@@ -166,18 +166,7 @@
 </hbox>
 
 <hbox id="copy_status_bottom_ui">
-    <button id="list_actions" oncommand="this.firstChild.showPopup();"
-        label="&staff.generic.list_actions.label;" 
-        accesskey="&staff.generic.list_actions.accesskey;" 
-        type="menu" allowevents="true">
-        <menupopup id="list_actions_popup">
-        	<menuitem command="sel_clip" label="&staff.generic.list_actions.sel_clip.label;" accesskey="&staff.generic.list_actions.sel_clip.accesskey;" disabled="true" />
-    	    <menuitem command="cmd_csv_to_printer" label="&staff.generic.list_actions.csv_to_printer.label;" accesskey="&staff.generic.list_actions.csv_to_printer.accesskey;" />
-        	<menuitem command="cmd_csv_to_clipboard" label="&staff.generic.list_actions.csv_to_clipboard.label;" accesskey="&staff.generic.list_actions.csv_to_clipboard.accesskey;" />
-        	<menuitem command="cmd_csv_to_file" label="&staff.generic.list_actions.csv_to_file.label;" accesskey="&staff.generic.list_actions.csv_to_file.accesskey;" />
-	        <menuitem command="save_columns" label="&staff.generic.list_actions.save_columns.label;" accesskey="&staff.generic.list_actions.save_columns.accesskey;" />
-        </menupopup>
-    </button>
+    <hbox id="list_actions"/>
 
 	<button id="copy_status_print" label="&staff.circ.copy_status_overlay.copy_status_print.label;" command="cmd_copy_status_print" accesskey="&staff.circ.copy_status_overlay.copy_status_print.accesskey;"/>
     <checkbox id="trim_list" label="&staff.circ.copy_status_overlay.trim_list.label;" checked="true" persist="checked" oncommand="try{this.setAttribute('checked',this.checked);}catch(E){alert(E);}" />



More information about the open-ils-commits mailing list