added a FilteringSelect to create a new funding source. has some hard-coded vals...
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 8 Apr 2008 15:37:59 +0000 (15:37 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 8 Apr 2008 15:37:59 +0000 (15:37 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/branches/acq-experiment@9268 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/web/oilsweb/oilsweb/public/oils/media/js/openils/acq/FundingSource.js
Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/financial/list_funding_sources.html

index dbfbde9..f15312f 100644 (file)
@@ -27,7 +27,7 @@ openils.acq.FundingSource.loadGrid = function(domId, columns) {
                 name:src.name(), 
                 owner: findOrgUnit(src.owner()).name(),
                 currency_type:src.currency_type(),
-                balance:src.summary()['balance']
+                balance:new String(src.summary()['balance'])
             });
         }
         gridRefs.grid.update();
@@ -36,5 +36,29 @@ openils.acq.FundingSource.loadGrid = function(domId, columns) {
     req.send();
     return gridRefs.grid;
 };
+
+/**
+ * Create a new funding source object
+ * @param fields Key/value pairs used to create the new funding source
+ */
+openils.acq.FundingSource.create = function(fields, onCreateComplete) {
+
+    var fs = new acqfs()
+    for(var field in fields) 
+        fs[field](fields[field]);
+
+    var ses = new OpenSRF.ClientSession('open-ils.acq');
+    var req = ses.request('open-ils.acq.funding_source.create', oilsAuthtoken, fs);
+
+    req.oncomplete = function(r) {
+        var msg = r.recv();
+        var id = msg.content();
+        fs.id(id); /* XXX check for event */
+        if(onCreateComplete)
+            onCreateComplete(fs);
+    };
+    req.send();
+};
+
 }
 
index 5fb6a6a..a9c4368 100644 (file)
     -->
 </div>
 
+<script>var fsGrid = null;</script>
+
 
 <script type="text/javascript">
     dojo.require("dijit.Dialog");
-    dojo.require("dijit.form.ComboBox");
-    function checkPw(fields) {
-        alert('name = ' + fields.name);
+    dojo.require("dijit.form.FilteringSelect");
+    
+    /** Creates a new funding source */
+    function createFS(fields) {
+        openils.acq.FundingSource.create(
+            fields, 
+            function(fsId) {
+                /** The grid won't update after it's been drawn, 
+                    at least not in FF, so refresh the page... */
+                location.href = location.href;
+            }
+        );
     }
 </script>
 
 <div dojoType="dijit.form.DropDownButton">
     <span>${('New Funding Source')}</span>
-    <div dojoType="dijit.TooltipDialog" execute="checkPw(arguments[0]);">
-        <table>
+    <div dojoType="dijit.TooltipDialog" execute="createFS(arguments[0]);">
+        <table class='dijitTooltipTable'>
             <tr>
                 <td><label for="name">${_('Name:')} </label></td>
                 <td><input dojoType="dijit.form.TextBox" name="name"></td>
             <tr>
                 <td><label for="loc">${_('Owning Location:')} </label></td>
                 <td>
-                    <select name="owner" dojoType="dijit.form.ComboBox" autocomplete="false" >
-                        <option >Illinois</option>
-                        <option >New York</option>
-                        <option >Texas</option>
+                    <select name="owner" dojoType="dijit.form.FilteringSelect" autocomplete="false" >
+                        <!-- XXX get orgs from DB... -->
+                        <option value='2'>SYS1</option>
+                        <option value='3'>SYS2</option>
+                        <option value='7'>BR4</option>
                     </select>
                 </td>
             </tr>
             <tr>
                 <td><label for="currency_type">${_('Currency Type:')}</label></td>
-                <td><input dojoType="dijit.form.TextBox" name="currency_type"></td>
+                <td>
+                    <select name="currency_type" dojoType="dijit.form.FilteringSelect" autocomplete="false" >
+                        <!-- XXX get-currency-types from DB... -->
+                        <option value='CAN'>CAN</option>
+                        <option value='EUR'>EUR</option>
+                        <option value='USD'>USD</option>
+                    </select>
+                </td>
             </tr>
             <tr>
-                <td><button dojoType=dijit.form.Button type="submit">${_('Create')}</button></td>
-                <td><button dojoType=dijit.form.Button type="submit">${_('Cancel')}</button></td>
+                <td colspan='2' align='center'>
+                    <button dojoType=dijit.form.Button type="submit">${_('Create')}</button>
+                </td>
             </tr>
         </table>
     </div>
@@ -69,7 +89,7 @@
     /* build the funding-source grid on page load */
     dojo.addOnLoad(
         function(){
-            var fsGrid = openils.acq.FundingSource.loadGrid('oils-acq-funding-source-grid', cols);
+            fsGrid = openils.acq.FundingSource.loadGrid('oils-acq-funding-source-grid', cols);
             fsGrid.onRowClick = function(evt) {
                 /** XXX Need to make this more user friendly / obvious ... */
                 id = fsGrid.model.getDatum(evt.rowIndex, 0);