[open-ils-commits] r16284 - in trunk/Open-ILS: examples src/perlmods/OpenILS/Application/Acq web/js/dojo/openils/acq/nls web/js/ui/default/acq/common web/templates/default/acq/common (senator)

svn at svn.open-ils.org svn at svn.open-ils.org
Wed Apr 21 17:02:01 EDT 2010


Author: senator
Date: 2010-04-21 17:01:55 -0400 (Wed, 21 Apr 2010)
New Revision: 16284

Modified:
   trunk/Open-ILS/examples/fm_IDL.xml
   trunk/Open-ILS/src/perlmods/OpenILS/Application/Acq/Lineitem.pm
   trunk/Open-ILS/web/js/dojo/openils/acq/nls/acq.js
   trunk/Open-ILS/web/js/ui/default/acq/common/li_table.js
   trunk/Open-ILS/web/templates/default/acq/common/li_table.tt2
Log:
Acq: added UI controls to attach a claim policy to one or many lineitems

Incidentally, two bugs were fixed:
    1) Incorrect permacrud action entries in the IDL that stopped
       open-ils.pcrud from generating methods for the jub and acqlih
       classes.
    2) A widely used acq subroutine, retrieve_lineitem_impl, incorrectly
       cleared the purchase_order and picklist fields of its result if
       fleshing for those fields was not specifically requested. The
       correct behavior is to set those fields back to their integer
       foreign key values. This was causing several subtle problems.


Modified: trunk/Open-ILS/examples/fm_IDL.xml
===================================================================
--- trunk/Open-ILS/examples/fm_IDL.xml	2010-04-21 13:33:55 UTC (rev 16283)
+++ trunk/Open-ILS/examples/fm_IDL.xml	2010-04-21 21:01:55 UTC (rev 16284)
@@ -5464,10 +5464,12 @@
 			<link field="order_summary" reltype="might_have" key="lineitem" map="" class="acqlisum"/>
 		</links>
 		<permacrud xmlns="http://open-ils.org/spec/opensrf/IDL/permacrud/v1">
-            <retrieve permission="CREATE_PURCHASE_ORDER VIEW_PURCHASE_ORDER CREATE_PICKLIST VIEW_PICKLIST">
-                <context link="purchase_order" field="ordering_agency"/>
-                <context link="picklist" field="org_unit"/>
-            </retrieve>
+			<actions>
+				<retrieve permission="CREATE_PURCHASE_ORDER VIEW_PURCHASE_ORDER CREATE_PICKLIST VIEW_PICKLIST">
+					<context link="purchase_order" field="ordering_agency"/>
+					<context link="picklist" field="org_unit"/>
+				</retrieve>
+			</actions>
 		</permacrud>
 	</class>
 
@@ -5508,10 +5510,12 @@
 			<link field="claim_policy" reltype="has_a" key="id" map="" class="acqclp"/>
 		</links>
 		<permacrud xmlns="http://open-ils.org/spec/opensrf/IDL/permacrud/v1">
-            <retrieve permission="CREATE_PURCHASE_ORDER VIEW_PURCHASE_ORDER">
-                <context link="purchase_order" field="ordering_agency"/>
-                <context link="picklist" field="org_unit"/>
-            </retrieve>
+			<actions>
+				<retrieve permission="CREATE_PURCHASE_ORDER VIEW_PURCHASE_ORDER">
+					<context link="purchase_order" field="ordering_agency"/>
+					<context link="picklist" field="org_unit"/>
+				</retrieve>
+			</actions>
 		</permacrud>
 	</class>
 

Modified: trunk/Open-ILS/src/perlmods/OpenILS/Application/Acq/Lineitem.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Application/Acq/Lineitem.pm	2010-04-21 13:33:55 UTC (rev 16283)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Application/Acq/Lineitem.pm	2010-04-21 21:01:55 UTC (rev 16284)
@@ -141,8 +141,14 @@
                 $li->picklist->org_unit, $li->picklist)
     );
 
-    $li->clear_purchase_order unless $$options{flesh_po};
-    $li->clear_picklist unless $$options{flesh_pl};
+    unless ($$options{flesh_po}) {
+        $li->purchase_order(
+            $li->purchase_order ? $li->purchase_order->id : undef
+        );
+    }
+    unless ($$options{flesh_pl}) {
+        $li->picklist($li->picklist ? $li->picklist->id : undef);
+    }
     return $li;
 }
 
@@ -200,7 +206,7 @@
 	method => 'update_lineitem',
 	api_name	=> 'open-ils.acq.lineitem.update',
 	signature => {
-        desc => 'Update a lineitem',
+        desc => 'Update one or many lineitems',
         params => [
             {desc => 'Authentication token', type => 'string'},
             {desc => 'lineitem object update', type => 'object'}
@@ -213,8 +219,13 @@
     my($self, $conn, $auth, $li) = @_;
     my $e = new_editor(xact=>1, authtoken=>$auth);
     return $e->die_event unless $e->checkauth;
-    my $evt = update_lineitem_impl($e, $li);
-    return $evt if $evt;
+
+    $li = [$li] unless ref $li eq "ARRAY";
+    foreach (@$li) {
+        my $evt = update_lineitem_impl($e, $_);
+        return $evt if $evt;
+    }
+
     $e->commit;
     return 1;
 }
@@ -230,8 +241,7 @@
     ]) or return $e->die_event;
 
     # the marc may have been cleared on retrieval...
-    $li->marc($e->retrieve_acq_lineitem($li->id)->marc)
-        unless $li->marc;
+    $li->marc($orig_li->marc) unless $li->marc;
 
     $li->editor($e->requestor->id);
     $li->edit_time('now');

Modified: trunk/Open-ILS/web/js/dojo/openils/acq/nls/acq.js
===================================================================
--- trunk/Open-ILS/web/js/dojo/openils/acq/nls/acq.js	2010-04-21 13:33:55 UTC (rev 16283)
+++ trunk/Open-ILS/web/js/dojo/openils/acq/nls/acq.js	2010-04-21 21:01:55 UTC (rev 16284)
@@ -71,5 +71,7 @@
     'NO_FIND_INVOICE': "Could not find that invoice.\nNote that the Invoice # field is case-sensitive.",
     'NO_LI_TO_CLAIM': "You have not selected any lineitems to claim.",
     'CLAIM_VOUCHERS': "Claim Vouchers",
-    'PRINT': "Print"
+    'PRINT': "Print",
+    'ATTACH_CLAIM_POLICY': "Attach claim policy",
+    'CHANGE_CLAIM_POLICY': "Change claim policy"
 }

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-04-21 13:33:55 UTC (rev 16283)
+++ trunk/Open-ILS/web/js/ui/default/acq/common/li_table.js	2010-04-21 21:01:55 UTC (rev 16284)
@@ -188,6 +188,42 @@
         td.appendChild(document.createTextNode(val));
     };
 
+    this.setClaimPolicyControl = function(li, row) {
+        if (!self.claimPolicyPicker) {
+            self.claimPolicyPicker = true; /* prevents a race condition */
+            new openils.widget.AutoFieldWidget({
+                "parentNode": "acq-lit-li-claim-policy",
+                "fmClass": "acqclp",
+                "selfReference": true,
+                "dijitArgs": {"required": true}
+            }).build(function(w) { self.claimPolicyPicker = w; });
+        }
+
+        if (typeof(row) == "undefined")
+            row = dojo.query('tr[li="' + li.id() + '"]', "acq-lit-tbody")[0];
+
+        var actViewPolicy = nodeByName("action_view_claim_policy", row);
+        if (li.claim_policy())
+            actViewPolicy.innerHTML = localeStrings.CHANGE_CLAIM_POLICY;
+
+        if (!actViewPolicy.onclick) {
+            actViewPolicy.onclick = function() {
+                if (li.claim_policy())
+                    self.claimPolicyPicker.attr("value", li.claim_policy());
+                liClaimPolicyDialog.show();
+                liClaimPolicySave.onClick = function() {
+                    self.changeClaimPolicy(
+                        [li], self.claimPolicyPicker.attr("value"),
+                        function() {
+                            self.setClaimPolicyControl(li, row);
+                            liClaimPolicyDialog.hide();
+                        }
+                    );
+                }
+            };
+        }
+    };
+
     /**
      * Inserts a single lineitem into the growing table of lineitems
      * @param {Object} li The lineitem object to insert
@@ -220,14 +256,7 @@
 
         this.updateLiNotesCount(li, row);
 
-        if (li.claim_policy()) {
-            var actViewInvoice = nodeByName("action_view_claim_policy", row);
-            actViewInvoice.disabled = false;
-            actViewInvoice.onclick = function() {
-                location.href = oilsBasePath + "/conify/global/acq/claim_policy/" +
-                    li.claim_policy();
-            };
-        }
+        this.setClaimPolicyControl(li, row);
 
         // show which PO this lineitem is a member of
         if(li.purchase_order() && !this.isPO) {
@@ -1745,9 +1774,43 @@
             case "cancel_lineitems":
                 this.maybeCancelLineitems();
                 break;
+
+            case "change_claim_policy":
+                var li_list = this.getSelected();
+                this.claimPolicyPicker.attr("value", null);
+                liClaimPolicyDialog.show();
+                liClaimPolicySave.onClick = function() {
+                    self.changeClaimPolicy(
+                        li_list,
+                        self.claimPolicyPicker.attr("value"),
+                        function() {
+                            li_list.forEach(
+                                function(li) { self.setClaimPolicyControl(li); }
+                            );
+                            liClaimPolicyDialog.hide();
+                        }
+                    )
+                };
+                break;
         }
     }
 
+    this.changeClaimPolicy = function(li_list, value, callback) {
+        li_list.forEach(
+            function(li) { li.claim_policy(value); }
+        );
+        fieldmapper.standardRequest(
+            ["open-ils.acq", "open-ils.acq.lineitem.update"], {
+                "params": [openils.User.authtoken, li_list],
+                "async": true,
+                "oncomplete": function(r) {
+                    r = openils.Util.readResponse(r);
+                    if (callback) callback(r);
+                }
+            }
+        );
+    };
+
     this.createAssets = function() {
         if(!this.isPO) return;
         if(!confirm(localeStrings.CREATE_PO_ASSETS_CONFIRM)) return;

Modified: trunk/Open-ILS/web/templates/default/acq/common/li_table.tt2
===================================================================
--- trunk/Open-ILS/web/templates/default/acq/common/li_table.tt2	2010-04-21 13:33:55 UTC (rev 16283)
+++ trunk/Open-ILS/web/templates/default/acq/common/li_table.tt2	2010-04-21 21:01:55 UTC (rev 16284)
@@ -24,6 +24,7 @@
                                             <option mask='sr|pl' value='create_order'>Create Purchase Order</option>
                                             <option mask='po' value='create_assets'>Load Bibs and Items</option>
                                             <option mask='po' value='cancel_lineitems'>Cancel Selected Lineitems</option>
+                                            <option mask='po' value='change_claim_policy'>Change Claim Policy</option>
                                             <option mask='po' value='receive_po'>Mark Purchase Order as Received</option>
                                             <option mask='po' value='rollback_receive_po'>Un-Receive Purchase Order</option>
                                             <option mask='po' value='print_po'>Print Purchase Order</option>
@@ -77,7 +78,6 @@
                                     <td style='width:70%;font-weight:bold;'>
                                         <a attr='title' href='javascript:void(0);'></a>
                                         <span name="worksheet">(<a name="worksheet_link" href="javascript:void(0);">&#x270D;</a>)</span>
-                                        <span name="claim_policy" class="hidden">(Claim Policy: <a name="claim_policy_link" href="javascript:void(0);"></a>)</span>
                                         <span name='pl' class='hidden'>(<a name='pl_link' href='javascript:void(0);'></a>)</span>
                                         <span name='po' class='hidden'>(<a name='po_link' href='javascript:void(0);'>PO</a>)</span>
                                     </td>
@@ -112,7 +112,7 @@
                             <option name='action_new_invoice' disabled='disabled'>New Invoice</option>
                             <option name='action_link_invoice' disabled='disabled'>Link to Invoice</option>
                             <option name='action_view_invoice' disabled='disabled'>View Invoice(s)</option>
-                            <option name='action_view_claim_policy' disabled='disabled'>View Claim Policy</option>
+                            <option name='action_view_claim_policy'>Apply Claim Policy</option>
                         </select>
                     </td>
                     <td><span name='li_state'></span></td>
@@ -379,6 +379,12 @@
             <span dojoType="dijit.form.Button"
                 jsId="acqLidCancelButton">Cancel Copy</span>
         </div>
+        <div dojoType="dijit.Dialog" jsId="liClaimPolicyDialog">
+                <label for="acq-lit-li-claim-policy">Claim policy:</label>
+                <span id="acq-lit-li-claim-policy"></span> &nbsp;
+                <span dojoType="dijit.form.Button"
+                    jsId="liClaimPolicySave">Save</span>
+        </div>
     </div>
 
     <div dojoType="dijit.Dialog" jsId='acqLitChangeLiStateDialog'>



More information about the open-ils-commits mailing list