acq - Claim policy application works better now
authorLebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Thu, 7 Mar 2013 19:51:53 +0000 (14:51 -0500)
committerLebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Thu, 7 Mar 2013 23:06:11 +0000 (18:06 -0500)
Signed-off-by: Lebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Open-ILS/src/templates/acq/common/li_table.tt2
Open-ILS/web/js/ui/default/acq/common/li_table.js
Open-ILS/web/js/ui/default/acq/po/view_po.js

index 06e5b4a..0d021e6 100644 (file)
@@ -41,7 +41,6 @@
                                             <!-- <option mask=''  value='batch_apply_funds'>[% l('Apply Funds to Selected Items') %]</option> XXX moving to batch updater -->
                                             <option mask='ao|gs|vp' value='cancel_lineitems'>[% l('Cancel Selected Line Items') %]</option>
                                             <option mask='po|ao|gs|vp' value='apply_claim_policy'>[% l('Apply Claim Policy to Selected Line Items') %]</option><!-- can the functionality desired here be covered by the next thing? -->
-                                            <option mask='po|ao|gs|vp' value='change_claim_policy'>[% l('Change Claim Policy for Selected Line Items') %]</option>
                                             <option mask='ao|gs|vp' value='receive_lineitems' id='receive_lineitems' disabled='disabled'>[% l('Mark Selected Line Items as Received') %]</option>
                                             <option mask='ao|gs|vp' value='rollback_receive_lineitems' id='rollback_receive_lineitems' disabled='disabled'>[% l('Un-Receive Selected Line Items') %]</option>
                                             <option mask='ao|gs|vp' value='batch_create_invoice'>[% l('Create Invoice From Selected Line Items') %]</option>
                                         <span name='pl' class='hidden'> | <a title='[% l('Select List') %]' name='pl_link' href='javascript:void(0);'>&#x2756; </a></span>
                                         <span name='po' class='hidden'> | <a title='[% l('Purchase Order') %]' name='po_link' href='javascript:void(0);'>&#x2318; </a></span>
                                         <span name="show_requests"> | <a title='[% l('Patron Requests') %]' name="show_requests_link" href="javascript:void(0);">[% l('requests') %]</a></span> 
+                                        <span name="claim_policy" class="hidden"> | [% l("claim policy:") %] <span name="claim_policy_name"></span></span>
                                         <span name='pro' class='hidden'> | <a title='[% l('Provider') %]' name='pro_link' href='javascript:void(0);'>&#x235F; </a></span>
                                         <span name='queue' class='hidden'> | <a title='[% l('Import Queue') %]' name='queue_link' href='javascript:void(0);'>[% l('&#x27AC; queue') %]</a></span>
                                     </td>
                             <option name='action_new_invoice' disabled='disabled'>[% l('New Invoice') %]</option>
                             <option name='action_link_invoice' disabled='disabled'>[% l('Link to Invoice') %]</option>
                             <option name='action_view_invoice' disabled='disabled'>[% l('View Invoice(s)') %]</option>
-                            <option name='action_view_claim_policy'>[% l('Apply Claim Policy') %]</option>
                             <option name='action_manage_claims'>[% l('Claims') %]</option>
                             <option name='action_view_history'>[% l('View History') %]</option>
                         </select>
index ca41dda..62fafa1 100644 (file)
@@ -6,6 +6,7 @@ dojo.require('dijit.form.FilteringSelect');
 dojo.require('dijit.form.Textarea');
 dojo.require('dijit.Tooltip');
 dojo.require('dijit.ProgressBar');
+dojo.require('dojox.timing.doLater');
 dojo.require('openils.acq.Lineitem');
 dojo.require('openils.acq.PO');
 dojo.require('openils.acq.Picklist');
@@ -333,38 +334,50 @@ function AcqLiTable() {
     };
 
     this.setClaimPolicyControl = function(li, row) {
-        if (!self.claimPolicyPicker) {
-            self.claimPolicyPicker = true; /* prevents a race condition */
+        if (!self._claimPolicyPickerLoading) {
+            self._claimPolicyPickerLoading = true;
+
             new openils.widget.AutoFieldWidget({
                 "parentNode": "acq-lit-li-claim-policy",
                 "fmClass": "acqclp",
                 "selfReference": true,
                 "dijitArgs": {"required": true}
-            }).build(function(w) { self.claimPolicyPicker = w; });
+            }).build(
+                function(w) { self.claimPolicyPicker = w; }
+            );
         }
 
-        if (!row) row = this._findLiRow(li);
-
-        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);
-                            self.reconsiderClaimControl(li, row);
-                            liClaimPolicyDialog.hide();
-                        }
-                    );
-                }
-            };
+        /* dojox.timing.doLater() is the best thing ever. Resource not yet
+         * ready? Just repeat my whole method when it is. */
+        if (dojox.timing.doLater(self.claimPolicyPicker)) {
+            return;
+        } else {
+            if (!row)
+                row = self._findLiRow(li);
+
+            if (li.claim_policy()) {
+                /* This Dojo data dance is necessary to get a whole fieldmapper
+                 * object based on a claim policy ID, since we alreay have the
+                 * widget thing loaded with all that data, and can thereby
+                 * avoid another request to the server. */
+                self.claimPolicyPicker.store.fetchItemByIdentity({
+                    "identity": li.claim_policy(),
+                    "onItem": function(a) {
+                        var policy = (new acqclp()).fromStoreItem(a);
+                        var span = nodeByName("claim_policy", row);
+                        var inner = nodeByName("claim_policy_name", row);
+
+                        openils.Util.show(span, "inline");
+                        inner.innerHTML = policy.name();
+                    },
+                    "onError": function(e) {
+                        console.error(e);
+                    }
+                });
+            } else {
+                openils.Util.hide(nodeByName("claim_policy", row));
+                nodeByName("claim_policy_name", row).innerHTML = "";
+            }
         }
     };
 
@@ -2206,7 +2219,7 @@ function AcqLiTable() {
                 this.maybeCancelLineitems();
                 break;
 
-            case "change_claim_policy":
+            case "apply_claim_policy":
                 var li_list = this.getSelected();
                 this.claimPolicyPicker.attr("value", null);
                 liClaimPolicyDialog.show();
index af8b844..81e2f6b 100644 (file)
@@ -325,11 +325,12 @@ function renderPo() {
                     openils.Util.timeStamp(PO.order_date(), {formatLength:'short'})
                 ]
             );
-        if(po_state == "on-order" || po_state == "cancelled") {
-            dojo.removeAttr('receive_po', 'disabled');
-        } else if(po_state == "received") {
-            dojo.removeAttr('rollback_receive_po', 'disabled');
-        }
+        /* These are handled another way now */
+//        if (po_state == "on-order" || po_state == "cancelled") {
+//            dojo.removeAttr('receive_lineitems', 'disabled');
+//        } else if(po_state == "received") {
+//            dojo.removeAttr('rollback_receive_lineitems', 'disabled');
+//        }
 
         /* cancel widgets only make sense for activate (ordered) POs */
         makeCancelWidget(