safer copy editor with copy status
authorphasefx <phasefx@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 14 Aug 2006 16:22:51 +0000 (16:22 +0000)
committerphasefx <phasefx@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 14 Aug 2006 16:22:51 +0000 (16:22 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@5487 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/xul/staff_client/chrome/content/main/constants.js
Open-ILS/xul/staff_client/server/cat/copy_editor.js

index be4edc5..3794bbc 100644 (file)
@@ -1,4 +1,14 @@
 dump('Loading constants.js\n');
+
+const my_constants = {
+       'magical_statuses' : {
+               '1' : 't', /* | Checked out    | t */
+               '3' : 't', /* | Lost           | f */
+               '6' : 't', /* | In transit     | t */
+               '8' : 't', /* | On holds shelf | t */
+       }
+}
+
 const api = {
        'AUTH_INIT' : { 'app' : 'open-ils.auth', 'method' : 'open-ils.auth.authenticate.init' },
        'AUTH_COMPLETE' : { 'app' : 'open-ils.auth', 'method' : 'open-ils.auth.authenticate.complete' },
index 9c0bd96..9ba013d 100644 (file)
@@ -75,7 +75,8 @@ function my_init() {
                                                "Status",
                                                { 
                                                        render: 'typeof fm.status() == "object" ? fm.status().name() : g.data.hash.ccs[ fm.status() ].name()', 
-                                                       input: 'c = function(v){ g.apply("status",v); if (typeof post_c == "function") post_c(v); }; x = util.widgets.make_menulist( util.functional.map_list( g.data.list.ccs, function(obj) { return [ obj.name(), obj.id() ]; } ).sort() ); x.addEventListener("apply",function(f){ return function(ev) { f(ev.target.value); } }(c), false);',
+                                                       input: g.safe_to_edit_copy_status() ? 'c = function(v){ g.apply("status",v); if (typeof post_c == "function") post_c(v); }; x = util.widgets.make_menulist( util.functional.map_list( g.data.list.ccs, function(obj) { return [ obj.name(), obj.id(), typeof my_constants.magical_statuses[obj.id()] != "undefined" ? true : false ]; } ).sort() ); x.addEventListener("apply",function(f){ return function(ev) { f(ev.target.value); } }(c), false);' : undefined,
+                                                       //input: 'c = function(v){ g.apply("status",v); if (typeof post_c == "function") post_c(v); }; x = util.widgets.make_menulist( util.functional.map_list( util.functional.filter_list( g.data.list.ccs, function(obj) { return typeof my_constants.magical_statuses[obj.id()] == "undefined"; } ), function(obj) { return [ obj.name(), obj.id() ]; } ).sort() ); x.addEventListener("apply",function(f){ return function(ev) { f(ev.target.value); } }(c), false);',
                                                }
                                        ]
                                ].concat(g.panes_and_field_names.left_pane);
@@ -349,6 +350,23 @@ g.apply_stat_cat = function(sc_id,entry_id) {
 }
 
 /******************************************************************************************************/
+/* This returns true if none of the copies being edited have a magical status found in my_constants.magical_statuses */
+
+g.safe_to_edit_copy_status = function() {
+       try {
+               var safe = true;
+               for (var i = 0; i < g.copies.length; i++) {
+                       var status = g.copies[i].status(); if (typeof status == 'object') status = status.id();
+                       if (typeof my_constants.magical_statuses[ status ] != 'undefined') safe = false;
+               }
+               return safe;
+       } catch(E) {
+               g.error.standard_unexpected_error_alert('safe_to_edit_copy_status?',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) {