From b0980113c0f1eaf93a85e0cc83d0c314477223ca Mon Sep 17 00:00:00 2001 From: erickson Date: Wed, 1 Apr 2009 20:11:51 +0000 Subject: [PATCH] autogrid the circ_modifier config ui git-svn-id: svn://svn.open-ils.org/ILS/trunk@12756 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- .../conify/global/config/circ_modifier.js | 124 +------------- .../conify/global/config/circ_modifier.tt2 | 154 +++++++----------- Open-ILS/web/templates/default/menu.tt2 | 2 +- 3 files changed, 70 insertions(+), 210 deletions(-) diff --git a/Open-ILS/web/js/ui/default/conify/global/config/circ_modifier.js b/Open-ILS/web/js/ui/default/conify/global/config/circ_modifier.js index c4178e72d3..983ea91f62 100644 --- a/Open-ILS/web/js/ui/default/conify/global/config/circ_modifier.js +++ b/Open-ILS/web/js/ui/default/conify/global/config/circ_modifier.js @@ -3,130 +3,18 @@ dojo.require('dojox.grid.cells.dijit'); dojo.require('dojo.data.ItemFileWriteStore'); dojo.require('dijit.form.CheckBox'); dojo.require('dijit.form.FilteringSelect'); +dojo.require('openils.widget.AutoGrid'); var cmCache = {}; function buildCMGrid() { - var store = new dojo.data.ItemFileWriteStore({data:ccm.initStoreData('code', {identifier:'code'})}) - cmGrid.setStore(store); - cmGrid.render(); - dojo.connect(store, 'onSet', cmGridChanged); - fieldmapper.standardRequest( - ['open-ils.pcrud', 'open-ils.pcrud.search.ccm'], - { async: true, - params: [openils.User.authtoken, {code:{'!=':null}}], - onresponse: function (r) { - if(obj = openils.Util.readResponse(r)) { - store.newItem(ccm.toStoreItem(obj)); - cmCache[obj.code()] = obj; - } - } - } - ); + cmGrid.overrideEditWidgets.sip2_media_type = sip2Selector; + cmGrid.loadAll({order_by:{ccm : 'name'}}); } - -function cmGridChanged(item, attr, oldVal, newVal) { - var cm = cmCache[cmGrid.store.getValue(item, 'code')]; - console.log("changing cm " + cm.code() + " object: " + attr + " = " + newVal); - cm[attr](newVal); - cm.ischanged(true); - cmSaveButton.setDisabled(false); -} -function saveChanges() { - cmGrid.doclick(0); - var changedObjects = []; - for(var i in cmCache){ - var cm = cmCache[i]; - if(cm.ischanged()) - changedObjects.push(cm); - } - _saveChanges(changedObjects, 0); -} -function _saveChanges(changedObjects, idx) { - - if(idx >= changedObjects.length) { - // we've made it through the list - cmSaveButton.setDisabled(true); - return; - } - - var item = changedObjects[idx]; - - fieldmapper.standardRequest( - ['open-ils.permacrud', 'open-ils.permacrud.update.ccm'], - { async: true, - params: [openils.User.authtoken, item], - oncomplete: function(r) { - if(stat = openils.Util.readResponse(r)) { - _saveChanges(changedObjects, ++idx); - } - } - } - ); -} -function formatMagneticMedia(inDatum) { - switch (inDatum) { - case 't': - return ""; - case 'f': - return ""; - } -} - -function cmCreate(args) { - if(! (args.code && args.name && args.description && args.sip2_media_type)) - return; - - var cmod = new ccm(); - cmod.code(args.code); - cmod.name(args.name); - cmod.description(args.description); - cmod.sip2_media_type(args.sip2_media_type); - if(args.magnetic_media[0] == 'on') - cmod.magnetic_media('t') - else - cmod.magnetic_media('f'); - - fieldmapper.standardRequest( - ['open-ils.permacrud', 'open-ils.permacrud.create.ccm'], - { async: true, - params: [openils.User.authtoken, cmod], - oncomplete: function(r) { - if(cm = openils.Util.readResponse(r)) - cmGrid.store.newItem(ccm.toStoreItem(cm)); - } - } - ); -} - -function deleteFromGrid() { - _deleteFromGrid(cmGrid.selection.getSelected(), 0); -} - -function _deleteFromGrid(list, idx) { - if(idx >= list.length) // we've made it through the list - return; - - var item = list[idx]; - var code = cmGrid.store.getValue(item, 'code'); - - fieldmapper.standardRequest( - ['open-ils.permacrud', 'open-ils.permacrud.delete.ccm'], - { async: true, - params: [openils.User.authtoken, code], - oncomplete: function(r) { - if(stat = openils.Util.readResponse(r)) { - // delete succeeded, remove it from the grid and the local cache - cmGrid.store.deleteItem(item); - delete cmCache[item.code]; - } - _deleteFromGrid(list, ++idx); - } - } - ); -} - + openils.Util.addOnLoad(buildCMGrid); + + \ No newline at end of file diff --git a/Open-ILS/web/templates/default/conify/global/config/circ_modifier.tt2 b/Open-ILS/web/templates/default/conify/global/config/circ_modifier.tt2 index ee86a77fbf..69f7da1a36 100644 --- a/Open-ILS/web/templates/default/conify/global/config/circ_modifier.tt2 +++ b/Open-ILS/web/templates/default/conify/global/config/circ_modifier.tt2 @@ -3,104 +3,76 @@

Circulation Modifier


-
- New Circulation Modifier -
- - - - - - - - - - - - - - - - - - - - - - - -
- -
-
- -
-
-
- - - - -
- + + +
+
+
Circulation Modifier
+
+ +
+
+ +
- - - - - + + -
CodeNameDescriptionSIP2 Media TypeMagnetic Media + +
+
- [% END %] diff --git a/Open-ILS/web/templates/default/menu.tt2 b/Open-ILS/web/templates/default/menu.tt2 index d05b2d56e4..7dd70a81ec 100644 --- a/Open-ILS/web/templates/default/menu.tt2 +++ b/Open-ILS/web/templates/default/menu.tt2 @@ -84,7 +84,7 @@
Currency Types
Exchange Rates
+ onClick="location.href = '[% ctx.base_uri %]/conify/global/acq/exchange_rate';">Exchange Rates
Distribution Formulas
-- 2.43.2