plugged in context org picker and plumbing for create dialog
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Fri, 14 Nov 2008 21:15:40 +0000 (21:15 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Fri, 14 Nov 2008 21:15:40 +0000 (21:15 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@11200 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/web/js/ui/default/conify/global/config/billing_type.js
Open-ILS/web/templates/default/conify/global/config/billing_type.tt2

index 46367b2..0761c01 100644 (file)
@@ -7,6 +7,26 @@ dojo.require('openils.widget.OrgUnitFilteringSelect');
 var btContextOrg;
 var btList;
 
+/** really need to put this in a shared location... */
+function getOrgInfo(rowIndex, item) {
+    if(!item) return '';
+    var orgId = this.grid.store.getValue(item, this.field);
+    return fieldmapper.aou.findOrgUnit(orgId).shortname();
+}
+
+function btInit() {
+    buildBTGrid();
+    var connect = function() {
+        dojo.connect(btContextOrgSelect, 'onChange',
+            function() {
+                btContextOrg = this.getValue();
+                buildBTGrid();
+            }
+        );
+    };
+    new openils.User().buildPermOrgSelector('VIEW_BILLING_TYPE', btContextOrgSelect, null, connect);
+}
+
 function buildBTGrid() {
     if(btContextOrg == null)
        btContextOrg = openils.User.user.ws_ou();
@@ -25,6 +45,29 @@ function buildBTGrid() {
     );
 }
 
-openils.Util.addOnLoad(buildBTGrid);
+function btCreate(args) {
+    if(!args.name || args.owner == null) 
+        return;
+    if(args.default_price == '' || isNaN(args.default_price))
+        args.default_price = null;
+
+    var btype = new cbt();
+    btype.name(args.name);
+    btype.owner(args.owner);
+    btype.default_price(args.default_price);
+
+    fieldmapper.standardRequest(
+        ['open-ils.permacrud', 'open-ils.permacrud.create.cbt'],
+        {   async: true,
+            params: [openils.User.authtoken, btype],
+            oncomplete: function(r) {
+                if(new String(openils.Util.readResponse(r)) != '0')
+                    buildBTGrid();
+            }
+        }
+    );
+}
+
+openils.Util.addOnLoad(btInit);
 
 
index fd437e3..b206d23 100644 (file)
@@ -2,45 +2,57 @@
 <script src='[% ctx.media_prefix %]/js/ui/default/conify/global/config/billing_type.js'> </script>
 <h1>Billing Types</h1><br/>
 
+
 <div dojoType="dijit.form.DropDownButton">
     <span>New Billing Type</span>
     <div dojoType="dijit.TooltipDialog" execute="btCreate(arguments[0]);">
+        <script type='dojo/connect' event='onOpen'>
+            new openils.User().buildPermOrgSelector('CREATE_BILLING_TYPE', btOwningOrg);
+        </script>
         <table class='dijitTooltipTable'>
             <tr>
                 <td><label for="name">Name: </label></td>
-                <td><input dojoType="dijit.form.TextBox" name="name"></td>
+                <td><input dojoType="dijit.form.TextBox" name="name"/></td>
             </tr>
             <tr>
                 <td><label for="name">Owning Location: </label></td>
-                <td><input dojoType="openils.widget.OrgUnitFilteringSelect" name="name"></td>
+                <td>
+                    <input dojoType="openils.widget.OrgUnitFilteringSelect" name="owner" 
+                        jsId='btOwningOrg' searchAttr='shortname' labelAttr='shortname'/>
+                </td>
             </tr>
             <tr>
                 <td><label for="name">Default Price: </label></td>
-                <td><input dojoType="dijit.form.CurrencyTextBox" name="default_price" required='false'></td>
+                <td><input dojoType="dijit.form.CurrencyTextBox" name="default_price" required='false'/></td>
             </tr>
             <tr>
                 <td colspan='2' align='center'>
-                    <button dojoType=dijit.form.Button type="submit">Create</button>
+                    <button dojoType='dijit.form.Button' type="submit">Create</button>
                 </td>
             </tr>
         </table>
     </div>
 </div> 
 
+<span>Context Org Unit</span>
+<select dojoType="openils.widget.OrgUnitFilteringSelect" jsId='btContextOrgSelect' 
+    searchAttr='shortname' labelAttr='shortname'> </select>
+
 <div dojoType="dijit.layout.ContentPane" layoutAlign="top">
     <div dojoType="dijit.layout.ContentPane" layoutAlign="client" style='height:600px;'>
         <table jsId="btGrid" dojoType="dojox.grid.DataGrid" query="{id: '*'}" rowSelector='20px'>
             <thead>
                 <tr>
                     <th field="id">ID</th>
-                    <th field="name" width='300px;'>Name</th>
-                    <th field="owner">Owning Location</th>
+                    <th field="name" width='250px;'>Name</th>
+                    <th field="owner" width='250px;' get='getOrgInfo'>Owning Location</th>
                     <th field="default_price">Default Price</th>
                 </tr>
             </thead>
         </table>    
     </div>
 </div>
+
 [% END %]