[open-ils-commits] r17815 - in trunk/Open-ILS/xul/staff_client/chrome/content: OpenILS circ util (phasefx)

svn at svn.open-ils.org svn at svn.open-ils.org
Sat Sep 18 23:50:31 EDT 2010


Author: phasefx
Date: 2010-09-18 23:50:28 -0400 (Sat, 18 Sep 2010)
New Revision: 17815

Modified:
   trunk/Open-ILS/xul/staff_client/chrome/content/OpenILS/data.js
   trunk/Open-ILS/xul/staff_client/chrome/content/circ/offline.js
   trunk/Open-ILS/xul/staff_client/chrome/content/util/print.js
Log:
Make sure offline interfaces correctly load printer settings outside of logins.  Some refactoring


Modified: trunk/Open-ILS/xul/staff_client/chrome/content/OpenILS/data.js
===================================================================
--- trunk/Open-ILS/xul/staff_client/chrome/content/OpenILS/data.js	2010-09-18 19:56:16 UTC (rev 17814)
+++ trunk/Open-ILS/xul/staff_client/chrome/content/OpenILS/data.js	2010-09-19 03:50:28 UTC (rev 17815)
@@ -244,6 +244,56 @@
         }
     },
 
+    'load_saved_print_templates' : function() {
+        var obj = this;
+        try {
+            JSAN.use('util.file'); var file = new util.file('print_list_templates');
+            if (file._file.exists()) {
+                try {
+                    var x = file.get_object();
+                    if (x) {
+                        for (var i in x) {
+                            obj.print_list_templates[i] = x[i];
+                        }
+                        obj.stash('print_list_templates');
+                        obj.data_progress('Saved print templates retrieved from file. ');
+                    }
+                } catch(E) {
+                    alert(E);
+                }
+            }
+            file.close();
+        } catch(E) {
+            alert("Error in OpenILS.data, load_saved_print_templates(): " + E);
+        }
+    },
+
+    'fetch_print_strategy' : function() {
+        var obj = this;
+        try {
+            obj.print_strategy = {};
+            var print_contexts = [ 'default', 'receipt', 'label', 'mail' ];
+            for (var i in print_contexts) {
+                JSAN.use('util.file'); var file = new util.file('print_strategy.' + print_contexts[i]);
+                if (file._file.exists()) {
+                    try {
+                        var x = file.get_content();
+                        if (x) {
+                            obj.print_strategy[ print_contexts[i] ] = x;
+                            obj.data_progress('Print strategy ' + print_contexts[i] + ' retrieved from file. ');
+                        }
+                    } catch(E) {
+                        alert(E);
+                    }
+                }
+                file.close();
+            }
+            obj.stash('print_strategy');
+        } catch(E) {
+            alert('Error in OpenILS.data, fetch_print_strategy(): ' + E);
+        }
+    },
+
     'print_list_defaults' : function() {
         var obj = this;
         //if (typeof obj.print_list_templates == 'undefined') {
@@ -384,26 +434,6 @@
         netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
         var obj = this;
 
-
-        JSAN.use('util.file'); var file = new util.file('print_list_templates');
-        obj.print_list_defaults();
-        obj.data_progress('Default print templates set. ');
-        if (file._file.exists()) {
-            try {
-                var x = file.get_object();
-                if (x) {
-                    for (var i in x) {
-                        obj.print_list_templates[i] = x[i];
-                    }
-                    obj.stash('print_list_templates');
-                    obj.data_progress('Saved print templates retrieved from file. ');
-                }
-            } catch(E) {
-                alert(E);
-            }
-        }
-        file.close();
-
         JSAN.use('util.file'); var file = new util.file('global_font_adjust');
         if (file._file.exists()) {
             try {
@@ -434,25 +464,10 @@
         }
         file.close();
 
-        obj.print_strategy = {};
-        var print_contexts = [ 'default', 'receipt', 'label', 'mail' ];
-        for (var i in print_contexts) {
-            JSAN.use('util.file'); var file = new util.file('print_strategy.' + print_contexts[i]);
-            if (file._file.exists()) {
-                try {
-                    var x = file.get_content();
-                    if (x) {
-                        obj.print_strategy[ print_contexts[i] ] = x;
-                        obj.data_progress('Print strategy ' + print_contexts[i] + ' retrieved from file. ');
-                    }
-                } catch(E) {
-                    alert(E);
-                }
-            }
-            file.close();
-        }
-        obj.stash('print_strategy');
-
+        obj.print_list_defaults();
+        obj.data_progress('Default print templates set. ');
+        obj.load_saved_print_templates();
+        obj.fetch_print_strategy();
         JSAN.use('util.print'); (new util.print()).GetPrintSettings();
         obj.data_progress('Printer settings retrieved. ');
 

Modified: trunk/Open-ILS/xul/staff_client/chrome/content/circ/offline.js
===================================================================
--- trunk/Open-ILS/xul/staff_client/chrome/content/circ/offline.js	2010-09-18 19:56:16 UTC (rev 17814)
+++ trunk/Open-ILS/xul/staff_client/chrome/content/circ/offline.js	2010-09-19 03:50:28 UTC (rev 17815)
@@ -74,55 +74,11 @@
     },
 
     'receipt_init' : function() {
-        function backup_receipt_templates() {
-            data.print_list_templates = {
-                'offline_checkout' : {
-                    'type' : 'offline_checkout',
-                    'header' : 'Patron %patron_barcode%<br/>\r\nYou checked out the following items:<hr/><ol>',
-                    'line_item' : '<li>Barcode: %barcode%<br/>\r\nDue: %due_date%\r\n',
-                    'footer' : '</ol><hr />%TODAY_TRIM%<br/>\r\n<br/>\r\n',
-                },
-                'offline_checkin' : {
-                    'type' : 'offline_checkin',
-                    'header' : 'You checked in the following items:<hr/><ol>',
-                    'line_item' : '<li>Barcode: %barcode%\r\n',
-                    'footer' : '</ol><hr />%TODAY_TRIM%<br/>\r\n<br/>\r\n',
-                },
-                'offline_renew' : {
-                    'type' : 'offline_renew',
-                    'header' : 'You renewed the following items:<hr/><ol>',
-                    'line_item' : '<li>Barcode: %barcode%\r\n',
-                    'footer' : '</ol><hr />%TODAY_TRIM%<br/>\r\n<br/>\r\n',
-                },
-                'offline_inhouse_use' : {
-                    'type' : 'offline_inhouse_use',
-                    'header' : 'You marked the following in-house items used:<hr/><ol>',
-                    'line_item' : '<li>Barcode: %barcode%\r\nUses: %count%',
-                    'footer' : '</ol><hr />%TODAY_TRIM%<br/>\r\n<br/>\r\n',
-                },
-            };
-            data.stash('print_list_templates');
-        }
-
         JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
-        JSAN.use('util.file'); var file = new util.file('print_list_templates');
-        if (file._file.exists()) {
-            try {
-                var x = file.get_object();
-                if (x) {
-                    data.print_list_templates = x;
-                    data.stash('print_list_templates');
-                } else {
-                    backup_receipt_templates();
-                }
-            } catch(E) {
-                alert(E);
-                backup_receipt_templates();
-            }
-        } else {
-            backup_receipt_templates();
-        }
-        file.close();
+        data.print_list_defaults();
+        data.load_saved_print_templates();
+        data.fetch_print_strategy();
+        JSAN.use('util.print'); (new util.print()).GetPrintSettings();
     },
 
     'patron_init' : function() {

Modified: trunk/Open-ILS/xul/staff_client/chrome/content/util/print.js
===================================================================
--- trunk/Open-ILS/xul/staff_client/chrome/content/util/print.js	2010-09-18 19:56:16 UTC (rev 17814)
+++ trunk/Open-ILS/xul/staff_client/chrome/content/util/print.js	2010-09-19 03:50:28 UTC (rev 17815)
@@ -105,6 +105,11 @@
             netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
             obj.data.init({'via':'stash'});
 
+            if (typeof obj.data.print_strategy == 'undefined') {
+                obj.data.print_strategy = {};
+                obj.data.stash('print_strategy');
+            }
+
             if (params.print_strategy || obj.data.print_strategy[obj.context] || obj.data.print_strategy['default']) {
 
                 switch(params.print_strategy || obj.data.print_strategy[obj.context] || obj.data.print_strategy['default']) {



More information about the open-ils-commits mailing list