From 64c9debfa75be900e34fd51bb0fec1fe7c06f8fa Mon Sep 17 00:00:00 2001 From: Jason Etheridge Date: Fri, 16 Mar 2012 15:54:59 -0400 Subject: [PATCH] prevent templates from changing unsafe fields in the Item Attribute Editor, for any of the fields are hidden via util.hide, and for statuses which shouldn't be changed (like from Checked Out to something else) Signed-off-by: Jason Etheridge Signed-off-by: Bill Erickson Signed-off-by: Mike Rylander --- .../xul/staff_client/server/cat/copy_editor.js | 31 ++++++++++++++++++++++ .../server/locale/en-US/cat.properties | 1 + 2 files changed, 32 insertions(+) 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 2d1579cf62..f4af66073d 100644 --- a/Open-ILS/xul/staff_client/server/cat/copy_editor.js +++ b/Open-ILS/xul/staff_client/server/cat/copy_editor.js @@ -324,6 +324,19 @@ g._apply_template = function(name,apply_volume_editor_template_changes) { if (g.templates[ name ] != 'undefined') { var template = g.templates[ name ]; for (var i in template) { + if (g.is_field_hidden(i)) { + alert($('catStrings').getFormattedString( + 'staff.cat.copy_editor.apply_unsafe_field', + [i] + )); + continue; + } + if (template[i].field == 'status') { + if (!g.safe_to_edit_copy_status()) { + alert($('catStrings').getFormattedString('staff.cat.copy_editor.apply_unsafe_field',[i])); + continue; + } + } g.changed[ i ] = template[ i ]; switch( template[i].type ) { case 'attribute' : @@ -653,6 +666,23 @@ g.safe_to_edit_copy_status = function() { } /******************************************************************************************************/ +/* This returns true if the field has been hidden via util.hide */ + +g.is_field_hidden = function(field) { + try { + g.data.stash_retrieve(); + if (g.data.hash.aous['ui.hide_copy_editor_fields'] + && g.data.hash.aous['ui.hide_copy_editor_fields'].indexOf(field) > -1) { + return true; + } + } catch(E) { + g.error.standard_unexpected_error_alert('is_field_hidden?',E); + return false; + } +} + + +/******************************************************************************************************/ /* This concats and uniques all the alert messages for use as the default value for a new alert message */ g.populate_alert_message_input = function(tb) { @@ -1293,6 +1323,7 @@ g.render = function() { } } + util.hide.generate_css('ui.hide_copy_editor_fields'); } /******************************************************************************************************/ diff --git a/Open-ILS/xul/staff_client/server/locale/en-US/cat.properties b/Open-ILS/xul/staff_client/server/locale/en-US/cat.properties index f8ac40c0db..edff8b0d3b 100644 --- a/Open-ILS/xul/staff_client/server/locale/en-US/cat.properties +++ b/Open-ILS/xul/staff_client/server/locale/en-US/cat.properties @@ -150,6 +150,7 @@ staff.cat.copy_editor.import_templates.save.success=All templates saved. staff.cat.copy_editor.import_templates.save.error=Error saving templates staff.cat.copy_editor.import_templates.note=Note: These imported templates will get saved along with any new template you try to create, but if that does not happen, then these templates will disappear with the next invocation of the item attribute editor. staff.cat.copy_editor.import_templates.error=Error importing templates +staff.cat.copy_editor.apply_unsafe_field=Template tried to change field '%1$s', which is not allowed currently. staff.cat.copy_editor.apply_owning_lib.undefined_volume.error=Error retrieving Volume information for copy %1$s. The owning library for this copy will not be changed. staff.cat.copy_editor.apply_owning_lib.call_number.error=Error changing owning library for copy %1$s. The owning library for this copy will not be changed. staff.cat.copy_editor.copy_count=1 copy -- 2.11.0