[open-ils-commits] r16060 - in trunk/Open-ILS: examples web/js/ui/default/acq/financial web/templates/default/acq/financial (erickson)

svn at svn.open-ils.org svn at svn.open-ils.org
Tue Mar 30 12:41:22 EDT 2010


Author: erickson
Date: 2010-03-30 12:41:18 -0400 (Tue, 30 Mar 2010)
New Revision: 16060

Modified:
   trunk/Open-ILS/examples/fm_IDL.xml
   trunk/Open-ILS/web/js/ui/default/acq/financial/view_funding_source.js
   trunk/Open-ILS/web/templates/default/acq/financial/view_funding_source.tt2
Log:
moved to auto-grid for view funding-source UI (for paging, etc.).  added pcrud entries for funding_source credits

Modified: trunk/Open-ILS/examples/fm_IDL.xml
===================================================================
--- trunk/Open-ILS/examples/fm_IDL.xml	2010-03-30 16:24:28 UTC (rev 16059)
+++ trunk/Open-ILS/examples/fm_IDL.xml	2010-03-30 16:41:18 UTC (rev 16060)
@@ -4918,7 +4918,7 @@
         </permacrud>
 	</class>
 
-	<class id="acqfscred" controller="open-ils.cstore open-ils.reporter-store" oils_obj:fieldmapper="acq::funding_source_credit" oils_persist:tablename="acq.funding_source_credit" reporter:label="Credit to Funding Source">
+	<class id="acqfscred" controller="open-ils.cstore open-ils.pcrud" oils_obj:fieldmapper="acq::funding_source_credit" oils_persist:tablename="acq.funding_source_credit" reporter:label="Credit to Funding Source">
 		<fields oils_persist:primary="id" oils_persist:sequence="acq.funding_source_credit_id_seq">
 			<field reporter:label="Credit ID" name="id" reporter:datatype="id" />
 			<field reporter:label="Funding Source ID" name="funding_source" reporter:datatype="link" />
@@ -4930,6 +4930,22 @@
 		<links>
 			<link field="funding_source" reltype="has_a" key="id" map="" class="acqfs"/>
 		</links>
+		<permacrud xmlns="http://open-ils.org/spec/opensrf/IDL/permacrud/v1">
+			<actions>
+				<create permission="ADMIN_FUNDING_SOURCE">
+                    <context link="funding_source" field="owner"/>
+                </create>
+				<retrieve permission="ADMIN_FUNDING_SOURCE">
+                    <context link="funding_source" field="owner"/>
+                </retrieve>
+				<update permission="ADMIN_FUNDING_SOURCE">
+                    <context link="funding_source" field="owner"/>
+                </update>
+				<delete permission="ADMIN_FUNDING_SOURCE">
+                    <context link="funding_source" field="owner"/>
+                </delete>
+			</actions>
+		</permacrud>
 	</class>
 
 	<class id="acqofscred" controller="open-ils.cstore open-ils.pcrud" oils_obj:fieldmapper="acq::ordered_funding_source_credit" oils_persist:tablename="acq.ordered_funding_source_credit" reporter:label="Ordered Funding Source Credit">

Modified: trunk/Open-ILS/web/js/ui/default/acq/financial/view_funding_source.js
===================================================================
--- trunk/Open-ILS/web/js/ui/default/acq/financial/view_funding_source.js	2010-03-30 16:24:28 UTC (rev 16059)
+++ trunk/Open-ILS/web/js/ui/default/acq/financial/view_funding_source.js	2010-03-30 16:41:18 UTC (rev 16060)
@@ -11,6 +11,7 @@
 dojo.require('openils.acq.Fund');
 dojo.require('openils.Event');
 dojo.require('openils.Util');
+dojo.require('openils.widget.AutoGrid');
     
 var ses = new OpenSRF.ClientSession('open-ils.acq');
 var fundingSource = null;
@@ -22,6 +23,12 @@
     loadFS();
 }
 
+function getFund(rowIndex, item) {
+    return '';
+    //return '<a href="[% ctx.base_path %]/acq/fund/view/'+fund.id()+'">'+fund.code()+'</a>';
+}
+
+
 /** creates a new funding_source_credit from the dialog ----- */
 function applyFSCredit(fields) {
     fields.funding_source = fundingSourceID;
@@ -30,7 +37,6 @@
 
 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);
 }
@@ -68,11 +74,23 @@
     return new String(fundingSource.summary()[this.field]);
 }
 
+function getFund(rowIndex, item) {
+    if(item) {
+        var fId = this.grid.store.getValue(item, 'fund');
+        return openils.acq.Fund.retrieve(fId);
+    }
+}
+
+function formatFund(fund) {
+    if(fund) {
+        return '<a href="' + oilsBasePath + '/acq/fund/view/'+fund.id()+'">'+fund.code()+'</a>';
+    }
+}
+
 /** builds the credits grid ----- */
 function loadFSGrid() {
     if(!fundingSource) return;
     var store = new dojo.data.ItemFileReadStore({data:acqfs.toStoreData([fundingSource])});
-
     fundingSourceGrid.setStore(store);
     fundingSourceGrid.render();
 }
@@ -81,21 +99,13 @@
 /** builds the credits grid ----- */
 function loadCreditGrid() {
     if(fsCreditGrid.isLoaded) return;
- 
-    var store = new dojo.data.ItemFileReadStore({data:acqfa.toStoreData(fundingSource.credits())});
-   
-    fsCreditGrid.setStore(store);
-    fsCreditGrid.render();
+    fsCreditGrid.loadAll({order_by : {acqfscred :  'effective_date DESC'}});
     fsCreditGrid.isLoaded = true;
 }
 
-/** builds the allocations grid ----- */
 function loadAllocationGrid() {
     if(fsAllocationGrid.isLoaded) return;
-    var store = new dojo.data.ItemFileReadStore({data:acqfa.toStoreData(fundingSource.allocations())});
-
-    fsAllocationGrid.setStore(store);
-    fsAllocationGrid.render();
+    fsAllocationGrid.loadAll({order_by : {acqfa :  'create_time DESC'}});
     fsAllocationGrid.isLoaded = true;
 }
 

Modified: trunk/Open-ILS/web/templates/default/acq/financial/view_funding_source.tt2
===================================================================
--- trunk/Open-ILS/web/templates/default/acq/financial/view_funding_source.tt2	2010-03-30 16:24:28 UTC (rev 16059)
+++ trunk/Open-ILS/web/templates/default/acq/financial/view_funding_source.tt2	2010-03-30 16:41:18 UTC (rev 16060)
@@ -1,14 +1,5 @@
 [% WRAPPER 'default/base.tt2' %]
-<script>
-    var fundingSourceID = [% ctx.page_args.0 %];
-    function getFund(rowIndex) {
-        data = fsAllocationGrid.model.getRow(rowIndex);
-        if(data) {
-            var fund = openils.acq.Fund.retrieve(data.fund);
-            return '<a href="[% ctx.base_path %]/acq/fund/view/'+fund.id()+'">'+fund.code()+'</a>';
-        }
-    }
-</script>
+<script> var fundingSourceID = [% ctx.page_args.0 %]; </script>
 
 <!-- load the page-specific JS -->
 <script src='[% ctx.media_prefix %]/js/ui/default/acq/financial/view_funding_source.js'> </script>
@@ -27,18 +18,13 @@
                 <tr>
                     <td><label for="amount">Amount: </label></td>
                     <td>
-                        <!-- XXX get currency from funding source ... -->
-                        <input dojoType="dijit.form.CurrencyTextBox" name="amount" currency='USD'> </input>
+                        <input dojoType="dijit.form.CurrencyTextBox" name="amount"> </input>
                     </td>
                 </tr>
                 <tr>
                     <td><label for="note">Note: </label></td>
                     <td>
                         <input dojoType="dijit.form.TextBox" name="note"> </input>
-                        <!-- XXX textarea makes more sense, but it's buggy in the dropdown dialog .. perhaps a height issue?
-                        <textarea dojoType='dijit.form.Textarea' name="note" style='min-height:6em'> 
-                        </textarea>
-                        -->
                     </td>
                 </tr>
                 <tr>
@@ -73,10 +59,10 @@
                 <tr>
                     <td><label for="amount">Amount: </label></td>
                     <td>
-                        <!-- XXX get currency from funding source ... -->
-                        <input dojoType="dijit.form.CurrencyTextBox" name="amount" currency='USD'> </input>
+                        <input dojoType="dijit.form.CurrencyTextBox" name="amount"> </input>
                     </td>
                 </tr>
+                <!-- Percent-based allocations are not supported.  Will implement or remove later.
                 <tr>
                     <td><label for="amount">Percent: </label></td>
                     <td>
@@ -88,6 +74,7 @@
                         </input>
                     </td>
                 </tr>
+                -->
                 <tr>
                     <td><label for="note">Note: </label></td>
                     <td>
@@ -106,6 +93,7 @@
 
 <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>
 
@@ -127,43 +115,56 @@
                     </table>     
                 </div> 
             </div>               
+        </div>
  
         <div dojoType="dijit.layout.ContentPane" class='oils-acq-detail-content-pane' title="Credits">
-            <script type='dojo/connect' event='onShow'>loadCreditGrid();
-            </script> 
+            <script type='dojo/connect' event='onShow'>loadCreditGrid(); </script> 
+
             <div dojoType="dijit.layout.ContentPane" layoutAlign="top"> 
-                <div dojoType="dijit.layout.ContentPane" layoutAlign="client" style='height:600px;'> 
-                    <table jsId="fsCreditGrid" dojoType="dojox.grid.DataGrid" query="{id: '*'}" rowSelector='20px'> 
-                        <thead> 
-                            <tr> 
-                                <th field="id">ID</th> 
-                                <th field="amount">Amount</th> 
-                                <th field="note" width='auto'>Note</th> 
-                            </tr> 
-                        </thead> 
-                    </table>     
+                <div dojoType="dijit.layout.ContentPane" layoutAlign="client">
+
+                    <table 
+                        jsId="fsCreditGrid"
+                        autoHeight='true'
+                        dojoType="openils.widget.AutoGrid"
+                        fieldOrder="['amount', 'effective_date', 'deadline_date', 'note']"
+                        suppressFields="['id', 'funding_source']"
+                        fmClass="acqfscred"
+                        query="{id: '*'}"
+                        showPaginator='true'>
+                    </table>
                 </div> 
             </div> 
+        </div>
+
+        <!-- Fund Allocations -->
+        <div dojoType="dijit.layout.ContentPane" class='oils-acq-detail-content-pane' title="Allocations">
+            <script type='dojo/connect' event='onShow'>loadAllocationGrid();</script>
             
-        <div dojoType="dijit.layout.ContentPane" class='oils-acq-detail-content-pane' title="Allocations">
-            <script type='dojo/connect' event='onShow'>loadAllocationGrid();</script> 
             <div dojoType="dijit.layout.ContentPane" layoutAlign="top"> 
-                <div dojoType="dijit.layout.ContentPane" layoutAlign="client" style='height:600px;'> 
-                    <table jsId="fsAllocationGrid" dojoType="dojox.grid.DataGrid" query="{id: '*'}" rowSelector='20px'> 
-                        <thead> 
-                            <tr> 
-                                <th field="id">ID</th> 
-                                <th field="fund" get='getFund'>Fund</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 dojoType="dijit.layout.ContentPane" layoutAlign="client"> 
+
+                    <table 
+                        jsId="fsAllocationGrid" 
+                        autoHeight='true'
+                        dojoType="openils.widget.AutoGrid"
+                        fieldOrder="['fund', 'amount', 'create_time', 'allocator', 'note']"
+                        suppressFields="['id', 'funding_source']"
+                        defaultCellWidth='"auto"'
+                        fmClass="acqfa"
+                        query="{id: '*'}"
+                        showPaginator='true'>
+
+                        <thead>
+                            <tr>
+                                <th field='fund' get='getFund' formatter='formatFund'/>
+                            </tr>
+                        </thead>
+                    </table>
                 </div> 
             </div> 
         </div>
+
     </div>
 </div>
 



More information about the open-ils-commits mailing list