added a button to mark a single item as received.
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 29 Jul 2008 18:25:06 +0000 (18:25 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 29 Jul 2008 18:25:06 +0000 (18:25 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/branches/acq-experiment@10176 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/web/oilsweb/oilsweb/public/oils/media/ui_js/oils/default/common/jubgrid.js
Open-ILS/web/oilsweb/oilsweb/templates/oils/default/common/jubgrid.html

index 59ff0d1..3b238d6 100644 (file)
@@ -271,6 +271,44 @@ var JUBGrid = {
         openils.acq.Lineitem.createLID(fields, addToStore);
     },
 
+    receiveLID: function(evt) {
+           var list =[];
+           var selected = JUBGrid.jubDetailGrid.selection.getSelected();
+       for (var idx = 0; idx < selected.length; idx++) {
+           var rowIdx = selected[idx];
+           var lid = JUBGrid.jubDetailGrid.model.getRow(rowIdx);
+            list.push(lid.id);
+        }
+        if(lid != null) { // is at least one selected?
+            JUBGrid._receiveLIDList(list, 0, 
+                function() {
+                    delete openils.acq.Lineitem.ModelCache[lid.lineitem];
+                    openils.acq.Lineitem.loadLIDGrid(
+                        JUBGrid.jubDetailGrid, lid.lineitem, JUBGrid.jubDetailGridLayout);
+                }
+            );
+        }
+    },
+
+    // loop through the list of LIDs and mark them as received
+    _receiveLIDList: function(list, idx, callback) {
+        if(idx >= list.length)
+            return callback();
+        fieldmapper.standardRequest(
+            ['open-ils.acq', 'open-ils.acq.lineitem_detail.receive'],
+            {   asnync: true,
+                params: [openils.User.authtoken, list[idx++]],
+                oncomplete: function(r) {
+                    var res = r.recv().content();
+                    if(e = openils.Event.parse(res))
+                        return alert(e);
+                    JUBGrid._receiveLIDList(list, idx, callback);
+                }
+            }
+        );
+    },
+
+
     // called when a lineitem is edited
     onJUBSet: function (griditem, attr, oldVal,newVal) {
         var item;
index dfc8087..1506331 100644 (file)
@@ -188,6 +188,9 @@ pointing to the JUB model (and store) that you have created.
            <button dojoType='dijit.form.Button' onclick='JUBGrid.deleteLID'>
                ${_('Delete Selected Copy')}
            </button>
+           <button dojoType='dijit.form.Button' onclick='JUBGrid.receiveLID'>
+               ${_('Mark Selected Copies Received')}
+           </button>
        </div>
         <div structure='JUBGrid.jubDetailGridLayout' jsid="JUBGrid.jubDetailGrid" dojoType="dojox.Grid"
             id='${domprefix + "-details-grid"}'>