[open-ils-commits] r15698 - trunk/Open-ILS/web/conify/global/permission (miker)
svn at svn.open-ils.org
svn at svn.open-ils.org
Thu Mar 4 14:49:07 EST 2010
Author: miker
Date: 2010-03-04 14:49:03 -0500 (Thu, 04 Mar 2010)
New Revision: 15698
Modified:
trunk/Open-ILS/web/conify/global/permission/perm_list.html
trunk/Open-ILS/web/conify/global/permission/perm_list.js
Log:
MORE: convert from permacrud to pcrud -- not as big as it looks -- and move some startup logic to the top (even though yslow will hate me)
Modified: trunk/Open-ILS/web/conify/global/permission/perm_list.html
===================================================================
--- trunk/Open-ILS/web/conify/global/permission/perm_list.html 2010-03-04 19:33:29 UTC (rev 15697)
+++ trunk/Open-ILS/web/conify/global/permission/perm_list.html 2010-03-04 19:49:03 UTC (rev 15698)
@@ -62,95 +62,87 @@
<script type="text/javascript" src="perm_list.js"></script>
- </head>
+ <script type="dojo/method"><![CDATA[
+ var highlighter= {};
+ highlighter.green = dojox.fx.highlight( { color : '#B4FFB4', node : 'grid_container', duration : 500 } );
+ highlighter.red = dojox.fx.highlight( { color : '#FF2018', node : 'grid_container', duration : 500 } );
- <body class="tundra" id='pagebody'>
+ var dirtyStore = [];
+ var perm_rows = [];
- <div dojoType="dijit.layout.LayoutContainer" id="grid_container" jsId="grid_container" orientation="vertical">
- <script type="dojo/method">
-<![CDATA[
- window.highlighter= {};
- window.highlighter.green = dojox.fx.highlight( { color : '#B4FFB4', node : 'grid_container', duration : 500 } );
- window.highlighter.red = dojox.fx.highlight( { color : '#FF2018', node : 'grid_container', duration : 500 } );
+ var _perm_list = pCRUD.retrieveAll('ppl');
+ var _perm_data = ppl.toStoreData( _perm_list, 'code' );
+ var perm_store = new dojo.data.ItemFileWriteStore({ data : _perm_data });
- window.dirtyStore = [];
+ perm_store.onSet = function (item, attr, o, n) {
+ if (attr == 'ischanged') return;
+ if (n == o) return;
+ this.setValue( item, 'ischanged', 1);
+ };
+ var perm_data_model = new dojox.grid.data.DojoData({ store: perm_store, query: { code : '*' } });
- pCRUD.request({
- method : 'open-ils.permacrud.search.ppl.atomic',
- timeout : 10,
- params : [ ses, { id : { "!=" : null } }, { order_by : { ppl : 'code' } } ],
- onerror : function (r) { status_update(ppl_strings.ERROR_FETCHING_PERMS) },
- oncomplete : function (r) {
+ var perm_grid_layout = [
+ { cells : [
+ [
+ { name : ppl_strings.LABEL_CODE, field : "code", width : "300px", editor : dojox.grid.editors.Dijit, rowSpan : "2" },
+ { name : ppl_strings.LABEL_DESCRIPTION, field : "description", width : "auto", editor : dojox.grid.editors.Editor, style : "minHeight:1em;" }
+ ],
+ [
+ { name : ppl_strings.LABEL_TRANSLATION,
+ width : "10em",
+ height : "2em",
+ get : function (row) {
+ var r = perm_data_model.getRow(row);
+ if (r) {
+ perm_rows[row] = new ccs().fromHash(perm_data_model.getRow(row));
+ setTimeout(
+ 'dojo.query(".perm_grid_trans_desc_' + row + '").'+
+ 'instantiate(openils.widget.TranslatorPopup,{field:"description",'+
+ 'targetObject:"window.perm_rows['+row+']"});'+
+ 'perm_grid.rowHeightChanged('+row+')',
+ 0
+ );
+ var oldnode = dojo.byId('description_translation_' + row);
+ if (oldnode) dijit.byNode(oldnode).destroyRecursive();
+ return '<span class="perm_grid_trans_desc_'+row+'"></span>';
+ }
+ return '';
+ }
+ }
+ ]
+ ]
+ }
+ ];
- window._perm_list = r.recv().content();
- window._perm_data = ppl.toStoreData( window._perm_list, 'code' );
- window.perm_store = new dojo.data.ItemFileWriteStore({ data : window._perm_data });
+ dojo.addOnUnload( function (event) {
- perm_store.onSet = function (item, attr, o, n) {
- if (attr == 'ischanged') return;
- if (n == o) return;
- this.setValue( item, 'ischanged', 1);
- };
+ perm_store.fetch({
+ query : { ischanged : 1 },
+ onItem : function (item, req) { try { if (this.isItem( item )) window.dirtyStore.push( item ); } catch (e) { /* meh */ } },
+ scope : perm_store
+ });
- window.perm_grid_layout = [
- { cells : [
- [
- { name : ppl_strings.LABEL_CODE, field : "code", width : "300px", editor : dojox.grid.editors.Dijit, rowSpan : "2" },
- { name : ppl_strings.LABEL_DESCRIPTION, field : "description", width : "auto", editor : dojox.grid.editors.Editor, style : "minHeight:1em;" }
- ],
- [
- { name : ppl_strings.LABEL_TRANSLATION,
- width : "10em",
- height : "2em",
- get : function (row) {
- if (!window.perm_rows) window.perm_rows = [];
- var r = window.perm_data_model.getRow(row);
- if (r) {
- window.perm_rows[row] = new ccs().fromHash(window.perm_data_model.getRow(row));
- setTimeout(
- 'dojo.query(".perm_grid_trans_desc_' + row + '").'+
- 'instantiate(openils.widget.TranslatorPopup,{field:"description",'+
- 'targetObject:"window.perm_rows['+row+']"});'+
- 'perm_grid.rowHeightChanged('+row+')',
- 0
- );
- var oldnode = dojo.byId('description_translation_' + row);
- if (oldnode) dijit.byNode(oldnode).destroyRecursive();
- return '<span class="perm_grid_trans_desc_'+row+'"></span>';
- }
- return '';
- }
- }
- ]
- ]
- }
- ];
+ if (dirtyStore.length > 0) {
+ var confirmation = confirm(ppl_strings.CONFIRM_EXIT_PPL);
- dojo.addOnUnload( function (event) {
+ if (confirmation) {
+ for (var i in dirtyStore) {
+ window.current_perm = dirtyStore[i];
+ save_perm(true);
+ }
+ }
+ }
- perm_store.fetch({
- query : { ischanged : 1 },
- onItem : function (item, req) { try { if (this.isItem( item )) window.dirtyStore.push( item ); } catch (e) { /* meh */ } },
- scope : perm_store
- });
+ });
+]]>
+ </script>
- if (dirtyStore.length > 0) {
- var confirmation = confirm(ppl_strings.CONFIRM_EXIT_PPL);
- if (confirmation) {
- for (var i in window.dirtyStore) {
- window.current_perm = window.dirtyStore[i];
- save_perm(true);
- }
- }
- }
+ </head>
- });
- }
- }).send();
-]]>
- </script>
+ <body class="tundra" id='pagebody'>
+ <div dojoType="dijit.layout.LayoutContainer" id="grid_container" jsId="grid_container" orientation="vertical">
<div dojoType="dijit.layout.LayoutContainer" orientation="horizontal" style="margin-top: 5px;" layoutAlign="top">
<span>&conify.perm_list.new_permission.label;</span>
<div dojoType="dijit.form.TextBox" id="new_perm_code" jsId="new_perm_code" label="&conify.perm_list.new_code.label;"></div>
@@ -166,37 +158,26 @@
});
var err = false;
- pCRUD.request({
- method : 'open-ils.permacrud.create.ppl',
- timeout : 10,
- params : [ ses, new_fm_obj ],
+ pCRUD.create(new_fm_objnew_fm_obj, {
onerror : function (r) {
highlighter.red.play();
status_update( ppl_strings.ERROR_CALLING_METHOD_PPL );
err = true;
},
- oncomplete : function (r) {
- var res = r.recv();
- if ( res && res.content() ) {
- var new_item_hash = res.content().toHash();
- perm_store.newItem( new_item_hash );
- status_update( dojo.string.substitute(ppl_strings.SUCCESS_CREATING_PERMISSION, [new_item_hash.code]) );
- perm_grid.model.sort(-1);
- highlighter.green.play();
- } else {
- highlighter.red.play();
- status_update( ppl_strings.ERROR_CREATING_PERMISSION );
- err = true;
- }
+ oncomplete : function (r, list) {
+ var new_item_hash = list[0].toHash();
+ perm_store.newItem( new_item_hash );
+ status_update( dojo.string.substitute(ppl_strings.SUCCESS_CREATING_PERMISSION, [new_item_hash.code]) );
+ perm_grid.model.sort(-1);
+ highlighter.green.play();
}
- }).send();
+ });
]]>
</script>
</button>
</div>
<div dojoType="dijit.layout.ContentPane" style="width:100%; height:100%;" layoutAlign="client">
- <div dojoType="dojox.grid.data.DojoData" id="perm_data_model" jsId="perm_data_model" store="perm_store" query="{ code : '*' }"></div>
<div id="perm_grid" dojoType="dojox.Grid" model="perm_data_model" structure="perm_grid_layout" jsId="perm_grid">
<!--
<script type="dojo/connect" event="onSet" args="item,attr,oldVal,newVal">
@@ -233,36 +214,26 @@
var modified_ppl = new ppl().fromStoreItem( current_perm );
modified_ppl.isdeleted( 1 );
- pCRUD.request({
- method : 'open-ils.permacrud.delete.ppl',
- timeout : 10,
- params : [ ses, modified_ppl ],
+ pCRUD.eliminate(modified_ppl, {
onerror : function (r) {
highlighter.red.play();
status_update( dojo.string.substitute(ppl_strings.ERROR_DELETING, [perm_store.getValue( current_perm, 'code' )]) );
},
oncomplete : function (r) {
- var res = r.recv();
- if ( res && res.content() ) {
-
- var old_name = perm_store.getValue( current_perm, 'code' );
-
- perm_store.fetch({
- query : { id : perm_store.getValue( current_perm, 'id' ) },
- onItem : function (item, req) { try { if (this.isItem( item )) this.deleteItem( item ); } catch (e) { /* meh */ } },
- scope : perm_store
- });
-
- current_perm = null;
-
- highlighter.green.play();
- status_update( dojo.string.substitute(ppl_strings.STATUS_DELETED, [old_name]) );
- } else {
- highlighter.red.play();
- status_update( dojo.string.substitute(ppl_strings.ERROR_DELETING, [old_name]) );
- }
+ var old_name = perm_store.getValue( current_perm, 'code' );
+
+ perm_store.fetch({
+ query : { id : perm_store.getValue( current_perm, 'id' ) },
+ onItem : function (item, req) { try { if (this.isItem( item )) this.deleteItem( item ); } catch (e) { /* meh */ } },
+ scope : perm_store
+ });
+
+ current_perm = null;
+
+ highlighter.green.play();
+ status_update( dojo.string.substitute(ppl_strings.STATUS_DELETED, [old_name]) );
}
- }).send();
+ });
}
}
Modified: trunk/Open-ILS/web/conify/global/permission/perm_list.js
===================================================================
--- trunk/Open-ILS/web/conify/global/permission/perm_list.js 2010-03-04 19:33:29 UTC (rev 15697)
+++ trunk/Open-ILS/web/conify/global/permission/perm_list.js 2010-03-04 19:49:03 UTC (rev 15698)
@@ -18,6 +18,7 @@
dojo.require('fieldmapper.AutoIDL');
dojo.require('fieldmapper.dojoData');
dojo.require('openils.widget.TranslatorPopup');
+dojo.require('openils.PermaCrud');
dojo.require('dojo.parser');
dojo.require('dojo.string');
dojo.require('dojo.data.ItemFileWriteStore');
@@ -36,7 +37,7 @@
var cgi = new CGI();
var cookieManager = new HTTP.Cookies();
var ses = cookieManager.read('ses') || cgi.param('ses');
-var pCRUD = new OpenSRF.ClientSession('open-ils.permacrud');
+var pCRUD = new openils.PermaCrud({authtoken : ses});
var ppl_strings = dojo.i18n.getLocalization('openils.conify', 'conify');
@@ -56,26 +57,17 @@
modified_ppl.description( dojo.string.trim( modified_ppl.description() ) );
modified_ppl.code( dojo.string.trim( modified_ppl.code() ) );
- pCRUD.request({
- method : 'open-ils.permacrud.update.ppl',
- timeout : 10,
- params : [ ses, modified_ppl ],
+ pCRUD.update(modified_ppl, {
onerror : function (r) {
highlighter.red.play();
status_update( dojo.string.substitute(ppl_strings.ERROR_SAVING_DATA, [perm_store.getValue(current_perm, 'code')]) );
},
oncomplete : function (r) {
- var res = r.recv();
- if ( res && res.content() ) {
- perm_store.setValue( current_perm, 'ischanged', 0 );
- highlighter.green.play();
- status_update( dojo.string.substitute(ppl_strings.SUCCESS_SAVE, [perm_store.getValue(current_perm, 'code')]) );
- } else {
- highlighter.red.play();
- status_update( dojo.string.substitute(ppl_strings.ERROR_SAVING_DATA, [perm_store.getValue(current_perm, 'code')]) );
- }
- },
- }).send();
+ perm_store.setValue( current_perm, 'ischanged', 0 );
+ highlighter.green.play();
+ status_update( dojo.string.substitute(ppl_strings.SUCCESS_SAVE, [perm_store.getValue(current_perm, 'code')]) );
+ }
+ });
}
function save_them_all (event) {
More information about the open-ils-commits
mailing list