From: erickson Date: Thu, 26 Mar 2009 14:45:44 +0000 (+0000) Subject: port the billing type UI to autogrid X-Git-Tag: sprint4-merge-nov22~10405 X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=e6fbc2fe8fd1698bd5c5d900720454f6626f0ae6;p=working%2FEvergreen.git port the billing type UI to autogrid git-svn-id: svn://svn.open-ils.org/ILS/trunk@12682 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- diff --git a/Open-ILS/web/js/ui/default/conify/global/config/billing_type.js b/Open-ILS/web/js/ui/default/conify/global/config/billing_type.js index a103084a49..f7514c81b9 100644 --- a/Open-ILS/web/js/ui/default/conify/global/config/billing_type.js +++ b/Open-ILS/web/js/ui/default/conify/global/config/billing_type.js @@ -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 getOrgInfo(rowIndex, item) { } 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 @@ function buildBTGrid() { 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); diff --git a/Open-ILS/web/templates/default/conify/global/config/billing_type.tt2 b/Open-ILS/web/templates/default/conify/global/config/billing_type.tt2 index 379ae5dc2e..ac2c848f41 100644 --- a/Open-ILS/web/templates/default/conify/global/config/billing_type.tt2 +++ b/Open-ILS/web/templates/default/conify/global/config/billing_type.tt2 @@ -1,95 +1,34 @@ [% WRAPPER default/base.tt2 %] -

Billing Types


- -
- New Billing Type -
- - - - - - - - - - - - - - - - - -
- -
- -
-
-
- -Context Org Unit - - - - - - -
-
- + +
+
+
Billing Types
+
+ +
+
+
+ Context Org Unit + +
+
- - - - - + -
IDNameOwning LocationDefault Price
-
-
-
- - Test Editing Dialog -
- - - - - - - - - - - - - - - - - - - -
ID
Name
Owning Location
DefaultPrice
- -
-
+
- [% END %]