[open-ils-commits] r16881 - in trunk/Open-ILS/web: js/ui/default/acq/common js/ui/default/acq/lineitem templates/default/acq/lineitem (senator)

svn at svn.open-ils.org svn at svn.open-ils.org
Thu Jul 8 11:11:26 EDT 2010


Author: senator
Date: 2010-07-08 11:11:24 -0400 (Thu, 08 Jul 2010)
New Revision: 16881

Modified:
   trunk/Open-ILS/web/js/ui/default/acq/common/li_table.js
   trunk/Open-ILS/web/js/ui/default/acq/lineitem/related.js
   trunk/Open-ILS/web/templates/default/acq/lineitem/related.tt2
Log:
Acq: If you go from a catalog record to "View/Place orders", there are now
easy shortcuts for adding a new lineitem to a selection list or a PO if there
aren't already any existing lineitems to work with.



Modified: trunk/Open-ILS/web/js/ui/default/acq/common/li_table.js
===================================================================
--- trunk/Open-ILS/web/js/ui/default/acq/common/li_table.js	2010-07-08 14:56:37 UTC (rev 16880)
+++ trunk/Open-ILS/web/js/ui/default/acq/common/li_table.js	2010-07-08 15:11:24 UTC (rev 16881)
@@ -1838,41 +1838,7 @@
                 break;
 
             case 'create_order':
-
-                if(!this.createPoProviderSelector) {
-                    var widget = new openils.widget.AutoFieldWidget({
-                        fmField : 'provider',
-                        fmClass : 'acqpo',
-                        searchFilter: {"active": "t"},
-                        parentNode : dojo.byId('acq-lit-po-provider'),
-                        dijitArgs : {
-                            "onChange": function() {
-                                if (this.item) {
-                                    self._updateCreatePoPrepayCheckbox(
-                                        this.item.prepayment_required
-                                    );
-                                }
-                            }
-                        }
-                    });
-                    widget.build(
-                        function(w) { self.createPoProviderSelector = w; }
-                    );
-                }
-
-                if(!this.createPoAgencySelector) {
-                    var widget = new openils.widget.AutoFieldWidget({
-                        fmField : 'ordering_agency',
-                        fmClass : 'acqpo',
-                        parentNode : dojo.byId('acq-lit-po-agency'),
-                        orgLimitPerms : ['CREATE_PURCHASE_ORDER'],
-                    });
-                    widget.build(
-                        function(w) { self.createPoAgencySelector = w; }
-                    );
-                }
-
-         
+                this._loadPOSelect();
                 acqLitPoCreateDialog.show();
                 break;
 
@@ -2408,7 +2374,38 @@
         );
     }
 
-    this._loadPLSelect = function() {
+    this._loadPOSelect = function() {
+        if (!this.createPoProviderSelector) {
+            var widget = new openils.widget.AutoFieldWidget({
+                "fmField": "provider",
+                "fmClass": "acqpo",
+                "searchFilter": {"active": "t"},
+                "parentNode": dojo.byId("acq-lit-po-provider"),
+                "dijitArgs": {
+                    "onChange": function() {
+                        if (this.item) {
+                            self._updateCreatePoPrepayCheckbox(
+                                this.item.prepayment_required
+                            );
+                        }
+                    }
+                }
+            });
+            widget.build(function(w) { self.createPoProviderSelector = w; });
+        }
+
+        if (!this.createPoAgencySelector) {
+            var widget = new openils.widget.AutoFieldWidget({
+                "fmField": "ordering_agency",
+                "fmClass": "acqpo",
+                "parentNode": dojo.byId("acq-lit-po-agency"),
+                "orgLimitPerms": ["CREATE_PURCHASE_ORDER"],
+            });
+            widget.build(function(w) { self.createPoAgencySelector = w; });
+        }
+    };
+
+    this._loadPLSelect = function(preSel) {
         if(this._plSelectLoaded) return;
         var plList = [];
         function handleResponse(r) {
@@ -2424,7 +2421,8 @@
                     self._plSelectLoaded = true;
                     acqLitAddExistingSelect.store = 
                         new dojo.data.ItemFileReadStore({data:acqpl.toStoreData(plList)});
-                    acqLitAddExistingSelect.setValue();
+
+                    acqLitAddExistingSelect.setValue(preSel);
                 }
             }
         );

Modified: trunk/Open-ILS/web/js/ui/default/acq/lineitem/related.js
===================================================================
--- trunk/Open-ILS/web/js/ui/default/acq/lineitem/related.js	2010-07-08 14:56:37 UTC (rev 16880)
+++ trunk/Open-ILS/web/js/ui/default/acq/lineitem/related.js	2010-07-08 15:11:24 UTC (rev 16881)
@@ -35,6 +35,7 @@
     if(identTarget == 'bib')
         var method = 'open-ils.acq.lineitems_for_bib.by_bib_id';
 
+    var total = 0;
     fieldmapper.standardRequest(
         ["open-ils.acq", method], {
             "async": true,
@@ -46,9 +47,14 @@
             "onresponse": function(r) {
                 var resp = openils.Util.readResponse(r);
                 if (resp) {
+                    total++;
                     liTable.show("list");
                     liTable.addLineitem(resp);
                 }
+            },
+            "oncomplete": function() {
+                if (!total)
+                    openils.Util.show("li_create_holder");
             }
         }
     );
@@ -69,78 +75,63 @@
     }) 
 }
 
-function addLi(fields) {
-
-    var li = new fieldmapper.jub();
-    li.marc(bibRecord.marc());
-    li.eg_bib_id(bibRecord.id());
-    if(fields.picklist) li.picklist(fields.picklist);
-    if(fields.po) li.po(fields.po);
-    li.selector(openils.User.user.id());
-    li.creator(openils.User.user.id());
-    li.editor(openils.User.user.id());
-
-    fieldmapper.standardRequest(
-        ['open-ils.acq', 'open-ils.acq.lineitem.create'],
-        {   async : true,
-            params : [openils.User.authtoken, li],
-            oncomplete : function(r) {
-                var id = openils.Util.readResponse(r);
-                if(!id) return;
-                if(fields.picklist) 
-                    location.href = oilsBasePath + '/acq/picklist/view/' + fields.picklist;
-                else
-                    location.href = oilsBasePath + '/acq/po/view/' + fields.po;
-            }
-        }
-    );
-}
-
-function loadPl() {
-
-    if(paramPL) {
-
+function createLi(oncomplete) {
+    return function() {
+        progressDialog.show();
+        liTable.reset();
         fieldmapper.standardRequest(
-            ['open-ils.acq', 'open-ils.acq.picklist.retrieve'],
-            {   async: true,
-                params: [openils.User.authtoken, paramPL], 
-                oncomplete : function(r) {
-                    var pl = openils.Util.readResponse(r);
-                    plSelector.store = 
-                        new dojo.data.ItemFileReadStore({data:fieldmapper.acqpl.toStoreData([pl])});
-                    plSelector.attr('value', pl.name());
-                    plSelector.attr('disabled', true);
+            ["open-ils.acq", "open-ils.acq.biblio.create_by_id"], {
+                "params": [
+                    openils.User.authtoken, [bibRecord.id()], {
+                        "flesh_attrs": true,
+                        "flesh_cancel_reason": true,
+                        "flesh_notes": true
+                    }
+                ],
+                "async": true,
+                "onresponse": function(r) {
+                    var li = openils.Util.readResponse(r);
+                    if (typeof(li) == "object") {
+                        liTable.show("list");
+                        liTable.addLineitem(li);
+                        dojo.query(
+                            "input[name='selectbox']", liTable._findLiRow(li)
+                        )[0].checked = true;
+                    }
+                },
+                "oncomplete": function() {
+                    progressDialog.hide();
+                    openils.Util.hide("li_create_holder");
+                    oncomplete();
                 }
             }
         );
+    };
+}
 
-    } else {
-
-        fieldmapper.standardRequest(
-            ['open-ils.acq', 'open-ils.acq.picklist.user.retrieve.atomic'],
-            {   async: true,
-                params: [openils.User.authtoken], 
-                oncomplete : function(r) {
-                    var list = openils.Util.readResponse(r);
-                    plSelector.store = 
-                        new dojo.data.ItemFileReadStore({data:fieldmapper.acqpl.toStoreData(list)});
-                }
-            }
-        );
-    }
+function prepareButtons() {
+    addToPlButton.onClick = createLi(
+        function() { /* oncomplete */
+            liTable._loadPLSelect(paramPL);
+            acqLitSavePlDialog.show();
+        }
+    );
+    createPoButton.onClick = createLi(
+        function() { /* oncomplete */
+            liTable._loadPOSelect();
+            acqLitPoCreateDialog.show();
+        }
+    );
 }
 
-
 function load() {
     var cgi = new openils.CGI();
 
     identTarget = cgi.param('target');
     paramPL = cgi.param('pl');
-    paramPO = cgi.param('po');
+//    paramPO = cgi.param('po');
 
-    loadPl();
-
-    if(identTarget == 'bib') {
+    if (identTarget == 'bib') {
         fetchBib();
     } else {
         fetchLi(); 
@@ -150,6 +141,7 @@
     liTable.reset();
     liTable._isRelatedViewer = true;
 
+    prepareButtons();
     fetchRelated();
 }
 

Modified: trunk/Open-ILS/web/templates/default/acq/lineitem/related.tt2
===================================================================
--- trunk/Open-ILS/web/templates/default/acq/lineitem/related.tt2	2010-07-08 14:56:37 UTC (rev 16880)
+++ trunk/Open-ILS/web/templates/default/acq/lineitem/related.tt2	2010-07-08 15:11:24 UTC (rev 16881)
@@ -38,23 +38,14 @@
             <div type='opac/slot-data' query='datafield[tag=260] subfield[code=c]'/>
         </li>
     </ul>
-    <div dojoType="dijit.form.DropDownButton">
-        <span>Create New Lineitem For This Record</span>
-        <div dojoType="dijit.TooltipDialog"  execute="addLi(arguments[0]);">
-            <table>
-                <tbody>
-                    <tr>
-                        <td>Add To Selection List</td>
-                        <td style='padding-left:10px;'><div name='picklist' jsId='plSelector' dojoType='dijit.form.FilteringSelect'/></td>
-                    </tr>
-                    <tr>
-                        <td colspan='2' style='align:center'>
-                            <button dojoType="dijit.form.Button" type="submit">Create</button>
-                        </td>
-                    </tr>
-                </tbody>
-            </table>
-        </div>
+
+    <div id="li_create_holder" class="hidden">
+        <button jsId="addToPlButton" dojoType="dijit.form.Button">
+            Add to New Selection List
+        </button>
+        <button jsId="createPoButton" dojoType="dijit.form.Button">
+            Create a New Purchase Order
+        </button>
     </div>
 
 </div>



More information about the open-ils-commits mailing list