From: Lebbeous Fogle-Weekley Date: Thu, 7 Mar 2013 19:51:53 +0000 (-0500) Subject: acq - Claim policy application works better now X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=9845c54c85ef49608853376ab4b0520b81af38ad;p=evergreen%2Fequinox.git acq - Claim policy application works better now Signed-off-by: Lebbeous Fogle-Weekley --- diff --git a/Open-ILS/src/templates/acq/common/li_table.tt2 b/Open-ILS/src/templates/acq/common/li_table.tt2 index 06e5b4aac1..0d021e6add 100644 --- a/Open-ILS/src/templates/acq/common/li_table.tt2 +++ b/Open-ILS/src/templates/acq/common/li_table.tt2 @@ -41,7 +41,6 @@ - @@ -121,6 +120,7 @@ | [% l('requests') %] + @@ -142,7 +142,6 @@ - diff --git a/Open-ILS/web/js/ui/default/acq/common/li_table.js b/Open-ILS/web/js/ui/default/acq/common/li_table.js index ca41ddaba7..62fafa1278 100644 --- a/Open-ILS/web/js/ui/default/acq/common/li_table.js +++ b/Open-ILS/web/js/ui/default/acq/common/li_table.js @@ -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(); diff --git a/Open-ILS/web/js/ui/default/acq/po/view_po.js b/Open-ILS/web/js/ui/default/acq/po/view_po.js index af8b8445c8..81e2f6b125 100644 --- a/Open-ILS/web/js/ui/default/acq/po/view_po.js +++ b/Open-ILS/web/js/ui/default/acq/po/view_po.js @@ -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(