From: phasefx Date: Mon, 26 Jan 2009 07:38:01 +0000 (+0000) Subject: some I18N for lists; an easier way to give standard actions to lists; and a refactore... X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=a630641a96f45ad328858bdc01f965b84010b1ee;p=Evergreen.git some I18N for lists; an easier way to give standard actions to lists; and a refactored example with the item status interface git-svn-id: svn://svn.open-ils.org/ILS/branches/staff-client-experiment@11970 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- diff --git a/Open-ILS/xul/staff_client/chrome/content/util/list.js b/Open-ILS/xul/staff_client/chrome/content/util/list.js index a1a14539f3..7629368dde 100644 --- a/Open-ILS/xul/staff_client/chrome/content/util/list.js +++ b/Open-ILS/xul/staff_client/chrome/content/util/list.js @@ -74,7 +74,7 @@ util.list.prototype = { } 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 @@ util.list.prototype = { 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 @@ util.list.prototype = { 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 @@ util.list.prototype = { } */ 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 @@ util.list.prototype = { 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 @@ util.list.prototype = { 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 @@ util.list.prototype = { } 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'); diff --git a/Open-ILS/xul/staff_client/chrome/locale/en-US/offline.properties b/Open-ILS/xul/staff_client/chrome/locale/en-US/offline.properties index 3fc2aad7f0..cc8fea8f26 100644 --- a/Open-ILS/xul/staff_client/chrome/locale/en-US/offline.properties +++ b/Open-ILS/xul/staff_client/chrome/locale/en-US/offline.properties @@ -187,4 +187,19 @@ openils.global_util.clipboard=Copied "%1$s" to clipboard. 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 diff --git a/Open-ILS/xul/staff_client/server/circ/copy_status.js b/Open-ILS/xul/staff_client/server/circ/copy_status.js index 4441192a4f..a247949a0c 100644 --- a/Open-ILS/xul/staff_client/server/circ/copy_status.js +++ b/Open-ILS/xul/staff_client/server/circ/copy_status.js @@ -110,14 +110,21 @@ circ.copy_status.prototype = { 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 @@ circ.copy_status.prototype = { } } ], - '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() { diff --git a/Open-ILS/xul/staff_client/server/circ/copy_status.xul b/Open-ILS/xul/staff_client/server/circ/copy_status.xul index fa56d08eb3..5c83e70172 100644 --- a/Open-ILS/xul/staff_client/server/circ/copy_status.xul +++ b/Open-ILS/xul/staff_client/server/circ/copy_status.xul @@ -101,9 +101,6 @@ - - - diff --git a/Open-ILS/xul/staff_client/server/circ/copy_status_overlay.xul b/Open-ILS/xul/staff_client/server/circ/copy_status_overlay.xul index f6379bdf26..185674f666 100644 --- a/Open-ILS/xul/staff_client/server/circ/copy_status_overlay.xul +++ b/Open-ILS/xul/staff_client/server/circ/copy_status_overlay.xul @@ -166,18 +166,7 @@ - +