prevent templates from changing unsafe fields
authorJason Etheridge <jason@esilibrary.com>
Fri, 16 Mar 2012 19:54:59 +0000 (15:54 -0400)
committerMike Rylander <mrylander@gmail.com>
Mon, 2 Apr 2012 11:47:38 +0000 (07:47 -0400)
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 <jason@esilibrary.com>
Signed-off-by: Bill Erickson <berick@esilibrary.com>
Signed-off-by: Mike Rylander <mrylander@gmail.com>

Open-ILS/xul/staff_client/server/cat/copy_editor.js
Open-ILS/xul/staff_client/server/locale/en-US/cat.properties

index 2d1579c..f4af660 100644 (file)
@@ -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');
 }
 
 /******************************************************************************************************/
index f8ac40c..edff8b0 100644 (file)
@@ -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