added some rough exchange rate editing code using auto widgets. essentially function...
[working/Evergreen.git] / Open-ILS / web / templates / default / conify / global / acq / exchange_rate.tt2
1 [% WRAPPER default/base.tt2 %]
2 <!--
3 <script src='[% ctx.media_prefix %]/js/ui/default/conify/global/config/billing_type.js'> </script>
4 -->
5 <h1>Exchange Rates</h1><br/>
6
7 <script>
8     dojo.require('dojo.data.ItemFileWriteStore');
9     dojo.require('openils.widget.EditDialog');
10     dojo.require('openils.widget.AutoGrid');
11     dojo.require('openils.PermaCrud');
12     dojo.require('openils.Util');
13     dojo.require('dojox.grid.DataGrid');
14
15     var cache = {};
16     function renderGrid() {
17         var pcrud = new openils.PermaCrud();
18         pcrud.retrieveAll('acqexr', 
19             {   async : true,
20                 oncomplete : function(r) {
21                     var list = openils.Util.readResponse(r);
22                     erGrid.fmObjectList = list;
23                     for(var i in list) {
24                         cache[list[i].id()] = list[i];
25                         erGrid.store.newItem(list[i].toStoreItem());
26                     }
27                     erGrid.update();
28                 }
29             }
30         );
31     }
32     openils.Util.addOnLoad(renderGrid);
33
34     openils.Util.addOnLoad(function() {
35         dojo.connect(erGrid, 'onKeyDown',
36             function(e) {
37                 if(e.keyCode == dojo.keys.ENTER) {
38                     this.selection.deselectAll();
39                     this.selection.select(this.focus.rowIndex);
40                     var item = this.selection.getFirstSelected();
41                     var dialog = new openils.widget.EditDialog({
42                         fmObject:cache[item.id],
43                         onPostApply : function() {
44                             // update grid item object
45                         }
46                     });
47                     dialog.editPane.fieldOrder = erGrid.fieldOrder;
48                     dialog.startup();
49                     dialog.show();
50                 }
51             }
52         );
53     });
54
55 </script>
56
57 <div dojoType="dijit.layout.ContentPane" layoutAlign="top" style='height:600px;'>
58     <table jsId="erGrid" dojoType="openils.widget.AutoGrid" 
59             fieldOrder="['id', 'from_currency', 'to_currency', 'ratio']"
60             query="{id: '*'}" rowSelector='20px' fmClass='acqexr'>
61     </table>
62 </div>
63 [% END %]
64
65