From: erickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4> Date: Tue, 30 Mar 2010 16:41:18 +0000 (+0000) Subject: moved to auto-grid for view funding-source UI (for paging, etc.). added pcrud entrie... X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=22137a1dac94cdd3d7dccfb164ace723f65c17b8;p=evergreen%2Fmasslnc.git moved to auto-grid for view funding-source UI (for paging, etc.). added pcrud entries for funding_source credits git-svn-id: svn://svn.open-ils.org/ILS/trunk@16060 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- diff --git a/Open-ILS/examples/fm_IDL.xml b/Open-ILS/examples/fm_IDL.xml index 3e813f5c63..30f5ddef34 100644 --- a/Open-ILS/examples/fm_IDL.xml +++ b/Open-ILS/examples/fm_IDL.xml @@ -4918,7 +4918,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA </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 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA <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"> diff --git a/Open-ILS/web/js/ui/default/acq/financial/view_funding_source.js b/Open-ILS/web/js/ui/default/acq/financial/view_funding_source.js index ca220ff766..e847dec381 100644 --- a/Open-ILS/web/js/ui/default/acq/financial/view_funding_source.js +++ b/Open-ILS/web/js/ui/default/acq/financial/view_funding_source.js @@ -11,6 +11,7 @@ dojo.require('openils.acq.FundingSource'); 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 @@ function resetPage() { 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 applyFSCredit(fields) { 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 @@ function getSummaryInfo(rowIndex) { 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 @@ function loadFSGrid() { /** 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; } diff --git a/Open-ILS/web/templates/default/acq/financial/view_funding_source.tt2 b/Open-ILS/web/templates/default/acq/financial/view_funding_source.tt2 index 27518142e8..51f64d0ee5 100644 --- a/Open-ILS/web/templates/default/acq/financial/view_funding_source.tt2 +++ b/Open-ILS/web/templates/default/acq/financial/view_funding_source.tt2 @@ -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> + <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>