acq li ident : set perm UI
authorBill Erickson <berick@esilibrary.com>
Tue, 12 Feb 2013 20:42:44 +0000 (15:42 -0500)
committerBill Erickson <berick@esilibrary.com>
Mon, 11 Mar 2013 19:54:47 +0000 (15:54 -0400)
Signed-off-by: Bill Erickson <berick@esilibrary.com>
Open-ILS/web/js/ui/default/acq/common/li_table.js
Open-ILS/web/js/ui/default/acq/picklist/view.js
Open-ILS/web/js/ui/default/acq/po/view_po.js

index 3fa3e6f..8b24065 100644 (file)
@@ -748,7 +748,6 @@ function AcqLiTable() {
 
             cbox.startup();
 
-
             // set the value for the cbox
             if (values[name].length) {
                 var orderIdent = self.getLiOrderIdent(li);
@@ -760,16 +759,37 @@ function AcqLiTable() {
                 }
             }
 
+            if (!self.orderIdentAllowed) 
+                cbox.attr('disabled', true);
+
             sel._cbox = cbox;
             cbox._lineitem = li;
             dojo.connect(cbox, 'onChange', updateOrderIdent);
         }
 
-
         changeComboBox(typeSel); // force the initial draw
         typeSel.onchange = function() {changeComboBox(typeSel)};
     };
 
+    this.testOrderIdentPerms = function(org, callback) {
+        var self = this;
+        new openils.User().getPermOrgList(
+            'ACQ_SET_LINEITEM_IDENTIFIER',
+            function(orgs) { 
+                console.log('found orgs = ' + orgs);
+                for (var i = 0; i < orgs.length; i++) {
+                    if (Number(orgs[i]) == Number(org)) {
+                        self.orderIdentAllowed = true;
+                        if (callback) callback();
+                        return;
+                    }
+                }
+                if (callback) callback();
+            }, 
+            true, true
+        );
+    };
+
     this.checkClaimEligibility = function(li, callback, row) {
         /* Assume always eligible, i.e. from this interface we don't care about
          * claim eligibility any more. this is where the user would force a
index f44f743..6fa02df 100644 (file)
@@ -21,7 +21,10 @@ function load() {
                 {flesh_lineitem_count:true, flesh_owner:true}],
             oncomplete: function(r) {
                 plist = openils.Util.readResponse(r);
-                drawPl(plist);
+                liTable.testOrderIdentPerms(
+                    plist.org_unit(),
+                    function() { drawPl(plist) }
+                );
             }
         }
     );
@@ -49,7 +52,7 @@ function load() {
 }
 
 function drawPl() {
-
+    
     dojo.byId("oils-acq-picklist-name").innerHTML = plist.name();
     dojo.byId("oils-acq-picklist-attr-owner").innerHTML = plist.owner().usrname();
     dojo.byId("oils-acq-picklist-attr-count").innerHTML = plist.entry_count();
index 490de97..2b9cc4b 100644 (file)
@@ -412,11 +412,17 @@ function init() {
                 /* po item table */
                 poItemTable = new PoItemTable(PO, pcrud);
 
+                liTable.testOrderIdentPerms( PO.ordering_agency(), init2);
+
                 renderPo();
             }
         }
     );
 
+}
+
+function init2() {
+
     var totalEstimated = 0;
     var zeroLi = true;
     fieldmapper.standardRequest(