finished wiring up the fund allocation create tooltip
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 12 May 2008 19:42:33 +0000 (19:42 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 12 May 2008 19:42:33 +0000 (19:42 +0000)
also, no longer reloading entire page on fund allocation and funding source
credit create complete, just refetching objects and redrawing grids

git-svn-id: svn://svn.open-ils.org/ILS/branches/acq-experiment@9556 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/financial/view_funding_source.html

index f824e21..62d2894 100644 (file)
     var fundingSourceID = ${c.oils.acq.funding_source_id};
     var fundingSource = null;
 
+    function resetPage() {
+        fundingSource = null;
+        fsCreditGrid.isLoaded = false;
+        fsAllocationGrid.isLoaded = false;
+        loadFS();
+    }
+
     /** creates a new funding_source_credit from the dialog ----- */
     function applyFSCredit(fields) {
         fields.funding_source = fundingSourceID;
-        openils.acq.FundingSource.createCredit(
-            fields, 
-            function(fscId) {
-                location.href = location.href;
-            }
-        );
+        openils.acq.FundingSource.createCredit(fields, resetPage);
+    }
+
+    function applyFSAllocation(fields) {
+        fields.funding_source = fundingSourceID;
+        if(isNaN(fields.percent)) fields.percent = null;
+        if(isNaN(fields.amount)) fields.amount = null;
+        openils.acq.Fund.createAllocation(fields, resetPage);
     }
 
     /** fetch the fleshed funding source ----- */
@@ -79,6 +88,7 @@
 
     /** builds the credits grid ----- */
     function loadFSGrid() {
+        if(!fundingSource) return;
         var store = new dojo.data.ItemFileReadStore({data:acqfs.toStoreData([fundingSource])});
         var model = new dojox.grid.data.DojoData(null, store, {rowsPerPage: 20, clientSort: true, query:{id:'*'}});
         fundingSourceGrid.setModel(model);
                         fundingSourceFundSelector.store = 
                             new dojo.data.ItemFileReadStore({data:store});
                         fundingSourceFundSelector.setValue(store.items[0].id);
-                    },
-                    'ADMIN_FUND' /* need to check MANAGE_FUND as well... */
+                    }, 'MANAGE_FUND'
                 );
             </script>
             <table class='dijitTooltipTable'>
 <div dojoType="dijit.layout.ContentPane" layoutAlign="top">
     <div dojoType="dijit.layout.TabContainer">
         <div dojoType="dijit.layout.ContentPane" class='oils-acq-detail-content-pane' title="${_('Summary')}" selected='true'>
+            <script type='dojo/connect' event='onShow'>loadFSGrid();</script>
             <script>
                 /** Define the columns for the funding source grid ----- */
                 var fundingSourceGridLayout = [{