print list template editor, in progress
authorphasefx <phasefx@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 14 Feb 2006 14:36:52 +0000 (14:36 +0000)
committerphasefx <phasefx@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 14 Feb 2006 14:36:52 +0000 (14:36 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@3070 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/xul/staff_client/server/circ/print_list_template_editor.js [new file with mode: 0644]
Open-ILS/xul/staff_client/server/circ/print_list_template_editor.xul [new file with mode: 0644]

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
new file mode 100644 (file)
index 0000000..ac8bb34
--- /dev/null
@@ -0,0 +1,180 @@
+dump('entering print_list_template_editor.js\n');
+
+if (typeof circ == 'undefined') circ = {};
+circ.print_list_template_editor = function (params) {
+       try {
+               netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+               JSAN.use('util.error'); this.error = new util.error();
+       } catch(E) {
+               dump('print_list: ' + E + '\n');
+       }
+}
+
+circ.print_list_template_editor.prototype = {
+
+       'init' : function( params ) {
+
+               try {
+                       netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+
+                       var obj = this;
+
+                       obj.session = params['session'];
+
+                       JSAN.use('OpenILS.data'); obj.data = new OpenILS.data(); obj.data.init({'via':'stash'});
+
+                       if (typeof obj.data.print_list_templates == 'undefined') {
+                               obj.data.print_list_types = [ 'items', 'holds' ];
+                               obj.data.print_list_templates = { 
+                                       'items_out' : {
+                                               'type' : 'items',
+                                               'header' : 'Welcome %PATRON_FIRSTNAME%, to %LIBRARY%!\r\nYou have the following items:<hr/><ol>',
+                                               'line_item' : '<li>%TITLE: 50%\r\nBarcode: %COPY_BARCODE% Due: %DUE_D%\r\n',
+                                               'footer' : '</ol><hr />%PINES_CODE% %TODAY%\r\nYou were helped by %STAFF_FIRSTNAME% %STAFF_LASTNAME%',
+                                       }, 
+                                       'checkout' : {
+                                               'type' : 'items',
+                                               'header' : 'Welcome %PATRON_FIRSTNAME%, to %LIBRARY%!\r\nYou checked out the following items:<hr/><ol>',
+                                               'line_item' : '<li>%TITLE%\r\nBarcode: %COPY_BARCODE% Due: %DUE_D%\r\n',
+                                               'footer' : '</ol><hr />%PINES_CODE% %TODAY%\r\nYou were helped by %STAFF_FIRSTNAME% %STAFF_LASTNAME%',
+                                       }, 
+                                       'checkin' : {
+                                               'type' : 'items',
+                                               'header' : 'You checked in the following items:<hr/><ol>',
+                                               'line_item' : '<li>%TITLE%\r\nBarcode: %COPY_BARCODE%\r\n',
+                                               'footer' : '</ol><hr />%PINES_CODE% %TODAY%\r\n',
+                                       }, 
+                                       'holds' : {
+                                               'type' : 'holds',
+                                               'header' : 'Welcome %PATRON_FIRSTNAME%, to %LIBRARY%!\r\nYou have the following titles on hold:<hr/><ol>',
+                                               'line_item' : '<li>%TITLE%\r\n',
+                                               'footer' : '</ol><hr />%PINES_CODE% %TODAY%\r\nYou were helped by %STAFF_FIRSTNAME% %STAFF_LASTNAME%',
+                                       } 
+                               }; 
+
+                               obj.data.stash( 'print_list_templates', 'print_list_types' );
+                       }
+
+                       JSAN.use('util.controller'); obj.controller = new util.controller();
+                       obj.controller.init(
+                               {
+                                       control_map : {
+                                               'header' : [ ['command'], function() {} ],
+                                               'line_item' : [ ['command'], function() {} ],
+                                               'footer' : [ ['command'], function() {} ],
+                                               'preview' : [
+                                                       ['command'],
+                                                       function() {
+                                                               alert( 'preview: ' + obj.controller.view.template_name_menu.value );
+                                                       }
+                                               ],
+                                               'save' : [
+                                                       ['command'],
+                                                       function() {
+                                                               obj.save_template( obj.controller.view.template_name_menu.value );
+                                                       }
+                                               ],
+                                               'delete' : [
+                                                       ['command'],
+                                                       function() {
+                                                               alert( 'not yet implemented' );
+                                                       }
+                                               ],
+                                               'template_name_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(
+                                                                               util.functional.map_object_to_list(
+                                                                                       obj.data.print_list_templates,
+                                                                                       function(o,i) { return [i,i]; }
+                                                                               )
+                                                                       );
+                                                                       ml.setAttribute('id','template_name_menu');
+                                                                       ml.setAttribute('editable','true');
+                                                                       ml.setAttribute('flex','1');
+                                                                       e.appendChild(ml);
+                                                                       obj.controller.view.template_name_menu = ml;
+                                                                       ml.addEventListener(
+                                                                               'command',
+                                                                               function(ev) {
+                                                                                       var tmp = obj.data.print_list_templates[ ev.target.value ];
+                                                                                       obj.controller.view.template_type_menu.value = tmp.type;
+                                                                                       obj.controller.view.header.value = tmp.header;
+                                                                                       obj.controller.view.line_item.value = tmp.line_item;
+                                                                                       obj.controller.view.footer.value = tmp.footer;
+                                                                               },
+                                                                               false
+                                                                       );
+                                                                       setTimeout(
+                                                                               function() {
+                                                                                       var tmp = obj.data.print_list_templates[ ml.value ];
+                                                                                       obj.controller.view.template_type_menu.value = tmp.type;
+                                                                                       obj.controller.view.header.value = tmp.header;
+                                                                                       obj.controller.view.line_item.value = tmp.line_item;
+                                                                                       obj.controller.view.footer.value = tmp.footer;
+                                                                               }, 0
+                                                                       );
+                                                               }
+                                                       }
+                                               ],
+                                               'template_type_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(
+                                                                               util.functional.map_list(
+                                                                                       obj.data.print_list_types,
+                                                                                       function(o) { return [o,o]; }
+                                                                               )
+                                                                       );
+                                                                       ml.setAttribute('id','template_types_menu');
+                                                                       e.appendChild(ml);
+                                                                       obj.controller.view.template_type_menu = ml;
+                                                                       ml.addEventListener(
+                                                                               'command',
+                                                                               function(ev) {
+                                                                                       alert(ev.target.value);
+                                                                               },
+                                                                               false
+                                                                       );
+                                                               }
+                                                       }
+                                               ],
+
+                                       }
+                               }
+                       );
+                       obj.controller.render(); obj.controller.view.template_name_menu.focus();
+
+               } catch(E) {
+                       this.error.sdump('D_ERROR','print_list.init: ' + E + '\n');
+               }
+       },
+
+       'test_template' : function (name) { 
+               var params = { 
+                       'au' : test_patron, 
+                       'lib' : obj.data.list.au[0].home_ou(),
+                       'staff' : obj.data.list.au[0],
+                       'header' : document.getElementById(name + '_header_tb').value,
+                       'line_item' : document.getElementById(name + '_line_item_tb').value,
+                       'footer' : document.getElementById(name + '_footer_tb').value
+               };
+               this.print.print_list( params, sample_view );
+       },
+
+       'save_template' : function(name) {
+               this.data.print_list_templates[name].header = this.controller.view.header.value;
+               this.data.print_list_templates[name].line_item = this.controller.view.line_item.value;
+               this.data.print_list_templates[name].footer = this.controller.view.footer.value;
+               this.data.stash( 'print_list_templates' );
+               alert('Template Saved');
+       },
+}
+
+dump('exiting print_list_template_editor.js\n');
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
new file mode 100644 (file)
index 0000000..30bf1db
--- /dev/null
@@ -0,0 +1,112 @@
+<?xml version="1.0"?>
+<!-- Application: Evergreen Staff Client -->
+<!-- Screen: Example Template for remote xul -->
+
+<!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
+<!-- STYLESHEETS -->
+<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
+<?xml-stylesheet href="chrome://open_ils_staff_client/skin/global.css" type="text/css"?>
+<?xml-stylesheet href="/xul/server/skin/global.css" type="text/css"?>
+
+<!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
+<!-- LOCALIZATION -->
+<!DOCTYPE window SYSTEM "chrome://open_ils_staff_client/locale/lang.dtd">
+
+<!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
+<!-- OVERLAYS -->
+<?xul-overlay href="/xul/server/OpenILS/util_overlay.xul"?>
+
+<window id="print_list_win" 
+       onload="try { my_init(); } catch(E) { alert(E); }"
+       xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+
+       <!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
+       <!-- BEHAVIOR -->
+        <script type="text/javascript">
+               var myPackageDir = 'open_ils_staff_client'; var IAMXUL = true; var g = {};
+       </script>
+        <scripts id="openils_util_scripts"/>
+
+       <script type="text/javascript" src="/xul/server/main/JSAN.js"/>
+       <script>
+       <![CDATA[
+               function my_init() {
+                       try {
+                               netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+                               if (typeof JSAN == 'undefined') { throw( "The JSAN library object is missing."); }
+                               JSAN.errorLevel = "die"; // none, warn, or die
+                               JSAN.addRepository('/xul/server/');
+                               JSAN.use('util.error'); g.error = new util.error();
+                               g.error.sdump('D_TRACE','my_init() for print_list.xul');
+
+                               g.cgi = new CGI();
+                               var session = g.cgi.param('session');
+
+                               JSAN.use('circ.print_list_template_editor');
+                               g.editor = new circ.print_list_template_editor();
+
+                               g.editor.init( 
+                                       { 
+                                               'session' : session,
+                                       } 
+                               );
+
+                               if (typeof window.xulG == 'object' && typeof window.xulG.set_tab_name == 'function') {
+                                       try { window.xulG.set_tab_name('Receipt Template Editor'); } catch(E) { alert(E); }
+                               }
+
+                       } catch(E) {
+                               var err_msg = "!! This software has encountered an error.  Please tell your friendly " +
+                                       "system administrator or software developer the following:\ncirc/print_list.xul\n" + E + '\n';
+                               try { g.error.sdump('D_ERROR',err_msg); } catch(E) { dump(err_msg); }
+                               alert(err_msg);
+                       }
+               }
+
+       ]]>
+       </script>
+
+       <commandset id="print_list_cmds">
+               <command id="cmd_broken" />
+       </commandset>
+
+       <groupbox id="main" flex="1">
+               <caption label="Templates" />
+               <hbox id="top_ui">
+                       <groupbox flex="1">
+                               <caption label="ID" />
+                               <hbox>
+                                       <label value="Name" accesskey="N" control="template_name_menu" />
+                                       <hbox id="template_name_menu_placeholder" flex="1"/>
+                               </hbox>
+                               <hbox>
+                                       <label value="Type" />
+                                       <hbox id="template_type_menu_placeholder" />
+                               </hbox>
+                       </groupbox>
+                       <groupbox>
+                               <caption label="Actions" />
+                               <button id="preview" label="Preview" accesskey="P" />
+                               <button id="save" label="Save" accesskey="S" />
+                               <button id="delete" label="Delete" accesskey="D" />
+                       </groupbox>
+               </hbox>
+               <groupbox orient="horizontal" flex="1">
+                       <caption label="Fields"/>
+                       <groupbox flex="1">
+                               <caption label="Header"/>
+                               <textbox id="header" multiline="true" flex="1"/>
+                       </groupbox>
+                       <groupbox flex="1">
+                               <caption label="Line Item"/>
+                               <textbox id="line_item" multiline="true" flex="1"/>
+                       </groupbox>
+                       <groupbox flex="1">
+                               <caption label="Footer"/>
+                               <textbox id="footer" multiline="true" flex="1"/>
+                       </groupbox>
+               </groupbox>
+       </groupbox>
+
+</window>
+