[open-ils-commits] r13843 - in trunk/Open-ILS: src/perlmods/OpenILS/Application/Acq web/js/dojo/openils/widget web/js/ui/default/acq/financial web/templates/default/acq/financial (erickson)

svn at svn.open-ils.org svn at svn.open-ils.org
Sun Aug 16 11:49:15 EDT 2009


Author: erickson
Date: 2009-08-16 11:49:12 -0400 (Sun, 16 Aug 2009)
New Revision: 13843

Modified:
   trunk/Open-ILS/src/perlmods/OpenILS/Application/Acq/Financials.pm
   trunk/Open-ILS/web/js/dojo/openils/widget/AutoGrid.js
   trunk/Open-ILS/web/js/ui/default/acq/financial/list_funds.js
   trunk/Open-ILS/web/templates/default/acq/financial/list_funds.tt2
Log:
added support to autogrid for loading paged data via callback for UIs that load their own data.  added paging to fund list page.  added paging options to fund by org fetcher

Modified: trunk/Open-ILS/src/perlmods/OpenILS/Application/Acq/Financials.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Application/Acq/Financials.pm	2009-08-14 15:39:05 UTC (rev 13842)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Application/Acq/Financials.pm	2009-08-16 15:49:12 UTC (rev 13843)
@@ -286,20 +286,32 @@
 );
 
 sub retrieve_org_funds {
-    my($self, $conn, $auth, $org_id_list, $options) = @_;
+    my($self, $conn, $auth, $filter, $options) = @_;
     my $e = new_editor(authtoken=>$auth);
     return $e->event unless $e->checkauth;
+    $filter ||= {};
     $options ||= {};
 
     my $limit_perm = ($$options{limit_perm}) ? $$options{limit_perm} : 'ADMIN_FUND';
     return OpenILS::Event->new('BAD_PARAMS') 
         unless $limit_perm =~ /(ADMIN|MANAGE|VIEW)_FUND/;
 
-    my $org_ids = ($org_id_list and @$org_id_list) ? $org_id_list :
+    $filter->{org}  = $filter->{org} || 
         $U->user_has_work_perm_at($e, $limit_perm, {descendants =>1});
-    return undef unless @$org_ids;
-    my $funds = $e->search_acq_fund({org => $org_ids});
+    return undef unless @{$filter->{org}};
 
+
+    my $query = [
+        $filter,
+        {
+            limit => $$options{limit} || 50,
+            offset => $$options{offset} || 0,
+            order_by => $$options{order_by} || {acqf => 'name'}
+        }
+    ];
+
+    my $funds = $e->search_acq_fund($query);
+
     for my $fund (@$funds) {
         $fund->summary(retrieve_fund_summary_impl($e, $fund))
             if $$options{flesh_summary};

Modified: trunk/Open-ILS/web/js/dojo/openils/widget/AutoGrid.js
===================================================================
--- trunk/Open-ILS/web/js/dojo/openils/widget/AutoGrid.js	2009-08-14 15:39:05 UTC (rev 13842)
+++ trunk/Open-ILS/web/js/dojo/openils/widget/AutoGrid.js	2009-08-16 15:49:12 UTC (rev 13843)
@@ -38,6 +38,7 @@
                 this.initAutoEnv();
                 this.attr('structure', this._compileStructure());
                 this.setStore(this.buildAutoStore());
+                this.cachedQueryOpts = {};
 
                 if(this.showColumnPicker) {
                     if(!this.columnPickerPrefix) {
@@ -82,7 +83,10 @@
                         onclick : function() { 
                             self.resetStore();
                             self.cachedQueryOpts.offset = self.displayOffset -= self.displayLimit;
-                            self.loadAll(self.cachedQueryOpts, self.cachedQuerySearch);
+                            if(self.dataLoader)
+                                self.dataLoader()
+                            else
+                                self.loadAll(self.cachedQueryOpts, self.cachedQuerySearch);
                         }
                     });
 
@@ -93,7 +97,10 @@
                         onclick : function() { 
                             self.resetStore();
                             self.cachedQueryOpts.offset = self.displayOffset += self.displayLimit;
-                            self.loadAll(self.cachedQueryOpts, self.cachedQuerySearch);
+                            if(self.dataLoader)
+                                self.dataLoader()
+                            else
+                                self.loadAll(self.cachedQueryOpts, self.cachedQuerySearch);
                         }
                     });
 
@@ -108,6 +115,14 @@
                 }
             },
 
+            hideLoadProgressIndicator : function() {
+                dojo.style(this.loadProgressIndicator, 'visibility', 'hidden');
+            },
+
+            showLoadProgressIndicator : function() {
+                dojo.style(this.loadProgressIndicator, 'visibility', 'visible');
+            },
+
             /* Don't allow sorting on the selector column */
             canSort : function(rowIdx) {
                 if(rowIdx == 1 && !this.hideSelector)

Modified: trunk/Open-ILS/web/js/ui/default/acq/financial/list_funds.js
===================================================================
--- trunk/Open-ILS/web/js/ui/default/acq/financial/list_funds.js	2009-08-14 15:39:05 UTC (rev 13842)
+++ trunk/Open-ILS/web/js/ui/default/acq/financial/list_funds.js	2009-08-16 15:49:12 UTC (rev 13843)
@@ -25,14 +25,29 @@
     return 0;
 }
 
-function loadFundGrid() {
+function loadFundGrid(year) {
     var yearStore = {identifier:'year', name:'year', items:[]};
     var yearsAdded = {}; /* don't duplicate the years in the selector */
+    lfGrid.resetStore();
 
+    if(!year) year = new Date().getFullYear().toString();
+
+    lfGrid.dataLoader = function() { loadFundGrid(year); };
+
     fieldmapper.standardRequest(
        [ 'open-ils.acq', 'open-ils.acq.fund.org.retrieve'],
        {    async: true,
-            params: [openils.User.authtoken, null, {flesh_summary:1}],
+
+            params: [
+                openils.User.authtoken, 
+                {year:year}, 
+                {
+                    flesh_summary:1, 
+                    limit: lfGrid.displayLimit,
+                    offset: lfGrid.displayOffset
+                }
+            ],
+
             onresponse : function(r) {
                 if(lf = openils.Util.readResponse(r)) {
                    openils.acq.Fund.cache[lf.id()] = lf;
@@ -44,28 +59,29 @@
                     }
                 }
             },
+
             oncomplete : function(r) {
-                // sort the unique list of years and set the selector to "now" if possible
                 yearStore.items = yearStore.items.sort().reverse();
                 fundFilterYearSelect.store = new dojo.data.ItemFileReadStore({data:yearStore});
                 var today = new Date().getFullYear().toString();
+
                 if(today in yearsAdded)
                     fundFilterYearSelect.setValue(today);
+
+                lfGrid.hideLoadProgressIndicator();
+
+                dojo.connect(
+                    fundFilterYearSelect, 
+                    'onChange', 
+                    function() {
+                        loadFundGrid(fundFilterYearSelect.getValue());
+                    }
+                );
             }
         }
     );
 }
 
-function filterGrid() {
-    var year = fundFilterYearSelect.getValue();
-    console.log(year);
-    if(year) 
-        lfGrid.setQuery({year:year});
-    else
-        lfGrid.setQuery({id:'*'});
-    
-    lfGrid.update();
-}
 
 openils.Util.addOnLoad(loadFundGrid);
 

Modified: trunk/Open-ILS/web/templates/default/acq/financial/list_funds.tt2
===================================================================
--- trunk/Open-ILS/web/templates/default/acq/financial/list_funds.tt2	2009-08-14 15:39:05 UTC (rev 13842)
+++ trunk/Open-ILS/web/templates/default/acq/financial/list_funds.tt2	2009-08-16 15:49:12 UTC (rev 13843)
@@ -3,47 +3,20 @@
 <!-- load the page-specific JS -->
 <script src='[% ctx.media_prefix %]/js/ui/default/acq/financial/list_funds.js'> </script>
 
-<script type="text/javascript">
-    function createFund(fields) {
-        /** Creates a new fund source */
-        openils.acq.Fund.create(
-            fields,
-            function(fundId) {
-                var evt = openils.Event.parse(fundId);
-                if(evt) {
-                    alert(evt); /* XXX */
-                    return;
-                } else {
-                    location.href =  /* go to the details page for this fund */
-                    '[% ctx.base_path %]/acq/fund/view/'+fundId;
-                }
-            }
-        );
-    }
+<table style='width:100%;'>
+    <tr>
+        <!-- TODO CSS -->
+        <td style='text-align:left;font-size:130%;font-weight: bold;'>Funds</td>
+        <td style='text-align:right;width:90%;'>
+            Year <select dojoType='dijit.form.FilteringSelect'
+                jsId='fundFilterYearSelect' labelAttr='year' searchAttr='year'> </select>
+            <button dojoType='dijit.form.Button' onClick='lfGrid.showCreateDialog()'>New Fund</button>
+            <button dojoType='dijit.form.Button' onClick='lfGrid.deleteSelected()'>Delete Selected</button>
+        </td>
+    </tr>
+</table>
 
-    function getName(rowIndex, item) {
-        if(!item) return;
-        var name = this.grid.store.getValue(item, 'name');
-        var id = this.grid.store.getValue(item, 'id');
-        return '<a href="[% ctx.base_path %]/acq/fund/view/'+id+'">'+name+'</a>';
-    }
-</script>
-
-
-<div class='oils-header-panel' dojoType="dijit.layout.ContentPane" layoutAlign="client">
-    <div>Funds</div>
-    <div>
-        <button dojoType='dijit.form.Button' onClick='lfGrid.showCreateDialog()'>New Fund</button>
-        <button dojoType='dijit.form.Button' onClick='lfGrid.deleteSelected()'>Delete Selected</button>
-    </div>
-</div>
-
 <div dojoType="dijit.layout.ContentPane" layoutAlign="client">
-    Year <select dojoType='dijit.form.FilteringSelect' onchange='filterGrid();'
-        jsId='fundFilterYearSelect' labelAttr='year' searchAttr='year'> </select>
-</div>
-
-<div dojoType="dijit.layout.ContentPane" layoutAlign="client">
     <table  jsId="lfGrid"
             autoHeight='true'
             dojoType="openils.widget.AutoGrid"
@@ -51,6 +24,7 @@
             query="{id: '*'}"
             defaultCellWidth='"auto"'
             fmClass='acqf'
+            showPaginator='true'
             editOnEnter='true'>
         <thead>
             <tr>



More information about the open-ils-commits mailing list