From: Jason Etheridge Date: Mon, 28 Feb 2011 20:36:21 +0000 (-0500) Subject: maintain a list of applied templates so that we can re-apply them as items get added... X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=c09450f989aad4e53e61d1723bd56a44f98a2a1f;p=evergreen%2Fequinox.git maintain a list of applied templates so that we can re-apply them as items get added/changed in the volume/copy creator --- diff --git a/Open-ILS/xul/staff_client/server/cat/copy_editor.js b/Open-ILS/xul/staff_client/server/cat/copy_editor.js index 1b8f5aa614..9b9d57fd35 100644 --- a/Open-ILS/xul/staff_client/server/cat/copy_editor.js +++ b/Open-ILS/xul/staff_client/server/cat/copy_editor.js @@ -176,6 +176,9 @@ function my_init() { try { g.copies = xulG.copies; g.original_copies = js2JSON( g.copies ); + for (var i = 0; i < g.applied_templates.length; i++) { + g._apply_template( g.applied_templates[i] ); + } g.summarize( g.copies ); g.render(); g.check_for_unmet_required_fields(); @@ -241,10 +244,26 @@ g.retrieve_templates = function() { /******************************************************************************************************/ /* Apply Template */ +g.applied_templates = []; + g.apply_template = function() { try { var name = g.template_menu.value; if (g.templates[ name ] != 'undefined') { + g.applied_templates.push( name ); + g._apply_template(name); + g.summarize( g.copies ); + g.render(); + g.check_for_unmet_required_fields(); + } + } catch(E) { + g.error.standard_unexpected_error_alert($('catStrings').getString('staff.cat.copy_editor.apply_templates.error'), E); + } +} + +g._apply_template = function(name) { + try { + if (g.templates[ name ] != 'undefined') { var template = g.templates[ name ]; for (var i in template) { g.changed[ i ] = template[ i ]; @@ -260,12 +279,9 @@ g.apply_template = function() { break; } } - g.summarize( g.copies ); - g.render(); - g.check_for_unmet_required_fields(); } } catch(E) { - g.error.standard_unexpected_error_alert($('catStrings').getString('staff.cat.copy_editor.apply_templates.error'), E); + alert('Error in copy_editor.js, g._apply_template('+name+'): ' + E); } } @@ -425,6 +441,7 @@ g.import_templates = function() { /* Restore backup copies */ g.reset = function() { + g.applied_templates = []; g.changed = {}; g.copies = JSON2js( g.original_copies ); g.summarize( g.copies );