[open-ils-commits] r12682 - in trunk/Open-ILS/web: js/ui/default/conify/global/config templates/default/conify/global/config (erickson)
svn at svn.open-ils.org
svn at svn.open-ils.org
Thu Mar 26 10:45:46 EDT 2009
Author: erickson
Date: 2009-03-26 10:45:44 -0400 (Thu, 26 Mar 2009)
New Revision: 12682
Modified:
trunk/Open-ILS/web/js/ui/default/conify/global/config/billing_type.js
trunk/Open-ILS/web/templates/default/conify/global/config/billing_type.tt2
Log:
port the billing type UI to autogrid
Modified: trunk/Open-ILS/web/js/ui/default/conify/global/config/billing_type.js
===================================================================
--- trunk/Open-ILS/web/js/ui/default/conify/global/config/billing_type.js 2009-03-26 03:05:40 UTC (rev 12681)
+++ trunk/Open-ILS/web/js/ui/default/conify/global/config/billing_type.js 2009-03-26 14:45:44 UTC (rev 12682)
@@ -1,10 +1,13 @@
dojo.require('dojox.grid.DataGrid');
+dojo.require('openils.widget.AutoGrid');
dojo.require('dojox.grid.cells.dijit');
dojo.require('dojo.data.ItemFileWriteStore');
dojo.require('dijit.form.CurrencyTextBox');
dojo.require('dijit.Dialog');
dojo.require('dojox.widget.PlaceholderMenuItem');
dojo.require('fieldmapper.OrgUtils');
+dojo.require('dijit.form.FilteringSelect');
+dojo.require('openils.PermaCrud');
dojo.require('openils.widget.OrgUnitFilteringSelect');
var btContextOrg;
@@ -18,27 +21,23 @@
}
function btInit() {
- btGridMenu.init({
- grid: btGrid,
- prefix: 'conify.global.config.billing_type.btGridMenu',
- authtoken: openils.User.authtoken
- });
buildBTGrid();
var connect = function() {
dojo.connect(btContextOrgSelect, 'onChange',
- function() {
- btContextOrg = this.getValue();
- buildBTGrid();
- }
- );
+ function() {
+ btContextOrg = this.getValue();
+ btGrid.resetStore();
+ buildBTGrid();
+ }
+ );
};
new openils.User().buildPermOrgSelector('VIEW_BILLING_TYPE', btContextOrgSelect, null, connect);
}
function buildBTGrid() {
if(btContextOrg == null)
- btContextOrg = openils.User.user.ws_ou();
+ btContextOrg = openils.User.user.ws_ou();
fieldmapper.standardRequest(
['open-ils.circ', 'open-ils.circ.billing_type.ranged.retrieve.all'],
{ async: true,
@@ -46,100 +45,17 @@
oncomplete: function(r) {
if(btList = openils.Util.readResponse(r)) {
btList = openils.Util.objectSort(btList);
- var store = new dojo.data.ItemFileWriteStore({data:cbt.toStoreData(btList)});
- btGrid.setStore(store);
- btGrid.render();
+ dojo.forEach(btList,
+ function(e) {
+ btGrid.store.newItem(cbt.toStoreItem(e));
+ }
+ );
}
}
}
);
}
-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();
- }
- }
- );
-}
-
-function btDrawEditDialog() {
- btEditDialog.show();
- var item = btGrid.selection.getSelected()[0];
- if(!item) {
- btEditDialog.hide();
- return;
- }
- var id = btGrid.store.getValue(item, 'id');
- var name = btGrid.store.getValue(item, 'name');
- var owner = btGrid.store.getValue(item, 'owner');
- var price = btGrid.store.getValue(item, 'default_price');
-
- dojo.byId('btId').innerHTML = id;
- btName.setValue(name);
- btOwnerLocation.setValue(owner);
- btDefaultPrice.setValue(price);
- new openils.User().buildPermOrgSelector('ADMIN_BILLING_TYPE', btOwnerLocation, owner);
-
- if (id >= 100){
- btOwnerLocation.setDisabled(false);
- btDefaultPrice.setDisabled(false);
-
- } else {
- btOwnerLocation.setDisabled(true);
- btDefaultPrice.setDisabled(true);
- }
-
- // add an onclick for the save button that knows which object we are editing
- editSave.domNode.onclick = function() {
- var map = openils.Util.mapList(btList, 'id', true);
- var bt = map[id]; // id comes from the getValue() call above
- saveChanges(bt, item);
- }
-}
-
-
-function saveChanges(bt, item){
- bt.name(btName.getValue());
- bt.owner(btOwnerLocation.getValue());
- bt.default_price(btDefaultPrice.getValue());
-
- fieldmapper.standardRequest(
- ['open-ils.permacrud', 'open-ils.permacrud.update.cbt'],
- { async: true,
- params: [openils.User.authtoken, bt],
- oncomplete: function(r) {
-
- if(openils.Util.readResponse(r)) {
- // update succeeded. put the new values into the grid
- btGrid.store.setValue(item, 'name', bt.name());
- btGrid.store.setValue(item, 'default_price', (bt.default_price()));
- btGrid.store.setValue(item, 'owner', bt.owner());
- btEditDialog.hide();
-
- } else {
- // update failed. indicate this to the user somehow
- alert('Update Failed. Reason: ');
- }
- }
- }
- );
-}
openils.Util.addOnLoad(btInit);
Modified: trunk/Open-ILS/web/templates/default/conify/global/config/billing_type.tt2
===================================================================
--- trunk/Open-ILS/web/templates/default/conify/global/config/billing_type.tt2 2009-03-26 03:05:40 UTC (rev 12681)
+++ trunk/Open-ILS/web/templates/default/conify/global/config/billing_type.tt2 2009-03-26 14:45:44 UTC (rev 12682)
@@ -1,95 +1,34 @@
[% WRAPPER default/base.tt2 %]
<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>
- </tr>
- <tr>
- <td><label for="owner">Owning Location: </label></td>
- <td>
- <input dojoType="openils.widget.OrgUnitFilteringSelect" name="owner"
- jsId='btOwningOrg' searchAttr='shortname' labelAttr='shortname'/>
- </td>
- </tr>
- <tr>
- <td><label for="default_price">Default Price: </label></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>
- </td>
- </tr>
- </table>
- </div>
-</div>
-<button dojoType='dijit.form.Button' onclick='btDrawEditDialog();'>Edit Current Row</button>
-<span>Context Org Unit</span>
-<select dojoType="openils.widget.OrgUnitFilteringSelect" jsId='btContextOrgSelect'
- searchAttr='shortname' labelAttr='shortname'> </select>
-
-<script>dojo.require('openils.widget.GridColumnPicker');</script>
-
-<!-- column picker menu -->
-<div dojoType="openils.widget.GridColumnPicker" jsid="btGridMenu" id="btGridMenu" style="display: none;" grid='btGrid'>
- <div dojoType="dojox.widget.PlaceholderMenuItem" label="GridColumns"></div>
-</div>
<!-- grid -->
-<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' columnReordering='true' headerMenu="btGridMenu">
+
+ <div dojoType="dijit.layout.ContentPane" layoutAlign="client">
+ <div dojoType="dijit.layout.ContentPane" layoutAlign="top" class='oils-header-panel'>
+ <div>Billing Types</div>
+ <div>
+ <button dojoType='dijit.form.Button' onClick='btGrid.showCreateDialog()'>New Billing Type</button>
+ </div>
+ </div>
+ <div>
+ <span>Context Org Unit</span>
+ <select dojoType="openils.widget.OrgUnitFilteringSelect" jsId='btContextOrgSelect'
+ searchAttr='shortname' labelAttr='shortname'> </select>
+ </div>
+ <table jsId="btGrid"
+ dojoType="openils.widget.AutoGrid"
+ fieldOrder="['id', 'name', 'owner', 'default_price']"
+ query="{id: '*'}"
+ defaultCellWidth='20'
+ fmClass='cbt'
+ editOnEnter='true'>
<thead>
- <tr>
- <th field="id">ID</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><th field='owner' get='getOrgInfo'/>
</tr>
</thead>
- </table>
+ </table>
</div>
</div>
-<div style='display:none;' dojoType="dijit.Dialog" jsId='btEditDialog'>
- <script>dojo.require('dijit.form.TextBox');</script>
- <b>Test Editing Dialog</b>
- <form>
- <table>
- <tr>
- <td>ID</td>
- <td><span id='btId'/></td>
- </tr>
- <tr>
- <td>Name</td>
- <td><input dojoType='dijit.form.TextBox' jsId='btName'/></td>
- </tr>
- <tr>
- <td>Owning Location</td>
- <td><select dojoType='openils.widget.OrgUnitFilteringSelect' jsId='btOwnerLocation' searchAttr='shortname' labelAttr='shortname'/></td>
- </tr>
- <tr>
- <td> DefaultPrice</td>
- <td><input dojoType='dijit.form.CurrencyTextBox' jsId='btDefaultPrice'></td>
- </tr>
- <tr>
- <td colspan='2' align='center'>
- <button jsId='editSave' dojoType='dijit.form.Button'>Save Changes</button>
- </td>
- </tr>
- </table>
- </form>
-</div>
-
[% END %]
More information about the open-ils-commits
mailing list