flesh out scan item as missing pieces dialog
authorphasefx <phasefx@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 27 Jul 2010 22:33:01 +0000 (22:33 +0000)
committerphasefx <phasefx@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 27 Jul 2010 22:33:01 +0000 (22:33 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@17045 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/xul/staff_client/server/cat/util.js
Open-ILS/xul/staff_client/server/circ/missing_pieces.js
Open-ILS/xul/staff_client/server/circ/missing_pieces.xul
Open-ILS/xul/staff_client/server/locale/en-US/circ.properties

index 89d5bb3..9622a72 100644 (file)
@@ -740,6 +740,7 @@ cat.util.render_loan_duration = function(value) {
 }
 
 cat.util.mark_item_as_missing_pieces = function(copy_ids) {
+    alert(js2JSON(copy_ids));
 }
 
 dump('exiting cat/util.js\n');
index 99eca39..579726e 100644 (file)
@@ -7,28 +7,42 @@ function my_init() {
         JSAN.errorLevel = "die"; // none, warn, or die
         JSAN.addRepository('/xul/server/');
         JSAN.use('util.error'); error = new util.error();
-        error.sdump('D_TRACE','my_init() for main_test.xul');
-
-        dojo.require('openils.PermaCrud');
-
-        var types = new openils.PermaCrud(
-            {
-                authtoken :ses()
-            }
-        ).retrieveAll('coust');
-
-        dojo.forEach(types,
-            function(type) {
-                alert( js2JSON(type) );
-            }
+        error.sdump('D_TRACE','my_init() for missing_pieces.xul');
+
+        JSAN.use('util.network');
+        var network = new util.network();
+
+        // Why the indirection of missing_pieces.xul instead of calling window.prompt in chrome/content/main/menu.js directly?
+        // So we can get free remote upgrades of the logic behind cat.util.mark_item_as_missing_pieces, since I can't call
+        // JSAN.use('cat.util'); in menu.js
+        var barcode = window.prompt(
+            $("circStrings").getString('staff.circ.missing_pieces.scan_item.prompt'),
+            '',
+            $("circStrings").getString('staff.circ.missing_pieces.scan_item.title')
         );
+        if (!barcode) {
+            window.close();
+            return;
+        }
 
-        if (typeof window.xulG == 'object' && typeof window.xulG.set_tab_name == 'function') {
-            try { window.xulG.set_tab_name('Test'); } catch(E) { alert(E); }
+        var copy;
+        try {
+            copy = network.simple_request('FM_ACP_RETRIEVE_VIA_BARCODE',[ barcode ]);
+            if (typeof copy.ilsevent != 'undefined') throw(copy); 
+            if (!copy) throw(copy);
+        } catch(E) {
+            alert($("circStrings").getFormattedString('staff.circ.missing_pieces.scan_item.error_alert', [barcode]) + '\n');
+            window.close();
+            return;
         }
 
+        JSAN.use('cat.util');
+        cat.util.mark_item_as_missing_pieces( [ copy.id() ] );
+        window.close();
     } catch(E) {
-        try { error.standard_unexpected_error_alert('main/test.xul',E); } catch(F) { alert(E); }
+        try { error.standard_unexpected_error_alert('circ/missing_pieces.xul',E); } catch(F) { alert(E); }
+        window.close();
     }
 }
 
index 6e0602b..303e6ce 100644 (file)
     </script>
     <scripts id="openils_util_scripts"/>
 
+    <messagecatalog id="circStrings" src="/xul/server/locale/<!--#echo var='locale'-->/circ.properties" />
+
     <script type="text/javascript" src="/xul/server/main/JSAN.js"/>
     <script type="text/javascript" src="missing_pieces.js"/>
 
-    <label value="retrieving coust's with dojo and PermaCrud..."/>
-
 </window>
 
index c0ce402..5a84b42 100644 (file)
@@ -450,3 +450,6 @@ staff.circ.holds.alt_view.label=Detail View
 staff.circ.holds.alt_view.accesskey=V
 staff.circ.holds.list_view.label=List View
 staff.circ.holds.list_view.accesskey=V
+staff.circ.missing_pieces.scan_item.prompt=Enter barcode for item missing pieces:
+staff.circ.missing_pieces.scan_item.title=Missing Pieces
+staff.circ.missing_pieces.scan_item.error_alert=No item with barcode "%1$s"