[open-ils-commits] r11523 - in trunk/Open-ILS/web: js/ui/default/acq/financial templates/default/acq/financial

svn at svn.open-ils.org svn at svn.open-ils.org
Thu Dec 11 11:12:56 EST 2008


Author: erickson
Date: 2008-12-11 11:12:54 -0500 (Thu, 11 Dec 2008)
New Revision: 11523

Modified:
   trunk/Open-ILS/web/js/ui/default/acq/financial/view_fund.js
   trunk/Open-ILS/web/templates/default/acq/financial/view_fund.tt2
Log:
move to 1.2 markup grid

Modified: trunk/Open-ILS/web/js/ui/default/acq/financial/view_fund.js
===================================================================
--- trunk/Open-ILS/web/js/ui/default/acq/financial/view_fund.js	2008-12-11 16:08:51 UTC (rev 11522)
+++ trunk/Open-ILS/web/js/ui/default/acq/financial/view_fund.js	2008-12-11 16:12:54 UTC (rev 11523)
@@ -2,8 +2,9 @@
 dojo.require('dijit.form.FilteringSelect');
 dojo.require('dijit.layout.TabContainer');
 dojo.require('dijit.layout.ContentPane');
-dojo.require('dojox.grid.Grid');
-
+dojo.require('dojox.grid.DataGrid');
+dojo.require('dijit.form.CurrencyTextBox');
+dojo.require('dojo.data.ItemFileReadStore');
 dojo.require("fieldmapper.OrgUtils");
 dojo.require('openils.acq.Fund');
 dojo.require('openils.acq.FundingSource');
@@ -13,7 +14,8 @@
 
 var fund = null;
 
-function getSummaryInfo(rowIndex) {
+function getSummaryInfo(rowIndex, item) {
+    if(!item) return'';
     return new String(fund.summary()[this.field]);
 }
 
@@ -21,48 +23,42 @@
     fields.fund = fundID;
     if(isNaN(fields.percent)) fields.percent = null;
     if(isNaN(fields.amount)) fields.amount = null;
-    //openils.acq.Fund.createAllocation(fields, resetPage);
     openils.acq.Fund.createAllocation(fields, 
         function(r){location.href = location.href;});
 }
+function getOrgInfo(rowIndex, item) {
+    if(!item) return ''; 
+    var owner = this.grid.store.getValue(item, 'org'); 
+    return fieldmapper.aou.findOrgUnit(owner).shortname();
 
-function getOrgInfo(rowIndex) {
-    data = fundGrid.model.getRow(rowIndex);
-    if(!data) return;
-    return fieldmapper.aou.findOrgUnit(data.org).shortname();
 }
 
-function getXferDest(rowIndex) {
-    data = this.grid.model.getRow(rowIndex);
-    if(!(data && data.xfer_destination)) return '';
-    return data.xfer_destination;
+function getXferDest(rowIndex, item) {
+    if(!item) return '';
+    var xfer_destination = this.grid.store.getValue(item, 'xfer_destination');
+    if(!(item && xfer_destination)) return '';
+    return xfer_destination;
 }
 
 function loadFundGrid() {
     var store = new dojo.data.ItemFileReadStore({data:acqf.toStoreData([fund])});
-    var model = new dojox.grid.data.DojoData(
-        null, store, {rowsPerPage: 20, clientSort: true, query:{id:'*'}});
-    fundGrid.setModel(model);
-    fundGrid.update();
+    fundGrid.setStore(store);
+    fundGrid.render();
 }
 
 function loadAllocationGrid() {
     if(fundAllocationGrid.isLoaded) return;
     var store = new dojo.data.ItemFileReadStore({data:acqfa.toStoreData(fund.allocations())});
-    var model = new dojox.grid.data.DojoData(
-        null, store, {rowsPerPage: 20, clientSort: true, query:{id:'*'}});
-    fundAllocationGrid.setModel(model);
-    fundAllocationGrid.update();
+    fundAllocationGrid.setStore(store);
+    fundAllocationGrid.render();
     fundAllocationGrid.isLoaded = true;
 }
 
 function loadDebitGrid() {
     if(fundDebitGrid.isLoaded) return;
     var store = new dojo.data.ItemFileReadStore({data:acqfa.toStoreData(fund.debits())});
-    var model = new dojox.grid.data.DojoData(
-        null, store, {rowsPerPage: 20, clientSort: true, query:{id:'*'}});
-    fundDebitGrid.setModel(model);
-    fundDebitGrid.update();
+    fundDebitGrid.setStore(store);
+    fundDebitGrid.render();
     fundDebitGrid.isLoaded = true;
 }
 

Modified: trunk/Open-ILS/web/templates/default/acq/financial/view_fund.tt2
===================================================================
--- trunk/Open-ILS/web/templates/default/acq/financial/view_fund.tt2	2008-12-11 16:08:51 UTC (rev 11522)
+++ trunk/Open-ILS/web/templates/default/acq/financial/view_fund.tt2	2008-12-11 16:12:54 UTC (rev 11523)
@@ -1,12 +1,11 @@
 [% WRAPPER 'default/base.tt2' %]
 <script>
     var fundID = [% ctx.page_args.0 %]
-    function getFundingSource(rowIndex) {
-        data = fundAllocationGrid.model.getRow(rowIndex);
-        if(data) {
-            var fs = openils.acq.FundingSource.retrieve(data.funding_source);
-            return '<a href="[% ctx.base_uri %]/acq/funding_source/view/'+fs.id()+'">'+fs.name()+'</a>';
-        }
+    function getFundingSource(rowIndex, item) {
+    if(!item) return ''; 
+    var fs_id = this.grid.store.getValue(item, 'funding_source');
+    var fs = openils.acq.FundingSource.retrieve(fs_id);
+    return '<a href="[% ctx.base_uri %]/acq/funding_source/view/'+fs.id()+'">'+fs.name()+'</a>';
     }
 </script>
 
@@ -24,10 +23,10 @@
         <div dojoType="dijit.TooltipDialog" execute="createAllocation(arguments[0]);">
             <script type='dojo/connect' event='onOpen'>
                 openils.acq.FundingSource.createStore(
-                    function(store) {
-                        fundingSourceSelector.store = 
-                            new dojo.data.ItemFileReadStore({data:store});
-                        fundingSourceSelector.setValue(store.items[0].code);
+                function(store) {
+                    fundingSourceSelector.store = 
+                    new dojo.data.ItemFileReadStore({data:store});
+                    fundingSourceSelector.setValue(store.items[0].code);
                     }, 'MANAGE_FUNDING_SOURCE'
                 );
             </script>
@@ -36,7 +35,7 @@
                     <td><label for="amount">Funding Source: </label></td>
                     <td>
                         <input jsId='fundingSourceSelector' name="funding_source" 
-                            dojoType="dijit.form.FilteringSelect" searchAttr='code' labelAttr='code'>
+                               dojoType="dijit.form.FilteringSelect" searchAttr='code' labelAttr='code'>
                         </input>
                     </td>
                 </tr>
@@ -51,10 +50,10 @@
                     <td><label for="amount">Percent: </label></td>
                     <td>
                         <input 
-                            dojoType="dijit.form.NumberTextBox" 
-                            constraints="{min:0,max:100}" 
-                            promptMessage="Please enter an amount between 0 and 100"
-                            name="percent"> 
+                             dojoType="dijit.form.NumberTextBox" 
+                             constraints="{min:0,max:100}" 
+                             promptMessage="Please enter an amount between 0 and 100"
+                             name="percent"> 
                         </input>
                     </td>
                 </tr>
@@ -66,7 +65,7 @@
                 </tr>
                 <tr>
                     <td colspan='2' align='center'>
-                        <button dojoType=dijit.form.Button type="submit">Apply</button>
+                        <button dojoType="dijit.form.Button" type="submit">Apply</button>
                     </td>
                 </tr>
             </table>
@@ -78,67 +77,79 @@
 <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>
-                /** Define the columns for the fund grid ----- */
-                var fundGridLayout = [{
-                    cells : [[
-                        {name: 'ID', field: 'id'},
-                        {name: 'Name', field: "name", width:'auto'}, 
-                        {name: 'Code', field: "code"},
-                        {name: 'Currency Type', field: "currency_type"},
-                        {name: 'Owner', get:getOrgInfo}, 
-                        /*
-                        {name: 'Balance (Total - (Spent + Encumbrances))")}', get:getSummaryInfo},
-                        {name: 'Amount Allocated to this Fund")}', get:getSummaryInfo},
-                        {name: 'Spent Balance (Total - Spent)")}', get:getSummaryInfo},
-                        {name: 'Total Debits (Spent + Encumbered)")}', get:getSummaryInfo},
-                        */
-                        {name: 'Balance', get:getSummaryInfo, field:'combined_balance'},
-                        {name: 'Total Allocated', get:getSummaryInfo, field:'allocation_total'},
-                        {name: 'Spent Balance', get:getSummaryInfo, field:'spent_balance'},
-                        {name: 'Total Debits', get:getSummaryInfo, field:'debit_total'},
-                        {name: 'Total Spent', get:getSummaryInfo, field:'spent_total'},
-                        {name: 'Total Encumbered', get:getSummaryInfo, field:'encumbrance_total'}
-                    ]]
-                }];
-            </script>
-            <div jsId='fundGrid' dojoType="dojox.Grid" structure='fundGridLayout'> </div>
+             class='oils-acq-detail-content-pane' title="Summary" selected='true'>
+            
+            <div dojoType="dijit.layout.ContentPane" layoutAlign="top"> 
+                <div dojoType="dijit.layout.ContentPane" layoutAlign="client" style='height:600px;'> 
+                    <table jsId="fundGrid" dojoType="dojox.grid.DataGrid" query="{id: '*'}" rowSelector='20px'> 
+                        <thead> 
+                            <tr> 
+                                <th field="id">ID</th> 
+                                <th field="name" width='auto'>Name</th> 
+                                <th field="code">Code</th> 
+                                <th field="currency_type">Currency Type</th> 
+                                <th field="org" get='getOrgInfo'>Owner</th> 
+                                <th field="combined_balance" get='getSummaryInfo'>Balance</th> 
+                                <th field="allocation_total" get='getSummaryInfo'>Total Allocated</th>
+                                <th field="spent_balance" get='getSummaryInfo'>Spent Balance</th>
+                                <th field="debit_total" get='getSummaryInfo'>Total Debits</th>
+                                <th field="spent_total" get='getSummaryInfo'>Total Spent</th>
+                                <th field="encumbrance_total" get='getSummaryInfo'>Total Encumbered</th>
+                            </tr> 
+                        </thead> 
+                    </table>     
+               
+            <!--
+            {name: 'Balance (Total - (Spent + Encumbrances))")}', get:getSummaryInfo},
+            {name: 'Amount Allocated to this Fund")}', get:getSummaryInfo},
+            {name: 'Spent Balance (Total - Spent)")}', get:getSummaryInfo},
+            {name: 'Total Debits (Spent + Encumbered)")}', get:getSummaryInfo},
+            -->
+
         </div>
+    </div>
+</div>
         <div dojoType="dijit.layout.ContentPane" class='oils-acq-detail-content-pane' title="Allocations">
             <script type='dojo/connect' event='onShow'>loadAllocationGrid();</script>
-            <script>
-                /** Define the columns for the funding source allocations grid ----- */
-                var fundAllocationGridLayout = [{
-                    cells : [[
-                        {name: 'ID', field: 'id'},
-                        {name: 'Funding Source', field: "fund", get:getFundingSource}, 
-                        {name: 'Amount', field: "amount"}, 
-                        {name: 'Percent', field: "percent"}, 
-                        {name: 'Allocated By', field: "allocator"}, 
-                        {name: 'Note', field: "note", width:'auto'}, 
-                    ]]
-                }];
-            </script>
-            <div jsId='fundAllocationGrid' dojoType="dojox.Grid" structure='fundAllocationGridLayout'> </div>
+            
+            <div dojoType="dijit.layout.ContentPane" layoutAlign="top"> 
+                <div dojoType="dijit.layout.ContentPane" layoutAlign="client" style='height:600px;'> 
+                    <table jsId="fundAllocationGrid" dojoType="dojox.grid.DataGrid" query="{id: '*'}" rowSelector='20px'> 
+                        <thead> 
+                            <tr> 
+                                <th field="id">ID</th> 
+                                <th field="funding_source" get='getFundingSource'>Funding Source</th> 
+                                <th field="amount">Amount</th> 
+                                <th field="percent">Percent</th> 
+                                <th field="allocator">Allocated By</th> 
+                                <th field="note" width='auto'>Note</th> 
+                            </tr> 
+                        </thead> 
+                    </table>     
+                </div> 
+            </div> 
+
         </div>
         <div dojoType="dijit.layout.ContentPane" class='oils-acq-detail-content-pane' title="Debits">
             <script type='dojo/connect' event='onShow'>loadDebitGrid();</script>
-            <script>
-                /** Define the columns for the funding source credits grid ----- */
-                var fundDebitGridLayout = [{
-                    cells : [[
-                        {name: 'ID', field: 'id'},
-                        {name: 'Origin Amount', field: "origin_amount"}, 
-                        {name: 'Origin Currency Type', field: "origin_currency_type"}, 
-                        {name: 'Amount', field: "amount"}, 
-                        {name: 'Encumbrance', field: "encumbrance"}, 
-                        {name: 'Debit Type', field: "debit_type"}, 
-                        {name: 'Transfer Destination', field: "xfer_destination", get:getXferDest}, 
-                    ]]
-                }];
-            </script>
-            <div jsId='fundDebitGrid' dojoType="dojox.Grid" structure='fundDebitGridLayout'> </div>
+            
+            <div dojoType="dijit.layout.ContentPane" layoutAlign="top"> 
+                <div dojoType="dijit.layout.ContentPane" layoutAlign="client" style='height:600px;'> 
+                    <table jsId="fundDebitGrid" dojoType="dojox.grid.DataGrid" query="{id: '*'}" rowSelector='20px'> 
+                        <thead> 
+                            <tr> 
+                                <th field="id">ID</th> 
+                                <th field="origin_amount">Origin Amount</th> 
+                                <th field="origin_currency_type">Origin Currency Type</th> 
+                                <th field="amount">Amount</th> 
+                                <th field="encumbrance">Encumbrance</th> 
+                                <th field="debit_type">Debit Type</th>
+                                <th field="xfer_destination" get='getXferDestination'>Transfer Destination</th> 
+                            </tr> 
+                        </thead> 
+                    </table>     
+                </div> 
+            </div> 
         </div>
     </div>
 </div>



More information about the open-ils-commits mailing list