From 05352daab6b4020af8489f765f53e36a5c8a3042 Mon Sep 17 00:00:00 2001 From: Thomas Berezansky Date: Tue, 20 Dec 2011 11:49:16 -0500 Subject: [PATCH] Add Context to Receipt Templates By default the print context is used, but this enabled each template to be assigned a specific printer context that it is intended for. This means that things that normally use "Default" can be forced to, say, "Receipt" and such easily. Signed-off-by: Thomas Berezansky Signed-off-by: Jason Etheridge --- Open-ILS/web/opac/locale/en-US/lang.dtd | 1 + .../staff_client/chrome/content/OpenILS/data.js | 10 +++++++++ .../xul/staff_client/chrome/content/util/print.js | 2 ++ .../xul/staff_client/server/cat/copy_buckets.js | 1 + .../server/circ/print_list_template_editor.js | 24 ++++++++++++++++++++++ .../server/circ/print_list_template_editor.xul | 2 ++ Open-ILS/xul/staff_client/server/circ/util.js | 6 ++++-- Open-ILS/xul/staff_client/server/patron/bill2.js | 3 ++- 8 files changed, 46 insertions(+), 3 deletions(-) diff --git a/Open-ILS/web/opac/locale/en-US/lang.dtd b/Open-ILS/web/opac/locale/en-US/lang.dtd index e2bc1bbf61..4a96bb1a9c 100644 --- a/Open-ILS/web/opac/locale/en-US/lang.dtd +++ b/Open-ILS/web/opac/locale/en-US/lang.dtd @@ -2448,6 +2448,7 @@ + diff --git a/Open-ILS/xul/staff_client/chrome/content/OpenILS/data.js b/Open-ILS/xul/staff_client/chrome/content/OpenILS/data.js index 0dda428d5f..d6e79a71b0 100644 --- a/Open-ILS/xul/staff_client/chrome/content/OpenILS/data.js +++ b/Open-ILS/xul/staff_client/chrome/content/OpenILS/data.js @@ -343,6 +343,16 @@ OpenILS.data.prototype = { 'holds', /* 'patrons' */ ]; + // We define this for the benefit of the editor. + // We don't assign them here, leaving that to the user. + // Without one assigned per template the context the util.print was created with will be used instead. + obj.print_list_contexts = [ + 'default', + 'receipt', + 'label', + 'mail', + 'offline', + ]; obj.print_list_templates = { 'item_status' : { 'type' : 'items', diff --git a/Open-ILS/xul/staff_client/chrome/content/util/print.js b/Open-ILS/xul/staff_client/chrome/content/util/print.js index 399e61b6e0..414c8d762e 100644 --- a/Open-ILS/xul/staff_client/chrome/content/util/print.js +++ b/Open-ILS/xul/staff_client/chrome/content/util/print.js @@ -227,6 +227,7 @@ util.print.prototype = { } var cols = []; var s = ''; + if (params.context) this.set_context(params.context); if (params.header) s += this.template_sub( params.header, cols, params ); if (params.list) { // Pre-templating sort @@ -303,6 +304,7 @@ util.print.prototype = { } else { this.simple(s,params); } + if(this.context != this.default_context) this.set_context(this.default_context); }, 'template_sub' : function( msg, cols, params ) { diff --git a/Open-ILS/xul/staff_client/server/cat/copy_buckets.js b/Open-ILS/xul/staff_client/server/cat/copy_buckets.js index 9dc89df27d..a9e3137974 100644 --- a/Open-ILS/xul/staff_client/server/cat/copy_buckets.js +++ b/Open-ILS/xul/staff_client/server/cat/copy_buckets.js @@ -626,6 +626,7 @@ cat.copy_buckets.prototype = { 'footer' : data.print_list_templates.item_status.footer, 'type' : data.print_list_templates.item_status.type, 'list' : obj.list2.dump_with_keys(), + 'context' : data.print_list_templates.item_status.context, }; JSAN.use('util.print'); var print = new util.print(); print.tree_list( p ); diff --git a/Open-ILS/xul/staff_client/server/circ/print_list_template_editor.js b/Open-ILS/xul/staff_client/server/circ/print_list_template_editor.js index f7b3916f10..c4d461f33c 100644 --- a/Open-ILS/xul/staff_client/server/circ/print_list_template_editor.js +++ b/Open-ILS/xul/staff_client/server/circ/print_list_template_editor.js @@ -109,6 +109,7 @@ circ.print_list_template_editor.prototype = { obj.controller.view.header.value = tmp.header; obj.controller.view.line_item.value = tmp.line_item; obj.controller.view.footer.value = tmp.footer; + obj.controller.view.template_context_menu.value = tmp.context; obj.preview(); }, 0 ); @@ -310,6 +311,7 @@ circ.print_list_template_editor.prototype = { obj.controller.view.header.value = tmp.header; obj.controller.view.line_item.value = tmp.line_item; obj.controller.view.footer.value = tmp.footer; + obj.controller.view.template_context_menu.value = tmp.context; obj.preview(); }, false @@ -335,8 +337,29 @@ circ.print_list_template_editor.prototype = { obj.controller.view.template_type_menu = ml; } } + ], + 'template_context_menu_placeholder' : [ + ['render'], + function(e) { + return function() { + JSAN.use('util.widgets'); JSAN.use('util.functional'); + util.widgets.remove_children(e); + var ml = util.widgets.make_menulist( + [['',null]].concat( + util.functional.map_list( + obj.data.print_list_contexts, + function(o) { return [o,o]; } + ) + ) + ); + ml.setAttribute('id','template_context_menu'); + e.appendChild(ml); + obj.controller.view.template_context_menu = ml; + } + } ] + } } ); @@ -378,6 +401,7 @@ circ.print_list_template_editor.prototype = { obj.data.print_list_templates[name].line_item = obj.controller.view.line_item.value; obj.data.print_list_templates[name].footer = obj.controller.view.footer.value; obj.data.print_list_templates[name].type = obj.controller.view.template_type_menu.value; + obj.data.print_list_templates[name].context = obj.controller.view.template_context_menu.value; obj.data.stash( 'print_list_templates' ); netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); JSAN.use('util.file'); var file = new util.file('print_list_templates'); diff --git a/Open-ILS/xul/staff_client/server/circ/print_list_template_editor.xul b/Open-ILS/xul/staff_client/server/circ/print_list_template_editor.xul index 534b16cac1..0450cfaff4 100644 --- a/Open-ILS/xul/staff_client/server/circ/print_list_template_editor.xul +++ b/Open-ILS/xul/staff_client/server/circ/print_list_template_editor.xul @@ -82,6 +82,8 @@