From f165469c9ecd60f4a4d7533074d9dbae2023882e Mon Sep 17 00:00:00 2001 From: phasefx Date: Fri, 13 Aug 2010 08:18:42 +0000 Subject: [PATCH] spawn external text editor for Patron Letter during Mark Item Missing Pieces workflow. Put configuration option under Admin -> Local System Administration -> External Text Editor Command git-svn-id: svn://svn.open-ils.org/ILS/trunk@17209 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/web/opac/locale/en-US/lang.dtd | 2 ++ .../xul/staff_client/chrome/content/main/menu.js | 15 ++++++++++ .../chrome/content/main/menu_frame_menus.xul | 4 +++ .../chrome/locale/en-US/offline.properties | 1 + Open-ILS/xul/staff_client/server/cat/util.js | 32 ++++++++++++++++++++-- 5 files changed, 52 insertions(+), 2 deletions(-) diff --git a/Open-ILS/web/opac/locale/en-US/lang.dtd b/Open-ILS/web/opac/locale/en-US/lang.dtd index 0b12f8992..80fe25782 100644 --- a/Open-ILS/web/opac/locale/en-US/lang.dtd +++ b/Open-ILS/web/opac/locale/en-US/lang.dtd @@ -1804,6 +1804,8 @@ + + diff --git a/Open-ILS/xul/staff_client/chrome/content/main/menu.js b/Open-ILS/xul/staff_client/chrome/content/main/menu.js index 944f68afb..91d5178ff 100644 --- a/Open-ILS/xul/staff_client/chrome/content/main/menu.js +++ b/Open-ILS/xul/staff_client/chrome/content/main/menu.js @@ -617,6 +617,21 @@ main.menu.prototype = { ['oncommand'], function() { open_eg_web_page('conify/global/permission/grp_penalty_threshold'); } ], + 'cmd_local_admin_external_text_editor' : [ + ['oncommand'], + function() { + var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces['nsIPrefBranch']); + var key = 'oils.text_editor.external.cmd'; + var has_key = prefs.prefHasUserValue(key); + var value = has_key ? prefs.getCharPref(key) : 'C:\\Windows\\notepad.exe %letter.txt%'; + var cmd = window.prompt( + document.getElementById('offlineStrings').getString('text_editor.prompt_for_external_cmd'), + value + ); + if (!cmd) { return; } + prefs.setCharPref(key,cmd); + } + ], 'cmd_local_admin_idl_field_doc' : [ ['oncommand'], function() { open_eg_web_page('conify/global/config/idl_field_doc'); } diff --git a/Open-ILS/xul/staff_client/chrome/content/main/menu_frame_menus.xul b/Open-ILS/xul/staff_client/chrome/content/main/menu_frame_menus.xul index 146563543..5aeed9df9 100644 --- a/Open-ILS/xul/staff_client/chrome/content/main/menu_frame_menus.xul +++ b/Open-ILS/xul/staff_client/chrome/content/main/menu_frame_menus.xul @@ -114,6 +114,9 @@ + @@ -345,6 +348,7 @@ + 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 19a60f020..eca1229ff 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 @@ -263,3 +263,4 @@ staff.cat.create_or_rebarcode_items=Create or Re-barcode Items printing.nothing_to_reprint=Nothing to re-print printing.prompt_for_external_print_cmd=Enter external print command and parameters (use %receipt.txt% or %receipt.html% as the file containing the print data. Those values will be substituted with the proper path.): printing.print_strategy_saved=Print strategy (%1$s) saved to file system. +text_editor.prompt_for_external_cmd=Enter external text editor command and parameters (use %letter.txt% as the file containing the text. This value will be substituted with the proper path.): diff --git a/Open-ILS/xul/staff_client/server/cat/util.js b/Open-ILS/xul/staff_client/server/cat/util.js index 566f1b20e..28531e570 100644 --- a/Open-ILS/xul/staff_client/server/cat/util.js +++ b/Open-ILS/xul/staff_client/server/cat/util.js @@ -775,7 +775,7 @@ cat.util.mark_item_as_missing_pieces = function(copy_ids) { 'chrome,resizable,modal', { 'copy_id' : copies[i].id() } ); - // TODO: patron notes/messages + // Patron Message var my_xulG = win.open( urls.XUL_NEW_STANDING_PENALTY, 'new_standing_penalty', @@ -794,7 +794,35 @@ cat.util.mark_item_as_missing_pieces = function(copy_ids) { [ ses(), penalty ] ); } - // TODO: Invoke 3rd party app with letter to patron + // Patron Letter + + var txt_file = new util.file('letter.txt'); + txt_file.write_content('truncate',robj.payload.letter.template_output().data()); + var text_path = '"' + txt_file._file.path + '"'; + txt_file.close(); + + var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces['nsIPrefBranch']); + var key = 'oils.text_editor.external.cmd'; + var has_key = prefs.prefHasUserValue(key); + var oils_external_letter_opener_cmd = has_key ? prefs.getCharPref(key) : 'C:\\Windows\\notepad.exe %letter.txt%'; + + var cmd = oils_external_letter_opener_cmd.replace('%letter.txt%',text_path); + + var file = new util.file('letter.bat'); + file.write_content('truncate+exec',cmd); + file.close(); + file = new util.file('letter.bat'); + + dump('letter exec: ' + cmd + '\n'); + var process = Components.classes["@mozilla.org/process/util;1"].createInstance(Components.interfaces.nsIProcess); + process.init(file._file); + + var args = []; + + dump('process.run = ' + process.run(false, args, args.length) + '\n'); + + file.close(); + } else if (robj.ilsevent == 1500 /* ACTION_CIRCULATION_NOT_FOUND */) { alert( $("catStrings").getFormattedString('staff.cat.util.mark_item_missing_pieces.circ_not_found',[ copies[i].barcode() ]) ); } else { -- 2.11.0