for user requests, View Picklist instead of Add to Picklist where appropriate. TODO...
authorphasefx <phasefx@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 24 Mar 2010 16:08:17 +0000 (16:08 +0000)
committerphasefx <phasefx@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 24 Mar 2010 16:08:17 +0000 (16:08 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@15947 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/web/js/ui/default/acq/picklist/user_request.js
Open-ILS/web/templates/default/acq/picklist/user_request.tt2

index ca0f04c..6e5a6be 100644 (file)
@@ -28,6 +28,15 @@ function drawRequest() {
     // hide the grid and the context selector
     dijit.byId('stackContainer').forward();
 
+    // toggle the View Picklist/Add to Picklist button label
+    if (aur_obj.lineitem()) {
+        openils.Util.addCSSClass( document.getElementById('add_to_picklist'), 'hidden' );
+        openils.Util.removeCSSClass( document.getElementById('view_picklist'), 'hidden' );
+    } else {
+        openils.Util.addCSSClass( document.getElementById('view_picklist'), 'hidden' );
+        openils.Util.removeCSSClass( document.getElementById('add_to_picklist'), 'hidden' );
+    }
+
     // draw a detail page for a particular request
     var div = document.getElementById('detail_content_pane');
     while (div.lastChild) { div.removeChild( div.lastChild ); }
@@ -43,8 +52,26 @@ function drawRequest() {
     // and to "reject" it (aka apply a cancel reason)
 }
 
+function fooPicklist() {
+    if (aur_obj.lineitem()) {
+        viewPicklist();
+    } else {
+        addToPicklist();
+    }
+}
+
+function viewPicklist() {
+    var lineitem = fieldmapper.standardRequest(
+        [ 'open-ils.acq', 'open-ils.acq.lineitem.retrieve' ],
+        {
+            params: [openils.User.authtoken, aur_obj.lineitem()]
+        }
+    );
+    location.href = oilsBasePath + "/acq/picklist/view/" + lineitem.picklist();
+}
+
 function addToPicklist() {
-    // reqId
+    // reqId, from detail view
     location.href = oilsBasePath + "/acq/picklist/brief_record?ur=" + reqId + "&prepop=" + encodeURIComponent(js2JSON({
         "1": aur_obj.title() || aur_obj.article_title() || aur_obj.volume(),
         "2": aur_obj.author(),
@@ -55,13 +82,29 @@ function addToPicklist() {
 }
 
 function setNoHold() {
-    // reqId
-    alert('stub');
+    // reqId, from detail view
+    fieldmapper.standardRequest(
+        [ 'open-ils.acq', 'open-ils.acq.user_request.set_no_hold.batch' ],
+        {   async: true,
+            params: [openils.User.authtoken, [reqId]],
+            oncomplete: function(r) {
+                drawRequest();
+            }
+        }
+    );
 }
 
 function cancelRequest() {
-    // reqId
-    alert('stub');
+    // reqId, from detail view
+    fieldmapper.standardRequest(
+        [ 'open-ils.acq', 'open-ils.acq.user_request.cancel.batch' ],
+        {   async: true,
+            params: [openils.User.authtoken, [reqId]],
+            oncomplete: function(r) {
+                drawRequest();
+            }
+        }
+    );
 }
 
 // format the title data as id:title
index f89553c..4173297 100644 (file)
@@ -48,7 +48,7 @@
                 <div>Patron Request</div>
                 <div>
                     <button dojoType="dijit.form.Button" onClick="location.href=oilsBasePath+'/acq/picklist/user_request'">[% ctx.page_title %]</button>
-                    <button dojoType="dijit.form.Button" onClick="addToPicklist()">Add to Picklist</button>
+                    <button dojoType="dijit.form.Button" onClick="fooPicklist()"><span id="add_to_picklist">Add to Picklist</span><span id="view_picklist">View Picklist</span></button>
                     <button dojoType="dijit.form.Button" onClick="setNoHold()">Set No Hold</button>
                     <button dojoType="dijit.form.Button" onClick="cancelRequest()">Cancel Request with Reason</button>
                 </div>