LP#1175293 Use filtered fund dropdown in funding source interface
authorDan Wells <dbw2@calvin.edu>
Wed, 2 Nov 2016 18:35:16 +0000 (14:35 -0400)
committerKathy Lussier <klussier@masslnc.org>
Tue, 14 Mar 2017 13:27:24 +0000 (09:27 -0400)
The exising interface for allocating to funds from a funding source
view lists all funds by code only.  Since many (most?) orgs reuse
fund codes year to year, you eventually end up with a bunch of
dupes you cannot tell apart.

Let's "borrow" an AutoFieldWidget to do the heavy lifting of creating
a filtered list of active funds, and include the year for further
user validation.

This is inspired by a few other fund dropdowns, but may not be the
best overall solution.

Signed-off-by: Dan Wells <dbw2@calvin.edu>
Signed-off-by: Chris Sharp <csharp@georgialibraries.org>
Signed-off-by: Kathy Lussier <klussier@masslnc.org>
Open-ILS/src/templates/acq/funding_source/view.tt2
Open-ILS/web/js/ui/default/acq/financial/view_funding_source.js

index 61e1903..e37d58a 100644 (file)
     <div dojoType="dijit.form.DropDownButton">
         <span>[% l('Allocate to Fund') %]</span>
         <div dojoType="dijit.TooltipDialog" execute="applyFSAllocation(arguments[0]);">
-            <script type='dojo/connect' event='onOpen'>
-                openils.acq.Fund.createStore(
-                    function(store) {
-                        fundingSourceFundSelector.store = 
-                            new dojo.data.ItemFileReadStore({data:store});
-                        fundingSourceFundSelector.setValue(store.items[0].code);
-                    }, 'MANAGE_FUND'
-                );
-            </script>
             <table class='dijitTooltipTable'>
                 <tr>
-                    <td><label for="amount">[% l('Fund: ') %]</label></td>
+                    <td><label for="fund">[% l('Fund: ') %]</label></td>
                     <td>
-                        <input jsId='fundingSourceFundSelector' name="fund" 
-                            dojoType="dijit.form.FilteringSelect" searchAttr='code' labelAttr='code'>
-                        </input>
+                        <div id="oils-acq-funding-source-fund-allocate"></div>
                     </td>
                 </tr>
                 <tr>
@@ -61,7 +50,7 @@
                 </tr>
                 <!-- Percent-based allocations are not supported.  Will implement or remove later.
                 <tr>
-                    <td><label for="amount">[% l('Percent: ') %]</label></td>
+                    <td><label for="percent">[% l('Percent: ') %]</label></td>
                     <td>
                         <input 
                             dojoType="dijit.form.NumberTextBox" 
index 5a68df1..51e1f87 100644 (file)
@@ -66,6 +66,21 @@ function loadFS(also_load_grid) {
             also_load_grid(true /* reset_first */);
     }
     req.send();
+
+    new openils.widget.AutoFieldWidget({
+        "fmField": "fund",
+        /* We're not really using LIDs here, we just need some class
+         * that has a fund field to take advantage of AutoFieldWidget's
+         * magic. */
+        "fmClass": "acqlid",
+        "labelFormat": ["${0} (${1})", "code", "year"],
+        "searchFormat": ["${0} (${1})", "code", "year"],
+        "searchFilter": {"active": "t"},
+        "searchOptions": {"order_by" : {"acqf":"year DESC, code"}},
+        "parentNode": dojo.byId("oils-acq-funding-source-fund-allocate"),
+        "orgLimitPerms": ["MANAGE_FUND"], //???
+        "dijitArgs": { "name" : "fund" }
+    }).build(function(w, ww) {});
 }
 
 /** Some grid rendering accessor functions ----- */