Acq - Show only context-appropriate options in actions dropdown menu
authorLebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Tue, 5 Mar 2013 19:05:30 +0000 (14:05 -0500)
committerLebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Thu, 7 Mar 2013 23:06:10 +0000 (18:06 -0500)
TODO: add_to_order, apply_claim_policy, receive_lineitems,
rollback_receive_lineitems

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/lineitem/related.js
Open-ILS/web/js/ui/default/acq/picklist/bib_search.js
Open-ILS/web/js/ui/default/acq/picklist/from_bib.js
Open-ILS/web/js/ui/default/acq/picklist/view.js
Open-ILS/web/js/ui/default/acq/po/search.js
Open-ILS/web/js/ui/default/acq/po/view_po.js
Open-ILS/web/js/ui/default/acq/search/unified.js

index c7da2d9..5e8efd0 100644 (file)
                                 <td>
                                     <span>
                                         <select id="acq-lit-li-actions-selector">
+                                    <!-- mask meanings:
+                                        pl: selection list
+                                        po: pending purchase order
+                                        ao: activated purchase order
+                                        gs: general search
+                                        vp: view/place orders
+                                        fs: MARC federated search
+
+                                        * for all, otherwise combine with |
+                                    -->
                                             <option mask='*'  value='_'>[% l('--Actions--') %]</option>
-                                            <option mask='sr' value='save_picklist'>[% l('Save Items To Selection List') %]</option>
-                                            <option mask='pl' value='selector_ready'>[% l('Mark Ready for Selector') %]</option>
-                                            <option mask='pl' value='order_ready'>[% l('Mark Ready for Order') %]</option>
-                                            <option mask='*'  value='delete_selected'>[% l('Delete Selected Items') %]</option>
-                                            <option mask='*'  value='add_brief_record'>[% l('Add Brief Record') %]</option>
-                                            <option mask='*'  value='export_attr_list'>[% l('Export Single Attribute List') %]</option>
-                                            <option mask='po' value='' disabled='disabled'>[% l('----PO----') %]</option>
-                                            <option mask='sr|pl' value='create_order'>[% l('Create Purchase Order') %]</option>
-                                            <option mask='sr|pl' value='add_to_order'>[% l('Add to Purchase Order') %]</option>
-                                            <option mask='po' value='print_po'>[% l('Print Purchase Order') %]</option>
-                                            <option mask='po' value='po_history'>[% l('View PO History') %]</option>
+                                            <option mask='pl|gs|vp|fs' value='save_picklist'>[% l('Save Items To Selection List') %]</option>
+                                            <option mask='pl|gs|vp' value='selector_ready'>[% l('Mark Ready for Selector') %]</option>
+                                            <option mask='pl|gs|vp' value='order_ready'>[% l('Mark Ready for Order') %]</option>
+                                            <option mask='pl|po|gs|vp'  value='delete_selected'>[% l('Delete Selected Items') %]</option>
+                                            <option mask='pl|po'  value='add_brief_record'>[% l('Add Brief Record') %]</option>
+                                            <option mask='pl|po|ao|gs'  value='export_attr_list'>[% l('Export Single Attribute List') %]</option>
+                                            <option mask='*' value='' disabled='disabled'>[% l('----PO----') %]</option>
+                                            <option mask='pl|gs|vp|fs' value='create_order'>[% l('Create Purchase Order') %]</option>
+                                            <option mask='pl|gs|vp|fs' value='add_to_order'>[% l('Add to Purchase Order') %]</option>
+                                            <option mask='po|ao' value='print_po'>[% l('Print Purchase Order') %]</option>
+                                            <option mask='po|ao' value='po_history'>[% l('View PO History') %]</option>
                                             <option mask='po' value='create_assets'>[% l('Load Bibs and Items') %]</option>
-                                            <!-- <option mask='*'  value='batch_apply_funds'>[% l('Apply Funds to Selected Items') %]</option> XXX moving to batch updater -->
-                                            <option mask='po' value='cancel_lineitems'>[% l('Cancel Selected Line Items') %]</option>
-                                            <option mask='po' 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' value='change_claim_policy'>[% l('Change Claim Policy for Selected Line Items') %]</option>
-                                            <option mask='po' value='receive_lineitems' id='receive_lineitems' disabled='disabled'>[% l('Mark Selected Line Items as Received') %]</option>
-                                            <option mask='po' value='rollback_receive_lineitems' id='rollback_receive_lineitems' disabled='disabled'>[% l('Un-Receive Selected Line Items') %]</option>
-                                            <option mask='po' value='batch_create_invoice'>[% l('Create Invoice From Selected Line Items') %]</option>
-                                            <option mask='po' value='batch_link_invoice'>[% l('Link Selected Line Items to Invoice') %]</option>
+                                            <!-- <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>
+                                            <option mask='ao|gs|vp' value='batch_link_invoice'>[% l('Link Selected Line Items to Invoice') %]</option>
                                         </select>
                                         <span id="acq-lit-export-attr-holder" class="hidden">
                                             <input dojoType="dijit.form.FilteringSelect" id="acq-lit-export-attr" jsId="acqLitExportAttrSelector" labelAttr="description" searchAttr="description" />
index 5f5df76..c905f5e 100644 (file)
@@ -152,6 +152,28 @@ function AcqLiTable() {
         }
     };
 
+    this.enableActionsDropdownOptions = function(mask) {
+        /* 'mask' is probably a minomer the way I'm using it, but it needs to
+         * be one of pl,po,ao,gs,vp, or fs. */
+        dojo.query("option", "acq-lit-li-actions-selector").forEach(
+            function(option) {
+                var opt_mask = dojo.attr(option, "mask");
+
+                /* For each <option> element, an empty or non-existent mask
+                 * attribute, a mask attribute of "*", or a mask attribute that
+                 * matches this method's argument should result in that
+                 * option's being enabled. */
+                dojo.attr(
+                    option, "disabled", !(
+                        !opt_mask ||
+                        opt_mask == "*" ||
+                        opt_mask.search(mask) != -1
+                    )
+                );
+            }
+        );
+    };
+
     /*
      * Ensures this.focusLineitem is in view and causes a brief 
      * border around the lineitem to come to life then fade.
index 0f3b91b..eb04bc4 100644 (file)
@@ -142,6 +142,7 @@ function load() {
     }
 
     liTable = new AcqLiTable();
+    liTable.enableActionsDropdownOptions("vp");
     liTable.reset();
     liTable._isRelatedViewer = true;
 
index 4345728..f0fa454 100644 (file)
@@ -25,6 +25,7 @@ var liTable;
 
 function drawForm() {
     liTable = new AcqLiTable();
+    liTable.enableActionsDropdownOptions("fs");
     liTable.skipInitialEligibilityCheck = true;
 
     fieldmapper.standardRequest(
index 4853d16..a737c0b 100644 (file)
@@ -67,7 +67,10 @@ function init() {
     new openils.widget.XULTermLoader(
         {"parentNode": "acq-frombib-upload", "parseCSV": true}
     ).build(function(w) { termLoader = w; });
+
     liTable = new AcqLiTable();
+    liTable.enableActionsDropdownOptions("vp");
+
     pager = new LiTablePager(fetchRecords, liTable);
 
     openils.Util.show("acq-frombib-begin-holder");
index f44f743..55d2900 100644 (file)
@@ -14,6 +14,8 @@ var liTable;
 function load() {
     liTable = new AcqLiTable();
     liTable.isPL = plId;
+    liTable.enableActionsDropdownOptions("pl");
+
     fieldmapper.standardRequest(
         ['open-ils.acq', 'open-ils.acq.picklist.retrieve.authoritative'],
         {   async: true,
index 5ef4d24..ddf7f3a 100644 (file)
@@ -97,6 +97,7 @@ function loadMetaPO(fields) {
     } else {
         if (!metaPO) {
             metaPO = new AcqLiTable();
+            metaPo.enableActionsDropdownOptions("po");
 
             /* We need to know the width (in cells) of the template row for
              * the LI table, and we don't want to hardcode it here. */
index e207949..af8b844 100644 (file)
@@ -317,6 +317,8 @@ function renderPo() {
 
     if(PO.order_date()) {
         openils.Util.show('acq-po-activated-on', 'inline');
+        liTable.enableActionsDropdownOptions("ao"); /* activated */
+
         dojo.byId('acq-po-activated-on').innerHTML = 
             dojo.string.substitute(
                 localeStrings.PO_ACTIVATED_ON, [
@@ -341,6 +343,8 @@ function renderPo() {
     } else {
         /* These things only make sense for not-ordered-yet POs */
 
+        liTable.enableActionsDropdownOptions("po");
+
         openils.Util.show("acq-po-zero-activate-label", "table-cell");
         openils.Util.show("acq-po-zero-activate", "table-cell");
 
index a6be3f0..a59f4eb 100644 (file)
@@ -976,8 +976,11 @@ openils.Util.addOnLoad(
 
         termManager = new TermManager();
 
+        var li_table = new AcqLiTable();
+        li_table.enableActionsDropdownOptions("gs");
+
         resultManager = new ResultManager(
-            new LiTablePager(null, new AcqLiTable()),
+            new LiTablePager(null, li_table),
             dijit.byId("acq-unified-po-grid"),
             dijit.byId("acq-unified-pl-grid"),
             dijit.byId("acq-unified-inv-grid")