[open-ils-commits] r15715 - in branches/rel_1_6/Open-ILS/web/conify/global: actor config permission (miker)
svn at svn.open-ils.org
svn at svn.open-ils.org
Fri Mar 5 12:07:35 EST 2010
Author: miker
Date: 2010-03-05 12:07:32 -0500 (Fri, 05 Mar 2010)
New Revision: 15715
Modified:
branches/rel_1_6/Open-ILS/web/conify/global/actor/org_unit_type.html
branches/rel_1_6/Open-ILS/web/conify/global/actor/org_unit_type.js
branches/rel_1_6/Open-ILS/web/conify/global/config/copy_status.html
branches/rel_1_6/Open-ILS/web/conify/global/config/copy_status.js
branches/rel_1_6/Open-ILS/web/conify/global/config/marc_code_maps.html
branches/rel_1_6/Open-ILS/web/conify/global/config/marc_code_maps.js
branches/rel_1_6/Open-ILS/web/conify/global/permission/grp_tree.html
branches/rel_1_6/Open-ILS/web/conify/global/permission/grp_tree.js
branches/rel_1_6/Open-ILS/web/conify/global/permission/perm_list.html
branches/rel_1_6/Open-ILS/web/conify/global/permission/perm_list.js
Log:
backporting conify fixes from trunk
Modified: branches/rel_1_6/Open-ILS/web/conify/global/actor/org_unit_type.html
===================================================================
--- branches/rel_1_6/Open-ILS/web/conify/global/actor/org_unit_type.html 2010-03-05 16:58:40 UTC (rev 15714)
+++ branches/rel_1_6/Open-ILS/web/conify/global/actor/org_unit_type.html 2010-03-05 17:07:32 UTC (rev 15715)
@@ -62,56 +62,53 @@
<script type="text/javascript" src="org_unit_type.js"></script>
- </head>
+ <script type="text/javascript">
+<![CDATA[
+ var dirtyStore = [];
- <body class="tundra" id='pagebody'>
+ var _out_type_list = pCRUD.retrieveAll('aout', { order_by : { aout : 'name' } });
- <div dojoType="dijit.layout.SplitContainer" orientation="horizontal" style="height: 100%">
+ var ou_type_store = new dojo.data.ItemFileWriteStore({ data : aout.toStoreData( _out_type_list ) });
- <div dojoType="dijit.layout.ContentPane" sizeShare="100">
- <script type="dojo/method">
-<![CDATA[
- window.dirtyStore = [];
+ ou_type_store.onSet = function (item, attr, o, n) {
+ if (attr == 'ischanged') return;
+ if (n == o) return;
+ this.setValue( item, 'ischanged', 1);
+ };
- pCRUD.request({
- method : 'open-ils.permacrud.search.aout.atomic',
- timeout : 10,
- params : [ ses, { id : { "!=" : null } }, { order_by : { aout : 'name' } } ],
- onerror : function (r) { status_update( aout_strings.ERROR_FETCHING_TYPES_AOUT ) },
- oncomplete : function (r) {
- ou_type_store = new dojo.data.ItemFileWriteStore({ data : aout.toStoreData( r.recv().content() ) });
- ou_type_store.onSet = function (item, attr, o, n) {
- if (attr == 'ischanged') return;
- if (n == o) return;
- this.setValue( item, 'ischanged', 1);
- };
- dojo.addOnUnload( function (event) {
+ dojo.addOnUnload( function (event) {
- ou_type_store.fetch({
- query : { ischanged : 1 },
- queryOptions : { deep : true },
- onItem : function (item, req) { try { if (this.isItem( item )) window.dirtyStore.push( item ); } catch (e) { /* meh */ } },
- scope : ou_type_store
- });
+ ou_type_store.fetch({
+ query : { ischanged : 1 },
+ queryOptions : { deep : true },
+ onItem : function (item, req) { try { if (this.isItem( item )) dirtyStore.push( item ); } catch (e) { /* meh */ } },
+ scope : ou_type_store
+ });
- if (dirtyStore.length > 0) {
- var confirmation = confirm(
- aout_strings.CONFIRM_UNSAVED_CHANGES
- );
+ if (dirtyStore.length > 0) {
+ var confirmation = confirm(
+ aout_strings.CONFIRM_UNSAVED_CHANGES
+ );
- if (confirmation) {
- for (var i in window.dirtyStore) {
- window.current_type = window.dirtyStore[i];
- save_type(true);
- }
- }
- }
-
- });
+ if (confirmation) {
+ for (var i in dirtyStore) {
+ current_type = dirtyStore[i];
+ save_type(true);
}
- }).send();
+ }
+ }
+
+ });
]]>
- </script>
+ </script>
+
+ </head>
+
+ <body class="tundra" id='pagebody'>
+
+ <div dojoType="dijit.layout.SplitContainer" orientation="horizontal" style="height: 100%">
+
+ <div dojoType="dijit.layout.ContentPane" sizeShare="100">
<div
id="type_tree"
label="&conify.org_unit_type.type_tree.label;"
@@ -313,51 +310,42 @@
var modified_aout = new aout().fromStoreItem( current_type );
modified_aout.isdeleted( 1 );
- pCRUD.request({
- method : 'open-ils.permacrud.delete.aout',
- timeout : 10,
- params : [ ses, modified_aout ],
+ pCRUD.eliminate(modified_aout, {
onerror : function (r) {
highlighter.editor_pane.red.play();
status_update( dojo.string.substitute ( aout_strings.ERROR_DELETING, [ou_type_store.getValue( current_type, 'name' )] ) );
},
oncomplete : function (r) {
- var res = r.recv();
- if ( res && res.content() ) {
- var old_name = ou_type_store.getValue( current_type, 'name' );
+ var old_name = ou_type_store.getValue( current_type, 'name' );
- ou_type_store.fetch({
- query : { id : ou_type_store.getValue( current_type, 'id' ) },
- queryOptions : { deep : true },
- onItem : function (item, req) { try { if (this.isItem( item )) this.deleteItem( item ); } catch (e) { /* meh */ } },
- scope : ou_type_store
- });
+ ou_type_store.fetch({
+ query : { id : ou_type_store.getValue( current_type, 'id' ) },
+ queryOptions : { deep : true },
+ onItem : function (item, req) { try { if (this.isItem( item )) this.deleteItem( item ); } catch (e) { /* meh */ } },
+ scope : ou_type_store
+ });
- current_type = null;
+ current_type = null;
- new_kid_button.disabled = true;
- save_out_button.disabled = true;
- delete_out_button.disabled = true;
+ new_kid_button.disabled = true;
+ save_out_button.disabled = true;
+ delete_out_button.disabled = true;
- var main_settings_fields = [ 'name', 'opac_label' ];
- for ( var i in main_settings_fields ) {
- var field = main_settings_fields[i];
- window["editor_pane_" + field].setValue( '' ); // unset the value
- window["editor_pane_" + field].setDisplayedValue( '' ); // unset the value
- }
-
- window["editor_pane_can_have_vols"].setChecked( false ); // unset the value
- window["editor_pane_can_have_users"].setChecked( false ); // unset the value
-
- highlighter.editor_pane.green.play();
- status_update( dojo.string.substitute( aout_strings.STATUS_DELETED, [old_name] ) );
- } else {
- highlighter.editor_pane.red.play();
- status_update( dojo.string.substitute( aout_strings.ERROR_DELETING, [old_name] ) );
+ var main_settings_fields = [ 'name', 'opac_label' ];
+ for ( var i in main_settings_fields ) {
+ var field = main_settings_fields[i];
+ window["editor_pane_" + field].setValue( '' ); // unset the value
+ window["editor_pane_" + field].setDisplayedValue( '' ); // unset the value
}
+
+ window["editor_pane_can_have_vols"].setChecked( false ); // unset the value
+ window["editor_pane_can_have_users"].setChecked( false ); // unset the value
+
+ highlighter.editor_pane.green.play();
+ status_update( dojo.string.substitute( aout_strings.STATUS_DELETED, [old_name] ) );
}
- }).send();
+ });
}
]]>
@@ -382,27 +370,17 @@
parent : ou_type_store.getValue( current_type, 'id' )
});
var err = false;
- pCRUD.request({
- method : 'open-ils.permacrud.create.aout',
- timeout : 10,
- params : [ ses, new_fm_obj ],
+ pCRUD.create(new_fm_obj, {
onerror : function (r) {
highlighter.editor_pane.red.play();
status_update( aout_strings.ERROR_CALLING_METHOD_AOUT );
err = true;
},
- oncomplete : function (r) {
- var res = r.recv();
- if ( res && res.content() ) {
- ou_type_store.newItem(
- res.content().toHash(),
- { parent : current_type, attribute : 'children' }
- );
- } else {
- highlighter.editor_pane.red.play();
- status_update( aout_strings.ERROR_CREATING_CHILD_AOUT );
- err = true;
- }
+ oncomplete : function (r, list) {
+ ou_type_store.newItem(
+ list[0].toHash(),
+ { parent : current_type, attribute : 'children' }
+ );
},
}).send();
Modified: branches/rel_1_6/Open-ILS/web/conify/global/actor/org_unit_type.js
===================================================================
--- branches/rel_1_6/Open-ILS/web/conify/global/actor/org_unit_type.js 2010-03-05 16:58:40 UTC (rev 15714)
+++ branches/rel_1_6/Open-ILS/web/conify/global/actor/org_unit_type.js 2010-03-05 17:07:32 UTC (rev 15715)
@@ -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.data.ItemFileWriteStore');
dojo.require('dojo.date.stamp');
@@ -40,7 +41,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 current_type;
var current_fm_type;
@@ -63,25 +64,16 @@
save_out_button.disabled = false;
delete_out_button.disabled = false;
- pCRUD.request({
- method : 'open-ils.permacrud.update.aout',
- timeout : 10,
- params : [ ses, modified_aout ],
+ pCRUD.update(modified_aout, {
onerror : function (r) {
highlighter.editor_pane.red.play();
status_update( dojo.string.substitute(aout_strings.ERROR_SAVING_DATA, [ou_type_store.getValue( current_type, 'name' )] ) );
},
oncomplete : function (r) {
- var res = r.recv();
- if ( res && res.content() ) {
- ou_type_store.setValue( current_type, 'ischanged', 0 );
- highlighter.editor_pane.green.play();
- status_update( dojo.string.substitute(aout_strings.SUCCESS_SAVING_DATA, [ou_type_store.getValue( current_type, 'name' )] ) );
- } else {
- highlighter.editor_pane.red.play();
- status_update( dojo.string.substitute(aout_strings.ERROR_SAVING_DATA, [ou_type_store.getValue( current_type, 'name' )] ) );
- }
- },
- }).send();
+ ou_type_store.setValue( current_type, 'ischanged', 0 );
+ highlighter.editor_pane.green.play();
+ status_update( dojo.string.substitute(aout_strings.SUCCESS_SAVING_DATA, [ou_type_store.getValue( current_type, 'name' )] ) );
+ }
+ });
}
Modified: branches/rel_1_6/Open-ILS/web/conify/global/config/copy_status.html
===================================================================
--- branches/rel_1_6/Open-ILS/web/conify/global/config/copy_status.html 2010-03-05 16:58:40 UTC (rev 15714)
+++ branches/rel_1_6/Open-ILS/web/conify/global/config/copy_status.html 2010-03-05 17:07:32 UTC (rev 15715)
@@ -63,70 +63,58 @@
<script type="text/javascript" src="copy_status.js"></script>
- </head>
-
- <body class="tundra" id='pagebody'>
-
- <div dojoType="dijit.layout.LayoutContainer" id="grid_container" jsId="grid_container" orientation="vertical">
- <script type="dojo/method">
+ <script type="text/javascript">
<![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 dirtyStore = [];
- window.dirtyStore = [];
+ var _status_list = pCRUD.retrieveAll('ccs', { order_by : { ccs : 'name' } });
+ var _status_data = ccs.toStoreData( _status_list, 'name' );
+ var status_store = new dojo.data.ItemFileWriteStore({ data : _status_data });
- pCRUD.request({
- method : 'open-ils.permacrud.search.ccs.atomic',
- timeout : 10,
- params : [ ses, { id : { "!=" : null } }, { order_by : { ccs : 'name' } } ],
- onerror : function (r) { status_update(ccs_strings.ERROR_FETCHING_STATUSES) },
- oncomplete : function (r) {
+ status_store.onSet = function (item, attr, o, n) {
+ if (attr == 'ischanged') return;
+ if (n == o) return;
+ this.setValue( item, 'ischanged', 1);
- window._status_list = r.recv().content();
- window._status_data = ccs.toStoreData( window._status_list, 'name' );
- window.status_store = new dojo.data.ItemFileWriteStore({ data : window._status_data });
+ if (attr == 'holdable' && typeof n != 'string')
+ this.setValue(item, 'holdable', n ? 't' : 'f');
- window.status_store.onSet = function (item, attr, o, n) {
- if (attr == 'ischanged') return;
- if (n == o) return;
- this.setValue( item, 'ischanged', 1);
+ if (attr == 'opac_visible' && typeof n != 'string')
+ this.setValue(item, 'opac_visible', n ? 't' : 'f');
- if (attr == 'holdable' && typeof n != 'string')
- this.setValue(item, 'holdable', n ? 't' : 'f');
+ };
- if (attr == 'opac_visible' && typeof n != 'string')
- this.setValue(item, 'opac_visible', n ? 't' : 'f');
+ dojo.addOnUnload( function (event) {
- };
+ status_store.fetch({
+ query : { ischanged : 1 },
+ onItem : function (item, req) { try { if (this.isItem( item )) dirtyStore.push( item ); } catch (e) { /* meh */ } },
+ scope : status_store
+ });
- dojo.addOnUnload( function (event) {
+ if (dirtyStore.length > 0) {
+ var confirmation = confirm(
+ ccs_strings.CONFIRM_EXIT_CCS
+ );
- status_store.fetch({
- query : { ischanged : 1 },
- onItem : function (item, req) { try { if (this.isItem( item )) window.dirtyStore.push( item ); } catch (e) { /* meh */ } },
- scope : status_store
- });
+ if (confirmation) {
+ for (var i in window.dirtyStore) {
+ current_status = dirtyStore[i];
+ save_status(true);
+ }
+ }
+ }
- if (dirtyStore.length > 0) {
- var confirmation = confirm(
- ccs_strings.CONFIRM_EXIT_CCS
- );
+ });
+]]>
+ </script>
- if (confirmation) {
- for (var i in window.dirtyStore) {
- window.current_status = window.dirtyStore[i];
- save_status(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.copy_status.new_status.label;</span>
<div dojoType="dijit.form.TextBox" id="new_status_code" jsId="new_status_name" label="&conify.copy_status.new_status.name;"></div>
@@ -142,30 +130,20 @@
});
var err = false;
- pCRUD.request({
- method : 'open-ils.permacrud.create.ccs',
- timeout : 10,
- params : [ ses, new_fm_obj ],
+ pCRUD.create(new_fm_obj, {
onerror : function (r) {
highlighter.red.play();
status_update( ccs_strings.ERROR_CALLING_METHOD_CCS );
err = true;
},
- oncomplete : function (r) {
- var res = r.recv();
- if ( res && res.content() ) {
- var new_item_hash = res.content().toHash();
- status_store.newItem( new_item_hash );
- status_update( dojo.string.substitute(ccs_strings.SUCCESS_CREATING_STATUS, [new_item_hash.name]) );
- status_grid.model.sort(-2);
- highlighter.green.play();
- } else {
- highlighter.red.play();
- status_update( ccs_strings.ERROR_CREATING_STATUS );
- err = true;
- }
+ oncomplete : function (r, list) {
+ var new_item_hash = list[0].toHash();
+ status_store.newItem( new_item_hash );
+ status_update( dojo.string.substitute(ccs_strings.SUCCESS_CREATING_STATUS, [new_item_hash.name]) );
+ status_grid.model.sort(-2);
+ highlighter.green.play();
}
- }).send();
+ });
]]>
</script>
</button>
@@ -191,6 +169,9 @@
{ name : ccs_strings.TRANSLATION,
width : "10em",
height : "2em",
+ formatter: function (row) {
+ return '<span class="status_grid_trans_cell_'+row+'"></span>';
+ },
get : function (row) {
if (!window.status_rows) window.status_rows = [];
var r = window.status_data_model.getRow(row);
@@ -203,7 +184,7 @@
'status_grid.rowHeightChanged('+row+')',
0
);
- return '<span class="status_grid_trans_cell_'+row+'"></span>';
+ return row;
}
return '';
}
@@ -272,36 +253,26 @@
var modified_ccs = new ccs().fromStoreItem( current_status );
modified_ccs.isdeleted( 1 );
- pCRUD.request({
- method : 'open-ils.permacrud.delete.ccs',
- timeout : 10,
- params : [ ses, modified_ccs ],
+ pCRUD.eliminate(modified_ccs, {
onerror : function (r) {
highlighter.red.play();
status_update( dojo.string.substitute( ccs_strings.ERROR_DELETING, [status_store.getValue( current_status, 'name' )] ) );
},
oncomplete : function (r) {
- var res = r.recv();
- if ( res && res.content() ) {
-
- var old_name = status_store.getValue( current_status, 'name' );
+ var old_name = status_store.getValue( current_status, 'name' );
- status_store.fetch({
- query : { id : status_store.getValue( current_status, 'id' ) },
- onItem : function (item, req) { try { if (this.isItem( item )) this.deleteItem( item ); } catch (e) { /* meh */ } },
- scope : status_store
- });
+ status_store.fetch({
+ query : { id : status_store.getValue( current_status, 'id' ) },
+ onItem : function (item, req) { try { if (this.isItem( item )) this.deleteItem( item ); } catch (e) { /* meh */ } },
+ scope : status_store
+ });
- current_status = null;
+ current_status = null;
- highlighter.green.play();
- status_update( dojo.string.substitute(ccs_strings.STATUS_DELETED, [old_name]) );
- } else {
- highlighter.red.play();
- status_update( dojo.string.substitute(ccs_strings.ERROR_DELETING, [old_name]) );
- }
+ highlighter.green.play();
+ status_update( dojo.string.substitute(ccs_strings.STATUS_DELETED, [old_name]) );
}
- }).send();
+ });
}
}
@@ -312,5 +283,11 @@
</div>
</div>
+ <script type="text/javascript">
+ 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 } );
+ </script>
+
</body>
</html>
Modified: branches/rel_1_6/Open-ILS/web/conify/global/config/copy_status.js
===================================================================
--- branches/rel_1_6/Open-ILS/web/conify/global/config/copy_status.js 2010-03-05 16:58:40 UTC (rev 15714)
+++ branches/rel_1_6/Open-ILS/web/conify/global/config/copy_status.js 2010-03-05 17:07:32 UTC (rev 15715)
@@ -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 current_status;
var virgin_out_id = -1;
@@ -54,26 +55,17 @@
var modified_ccs = new ccs().fromStoreItem( current_status );
modified_ccs.ischanged( 1 );
- pCRUD.request({
- method : 'open-ils.permacrud.update.ccs',
- timeout : 10,
- params : [ ses, modified_ccs ],
+ pCRUD.update(modified_ccs, {
onerror : function (r) {
highlighter.red.play();
status_update( dojo.string.substitute(ccs_strings.ERROR_SAVING_STATUS, [status_store.getValue( current_status, 'name' )]) );
},
oncomplete : function (r) {
- var res = r.recv();
- if ( res && res.content() ) {
- status_store.setValue( current_status, 'ischanged', 0 );
- highlighter.green.play();
- status_update( dojo.string.substitute(ccs_strings.SUCCESS_SAVE, [status_store.getValue( current_status, 'name' )]) );
- } else {
- highlighter.red.play();
- status_update( dojo.string.substitute(ccs_strings.ERROR_SAVING_STATUS, [status_store.getValue( current_status, 'name' )]) );
- }
- },
- }).send();
+ status_store.setValue( current_status, 'ischanged', 0 );
+ highlighter.green.play();
+ status_update( dojo.string.substitute(ccs_strings.SUCCESS_SAVE, [status_store.getValue( current_status, 'name' )]) );
+ }
+ });
}
function save_them_all (event) {
Modified: branches/rel_1_6/Open-ILS/web/conify/global/config/marc_code_maps.html
===================================================================
--- branches/rel_1_6/Open-ILS/web/conify/global/config/marc_code_maps.html 2010-03-05 16:58:40 UTC (rev 15714)
+++ branches/rel_1_6/Open-ILS/web/conify/global/config/marc_code_maps.html 2010-03-05 17:07:32 UTC (rev 15715)
@@ -81,6 +81,9 @@
{ name : cam_strings.LABEL_TRANSLATION,
width : "10em",
height : "2em",
+ formatter : function (row) {
+ return '<span class="cam_value_'+row+'"></span>';
+ },
get : function (row) {
if (!grid_row_object_cache.cam) grid_row_object_cache.cam = [];
var r = this.grid.model.getRow(row);
@@ -96,7 +99,7 @@
);
var oldnode = dojo.byId('value_translation_cam_' + row);
if (oldnode) dijit.byNode(oldnode).destroyRecursive();
- return '<span class="cam_value_'+row+'"></span>';
+ return row;
}
return '';
}
@@ -104,6 +107,9 @@
{ name : cam_strings.LABEL_TRANSLATION,
width : "10em",
height : "2em",
+ formatter : function (row) {
+ return '<span class="cam_description_'+row+'"></span>';
+ },
get : function (row) {
if (!grid_row_object_cache.cam) grid_row_object_cache.cam = [];
var r = this.grid.model.getRow(row);
@@ -119,7 +125,7 @@
);
var oldnode = dojo.byId('description_translation_cam_' + row);
if (oldnode) dijit.byNode(oldnode).destroyRecursive();
- return '<span class="cam_description_'+row+'"></span>';
+ return row;
}
return '';
}
@@ -171,6 +177,9 @@
{ name : cam_strings.LABEL_TRANSLATION,
width : "10em",
height : "2em",
+ formatter : function (row) {
+ return '<span class="'+classname+'_value_'+row+'"></span>';
+ },
get : function (row) {
if (!grid_row_object_cache[classname]) grid_row_object_cache[classname] = [];
var r = this.grid.model.getRow(row);
@@ -186,7 +195,7 @@
);
var oldnode = dojo.byId('value_translation_' + classname + '_' + row);
if (oldnode) dijit.byNode(oldnode).destroyRecursive();
- return '<span class="'+classname+'_value_'+row+'"></span>';
+ return row;
}
return '';
}
Modified: branches/rel_1_6/Open-ILS/web/conify/global/config/marc_code_maps.js
===================================================================
--- branches/rel_1_6/Open-ILS/web/conify/global/config/marc_code_maps.js 2010-03-05 16:58:40 UTC (rev 15714)
+++ branches/rel_1_6/Open-ILS/web/conify/global/config/marc_code_maps.js 2010-03-05 17:07:32 UTC (rev 15715)
@@ -18,6 +18,7 @@
dojo.require('fieldmapper.AutoIDL');
dojo.require('fieldmapper.dojoData');
dojo.require('openils.widget.TranslatorPopup');
+dojo.require('openils.PermaCrud');
dojo.require('dojo.cookie');
dojo.require('dojo.parser');
dojo.require('dojo.string');
@@ -40,7 +41,7 @@
// some handy globals
var cgi = new CGI();
var ses = dojo.cookie('ses') || cgi.param('ses');
-var pCRUD = new OpenSRF.ClientSession('open-ils.permacrud');
+var pCRUD = new openils.PermaCrud({authtoken:ses});
console.log('initialized pcrud session');
@@ -77,26 +78,16 @@
if(classname == 'cam' || classname == 'clfm')
obj.description( dojo.string.trim( obj.description() ) );
- pCRUD.request({
- method : 'open-ils.permacrud.update.' + classname,
- timeout : 10,
- params : [ ses, modified_ppl ],
+ pCRUD.update(obj, {
onerror : function (r) {
//highlighter.red.play();
status_update( dojo.string.substitute(cam_strings.ERROR_SAVING_DATA_CAM, [classname, obj.code()]) );
},
oncomplete : function (r) {
- var res = r.recv();
- if ( res && res.content() ) {
- stores[classname].setValue( current_item, 'ischanged', 0 );
- //highlighter.green.play();
- status_update( dojo.string.substitute(cam_strings.SUCCESS_SAVE, stores[classname].getValue( item, 'code' )) );
- } else {
- //highlighter.red.play();
- status_update( dojo.string.substitute( cam_strings.ERROR_SAVING_DATA_CAM, [classname, stores[classname].getValue( item, 'code' )] ) );
- }
- },
- }).send();
+ stores[classname].setValue( current_item, 'ischanged', 0 );
+ status_update( dojo.string.substitute(cam_strings.SUCCESS_SAVE, stores[classname].getValue( item, 'code' )) );
+ }
+ });
}
function save_them_all (event) {
@@ -153,33 +144,21 @@
var obj = new fieldmapper[classname]().fromStoreItem( item );
obj.isdeleted( 1 );
- pCRUD.request({
- method : 'open-ils.permacrud.delete.' + classname,
- timeout : 10,
- params : [ ses, obj ],
+ pCRUD.eliminate(obj, {
onerror : function (r) {
//highlighter.red.play();
status_update( dojo.string.substitute( cam_strings.ERROR_DELETING, [grid.model.store.getValue( item, 'value' )] ) );
},
oncomplete : function (r) {
- var res = r.recv();
- var old_name = grid.model.store.getValue( item, 'value' );
- if ( res && res.content() ) {
-
- grid.model.store.fetch({
- query : { code : grid.model.store.getValue( item, 'code' ) },
- onItem : function (item, req) { try { if (this.isItem( item )) this.deleteItem( item ); } catch (e) { /* meh */ } },
- scope : grid.model.store
- });
+ grid.model.store.fetch({
+ query : { code : grid.model.store.getValue( item, 'code' ) },
+ onItem : function (item, req) { try { if (this.isItem( item )) this.deleteItem( item ); } catch (e) { /* meh */ } },
+ scope : grid.model.store
+ });
- //highlighter.green.play();
- status_update( dojo.string.substitute( cam_strings.STATUS_DELETED, [old_name] ) );
- } else {
- //highlighter.red.play();
- status_update( dojo.string.substitute( cam_strings.ERROR_DELETING, [old_name] ) );
- }
+ status_update( dojo.string.substitute( cam_strings.STATUS_DELETED, [old_name] ) );
}
- }).send();
+ });
}
}
@@ -202,29 +181,19 @@
new_fm_obj.isnew(1);
var err = false;
- pCRUD.request({
- method : 'open-ils.permacrud.create.' + cl,
- timeout : 10,
- params : [ ses, new_fm_obj ],
+ pCRUD.create(new_fm_obj, {
onerror : function (r) {
//highlighter.red.play();
status_update( dojo.string.substitute( cam_strings.ERROR_CALLING_METHOD_CAM, [cl] ) );
err = true;
},
- oncomplete : function (r) {
- var res = r.recv();
- if ( res && res.content() ) {
- var new_item_hash = res.content().toHash();
- stores[cl].newItem( new_item_hash );
- status_update( dojo.string.substitute( cam_strings.SUCCESS_CREATING_CODE, [new_item_hash.code, cl] ) );
- //highlighter.green.play();
- } else {
- //highlighter.red.play();
- status_update( cam_strings.ERROR_CREATING_PERMISSION );
- err = true;
- }
+ oncomplete : function (r, list) {
+ var new_item_hash = list[0].toHash();
+ stores[cl].newItem( new_item_hash );
+ status_update( dojo.string.substitute( cam_strings.SUCCESS_CREATING_CODE, [new_item_hash.code, cl] ) );
+ //highlighter.green.play();
}
- }).send();
+ });
return false;
}
Modified: branches/rel_1_6/Open-ILS/web/conify/global/permission/grp_tree.html
===================================================================
--- branches/rel_1_6/Open-ILS/web/conify/global/permission/grp_tree.html 2010-03-05 16:58:40 UTC (rev 15714)
+++ branches/rel_1_6/Open-ILS/web/conify/global/permission/grp_tree.html 2010-03-05 17:07:32 UTC (rev 15715)
@@ -73,116 +73,84 @@
<script type="text/javascript" src="grp_tree.js"></script>
- </head>
+ <script type="text/javascript"><![CDATA[
+ var dirtyStore = [];
+ var current_group;
- <body class="tundra" id='pagebody'>
+ var _group_list = server.pcrud.retrieveAll('pgt', { order_by : { pgt : 'name' } });
+ var _group_data = pgt.toStoreData( _group_list );
+ var group_store = new dojo.data.ItemFileWriteStore({ data : _group_data });
- <div dojoType="dijit.layout.SplitContainer" orientation="horizontal" style="height: 100%">
+ group_store.onSet = function (item, attr, o, n) {
+ if (attr == 'ischanged') return;
+ if (n == o) return;
+ this.setValue( item, 'ischanged', 1);
+ };
- <div dojoType="dijit.layout.ContentPane" sizeShare="100">
- <script type="dojo/method">
- <![CDATA[
- window.dirtyStore = [];
+ dojo.addOnUnload( function (event) {
- server.pCRUD.request({
- method : 'open-ils.permacrud.search.pgt.atomic',
- timeout : 10,
- params : [ ses, { id : { "!=" : null } }, { order_by : { pgt : 'name' } } ],
- onerror : function (r) { status_update( pgt_strings.ERROR_FETCHING_GROUPS ) },
- oncomplete : function (r) {
- window._group_list = r.recv().content();
- window._group_data = pgt.toStoreData( window._group_list );
- window.group_store = new dojo.data.ItemFileWriteStore({ data : window._group_data });
- window.group_store.onSet = function (item, attr, o, n) {
- if (attr == 'ischanged') return;
- if (n == o) return;
- this.setValue( item, 'ischanged', 1);
- };
- dojo.addOnUnload( function (event) {
+ group_store.fetch({
+ query : { ischanged : 1 },
+ queryOptions : { deep : true },
+ onItem : function (item, req) { try { if (this.isItem( item )) dirtyStore.push( item ); } catch (e) { /* meh */ } },
+ scope : group_store
+ });
- window.group_store.fetch({
- query : { ischanged : 1 },
- queryOptions : { deep : true },
- onItem : function (item, req) { try { if (this.isItem( item )) window.dirtyStore.push( item ); } catch (e) { /* meh */ } },
- scope : window.group_store
- });
+ if (dirtyStore.length > 0) {
+ var confirmation = confirm( pgt_strings.CONFIRM_EXIT_PGT );
- if (dirtyStore.length > 0) {
- var confirmation = confirm( pgt_strings.CONFIRM_EXIT_PGT );
+ if (confirmation) {
+ for (var i in dirtyStore) {
+ current_group = dirtyStore[i];
+ save_group(true);
+ }
+ }
+ }
- if (confirmation) {
- for (var i in window.dirtyStore) {
- window.current_group = window.dirtyStore[i];
- save_group(true);
- }
- }
- }
+ });
- });
- }
- }).send();
+ var _ou_type_list = server.pcrud.retrieveAll('aout', { order_by : { aout : 'depth' } });
+ var _ou_type_data = aout.toStoreData( _ou_type_list );
+ var ou_type_store = new dojo.data.ItemFileReadStore({ data : _ou_type_data });
- server.actor.request({
- method : 'open-ils.actor.org_types.retrieve',
- timeout : 10,
- onerror : function (r) { status_update( pgt_strings.ERROR_FETCHING_TYPES_AOUT ) },
- oncomplete : function (r) {
- window._ou_type_list = r.recv().content();
- window._ou_type_data = aout.toStoreData( window._ou_type_list );
- window.ou_type_store = new dojo.data.ItemFileReadStore({ data : window._ou_type_data });
- }
- }).send();
+ var _perm_list = server.pcrud.retrieveAll('ppl', { order_by : { ppl : 'code' } });
+ var _perm_data = ppl.toStoreData( _perm_list, 'code' );
+ var _perm_name_data = ppl.toStoreData( _perm_list, 'code', { identifier : 'code' } );
- server.actor.request({
- method : 'open-ils.actor.permissions.retrieve',
- timeout : 10,
- onerror : function (r) { status_update( pgt_strings.ERROR_FETCHING_PERMS ) },
- oncomplete : function (r) {
-
- window._perm_list = r.recv().content();
+ var perm_store = new dojo.data.ItemFileWriteStore({ data : _perm_data });
+ var perm_name_store = new dojo.data.ItemFileWriteStore({ data : _perm_name_data });
- window._perm_data = ppl.toStoreData( window._perm_list, 'code' );
- window._perm_name_data = ppl.toStoreData( window._perm_list, 'code', { identifier : 'code' } );
+ var _perm_map_list = server.pcrud.retrieveAll('pgpm');
+ var _perm_map_data = pgpm.toStoreData( _perm_map_list, 'id' );
+ var perm_map_store = new dojo.data.ItemFileWriteStore({ data : _perm_map_data });
- window.perm_store = new dojo.data.ItemFileWriteStore({ data : window._perm_data });
- window.perm_name_store = new dojo.data.ItemFileWriteStore({ data : window._perm_name_data });
-
-
- }
- }).send();
+ perm_map_store.onSet = function (item, attr, o, n) {
+ if (attr == 'ischanged') return;
+ if (n == o) return;
- server.pCRUD.request({
- method : 'open-ils.permacrud.search.pgpm.atomic',
- timeout : 10,
- params : [ ses, { id : { "!=" : null } } ],
- onerror : function (r) { status_update( pgt_strings.ERROR_FETCHING_PERM_MAPS ) },
- oncomplete : function (r) {
- window._perm_map_list = r.recv().content();
- window._perm_map_data = pgpm.toStoreData( window._perm_map_list, 'id' );
- window.perm_map_store = new dojo.data.ItemFileWriteStore({ data : window._perm_map_data });
+ this.setValue( item, 'ischanged', 1);
- window.perm_map_store.onSet = function (item, attr, o, n) {
- if (attr == 'ischanged') return;
- if (n == o) return;
+ if (attr == 'grantable' && (typeof (n) != 'string'))
+ this.setValue(item, 'grantable', n ? 't' : 'f');
+ }
- this.setValue( item, 'ischanged', 1);
+ dojo.addOnUnload( function (event) { save_them_all(); });
- if (attr == 'grantable' && (typeof (n) != 'string'))
- this.setValue(item, 'grantable', n ? 't' : 'f');
- }
+ ]]></script>
- dojo.addOnUnload( function (event) { save_them_all(); });
- }
-
- }).send();
-]]>
- </script>
+ </head>
+
+ <body class="tundra" id='pagebody'>
+
+ <div dojoType="dijit.layout.SplitContainer" orientation="horizontal" style="height: 100%">
+
+ <div dojoType="dijit.layout.ContentPane" sizeShare="100">
<div
id="group_tree"
- label="&conify.grp_tree.permission_groups.label;"
- query="{'_top':'true'}"
+ label="&conify.grp_tree.permission_groups.label;"
dojoType="dijit.Tree"
store="group_store"
+ query="{'_top':'true'}"
minSize="200"
jsId="group_tree"
>
@@ -194,7 +162,7 @@
current_group = item;
window.current_fm_group = new pgt().fromStoreItem(item);
- perm_map_model.query = { grp : current_group ? current_group.id[0] : -1 };
+ perm_map_model.query = { grp : current_group ? group_store.getValue(current_group,'id') : -1 };
perm_map_model.refresh();
perm_grid.refresh();
@@ -397,50 +365,40 @@
var modified_pgt = new pgt().fromStoreItem( current_group );
modified_pgt.isdeleted( 1 );
- server.pCRUD.request({
- method : 'open-ils.permacrud.delete.pgt',
- timeout : 10,
- params : [ ses, modified_pgt ],
+ server.pcrud.eliminate( modified_pgt, {
onerror : function (r) {
highlighter.editor_pane.red.play();
status_update( dojo.string.substitute( pgt_strings.CONFIRM_DELETE, [group_store.getValue( current_group, 'name' )]) );
},
oncomplete : function (r) {
- var res = r.recv();
- if ( res && res.content() ) {
-
- var old_name = group_store.getValue( current_group, 'name' );
+ var old_name = group_store.getValue( current_group, 'name' );
- group_store.fetch({
- query : { id : group_store.getValue( current_group, 'id' ) },
- queryOptions : { deep : true },
- onItem : function (item, req) { try { if (this.isItem( item )) this.deleteItem( item ); } catch (e) { /* meh */ } },
- scope : group_store
- });
-
- current_group = null;
-
- new_kid_button.disabled = true;
- save_group_button.disabled = true;
- delete_group_button.disabled = true;
-
- var main_settings_fields = [ 'name', 'perm_interval', 'description' ];
- for ( var i in main_settings_fields ) {
- var field = main_settings_fields[i];
- window["editor_pane_" + field].setValue( '' ); // unset the value
- window["editor_pane_" + field].setDisplayedValue( '' ); // unset the value
- }
+ group_store.fetch({
+ query : { id : group_store.getValue( current_group, 'id' ) },
+ queryOptions : { deep : true },
+ onItem : function (item, req) { try { if (this.isItem( item )) this.deleteItem( item ); } catch (e) { /* meh */ } },
+ scope : group_store
+ });
- window["editor_pane_usergroup"].setChecked( false ); // unset the value
-
- highlighter.editor_pane.green.play();
- status_update( dojo.string.substitute( pgt_strings.STATUS_DELETED, [old_name]) );
- } else {
- highlighter.editor_pane.red.play();
- status_update( dojo.string.substitute( pgt_strings.ERROR_DELETING, [old_name]) );
+ current_group = null;
+
+ new_kid_button.disabled = true;
+ save_group_button.disabled = true;
+ delete_group_button.disabled = true;
+
+ var main_settings_fields = [ 'name', 'perm_interval', 'description' ];
+ for ( var i in main_settings_fields ) {
+ var field = main_settings_fields[i];
+ window["editor_pane_" + field].setValue( '' ); // unset the value
+ window["editor_pane_" + field].setDisplayedValue( '' ); // unset the value
}
+
+ window["editor_pane_usergroup"].setChecked( false ); // unset the value
+
+ highlighter.editor_pane.green.play();
+ status_update( dojo.string.substitute( pgt_strings.STATUS_DELETED, [old_name]) );
}
- }).send();
+ });
}
]]>
@@ -464,30 +422,18 @@
});
var err = false;
- server.pCRUD.request({
- method : 'open-ils.permacrud.create.pgt',
- timeout : 10,
- params : [ ses, new_fm_obj ],
+
+ server.pcrud.create( new_fm_obj, {
onerror : function (r) {
highlighter.editor_pane.red.play();
status_update( pgt_strings.ERROR_CALLING_METHOD_PGT );
err = true;
},
- oncomplete : function (r) {
- var res = r.recv();
- if ( res && res.content() ) {
- group_store.newItem(
- res.content().toHash(),
- { parent : current_group, attribute : 'children' }
- );
- } else {
- highlighter.editor_pane.red.play();
- status_update( pgt_strings.ERROR_CREATING_CHILD_GROUP );
- err = true;
- }
- },
- }).send();
-
+ oncomplete : function (r,list) {
+ group_store.newItem( list[0].toHash(), { parent : current_group, attribute : 'children' } );
+ }
+ });
+
if (!err) {
highlighter.editor_pane.green.play();
highlighter.group_tree.green.play();
@@ -501,7 +447,7 @@
<div id="perm_pane" dojoType="dijit.layout.ContentPane" title="&conify.grp_tree.group_permissions.title;">
<script type="dojo/connect" event="onShow">
- perm_map_model.query = { grp : current_group ? current_group.id[0] : -1 };
+ perm_map_model.query = { grp : current_group ? group_store.getValue(current_group,'id') : -1 };
perm_map_model.refresh();
perm_grid.refresh();
</script>
@@ -645,36 +591,26 @@
});
var err = false;
- server.pCRUD.request({
- method : 'open-ils.permacrud.create.pgpm',
- timeout : 10,
- params : [ ses, new_fm_obj ],
+ server.pcrud.create(new_fm_obj, {
onerror : function (r) {
highlighter.group_tree.red.play();
status_update( pgt_strings.ERROR_CALLING_METHOD_PERM_MAP );
err = true;
},
- oncomplete : function (r) {
+ oncomplete : function (r, list) {
- var res = r.recv();
- if ( res && res.content() ) {
- var new_item_hash = res.content().toHash();
- perm_map_store.newItem( new_item_hash );
- status_update( pgt_strings.SUCCESS_NEW_PERM_MAP );
- highlighter.group_tree.green.play();
+ var new_item_hash = list[0].toHash();
+ perm_map_store.newItem( new_item_hash );
+ status_update( pgt_strings.SUCCESS_NEW_PERM_MAP );
+ highlighter.group_tree.green.play();
- perm_map_model.query = { grp : current_group ? current_group.id[0] : -1 };
- perm_grid.model.sort(-1);
- perm_map_model.refresh();
- perm_grid.refresh();
+ perm_map_model.query = { grp : current_group ? group_store.getValue(current_group,'id') : -1 };
+ perm_grid.model.sort(-1);
+ perm_map_model.refresh();
+ perm_grid.refresh();
- } else {
- highlighter.group_tree.red.play();
- status_update( pgt_strings.ERROR_CREATING_PERM_MAP );
- err = true;
- }
}
- }).send();
+ });
new_popup._closeDropDown();
]]>
@@ -708,34 +644,25 @@
var modified_pgpm = new pgpm().fromStoreItem( window.current_perm_map );
modified_pgpm.isdeleted( 1 );
- server.pCRUD.request({
- method : 'open-ils.permacrud.delete.pgpm',
- timeout : 10,
- params : [ ses, modified_pgpm ],
+ server.pcrud.eliminate( modified_pgpm, {
onerror : function (r) {
highlighter.editor_pane.red.play();
status_update( dojo.string.substitute( pgt_strings.ERROR_DELETING_PERM_MAPPING, [perm_map_store.getValue( window.current_perm_map, 'id' )] ) );
},
- oncomplete : function (r) {
- var res = r.recv();
- if ( res && res.content() ) {
+ oncomplete : function (r, list) {
- perm_map_store.fetch({
- query : { id : perm_map_store.getValue( window.current_perm_map, 'id' ) },
- onItem : function (item, req) { try { if (this.isItem( item )) this.deleteItem( item ); } catch (e) { /* meh */ } },
- scope : perm_map_store
- });
+ perm_map_store.fetch({
+ query : { id : perm_map_store.getValue( window.current_perm_map, 'id' ) },
+ onItem : function (item, req) { try { if (this.isItem( item )) this.deleteItem( item ); } catch (e) { /* meh */ } },
+ scope : perm_map_store
+ });
- window.current_perm_map = null;
+ window.current_perm_map = null;
- highlighter.editor_pane.green.play();
- status_update( pgt_strings.SUCCESS_DELETED_PERM_MAP );
- } else {
- highlighter.editor_pane.red.play();
- status_update( dojo.string.substitute( pgt_strings.ERROR_DELETING_PERM_MAPPING, [perm_map_store.getValue( window.current_perm_map, 'id' )]) );
- }
+ highlighter.editor_pane.green.play();
+ status_update( pgt_strings.SUCCESS_DELETED_PERM_MAP );
}
- }).send();
+ });
}
]]>
Modified: branches/rel_1_6/Open-ILS/web/conify/global/permission/grp_tree.js
===================================================================
--- branches/rel_1_6/Open-ILS/web/conify/global/permission/grp_tree.js 2010-03-05 16:58:40 UTC (rev 15714)
+++ branches/rel_1_6/Open-ILS/web/conify/global/permission/grp_tree.js 2010-03-05 17:07:32 UTC (rev 15715)
@@ -17,6 +17,7 @@
dojo.require('fieldmapper.AutoIDL');
dojo.require('fieldmapper.dojoData');
+dojo.require('openils.PermaCrud');
dojo.require('openils.widget.TranslatorPopup');
dojo.require('dojo.parser');
dojo.require('dojo.data.ItemFileWriteStore');
@@ -45,12 +46,11 @@
var cookieManager = new HTTP.Cookies();
var ses = cookieManager.read('ses') || cgi.param('ses');
var server = {};
-server.pCRUD = new OpenSRF.ClientSession('open-ils.permacrud');
+server.pcrud = new openils.PermaCrud({ authtoken : ses });
server.actor = new OpenSRF.ClientSession('open-ils.actor');
var pgt_strings = dojo.i18n.getLocalization('openils.conify', 'conify');
-var current_group;
var virgin_out_id = -1;
var highlighter = {};
@@ -68,26 +68,17 @@
save_group_button.disabled = false;
delete_group_button.disabled = false;
- server.pCRUD.request({
- method : 'open-ils.permacrud.update.pgt',
- timeout : 10,
- params : [ ses, modified_pgt ],
+ server.pcrud.update(modified_pgt, {
onerror : function (r) {
highlighter.editor_pane.red.play();
status_update( dojo.string.substitute( pgt_strings.ERROR_SAVING_DATA, [group_store.getValue( current_group, 'name' )]) );
},
oncomplete : function (r) {
- var res = r.recv();
- if ( res && res.content() ) {
- group_store.setValue( current_group, 'ischanged', 0 );
- highlighter.editor_pane.green.play();
- status_update( dojo.string.substitute(pgt_strings.SUCCESS_SAVE, [group_store.getValue( current_group, 'name' )]) );
- } else {
- highlighter.editor_pane.red.play();
- status_update( dojo.string.substitute(pgt_strings.ERROR_SAVING_DATA, [group_store.getValue( current_group, 'name' )]) );
- }
+ group_store.setValue( current_group, 'ischanged', 0 );
+ highlighter.editor_pane.green.play();
+ status_update( dojo.string.substitute(pgt_strings.SUCCESS_SAVE, [group_store.getValue( current_group, 'name' )]) );
},
- }).send();
+ });
}
function save_perm_map (storeItem) {
@@ -95,26 +86,17 @@
var modified_pgpm = new pgpm().fromStoreItem( storeItem );
modified_pgpm.ischanged( 1 );
- server.pCRUD.request({
- method : 'open-ils.permacrud.update.pgpm',
- timeout : 10,
- params : [ ses, modified_pgpm ],
+ server.pcrud.update(modified_pgpm, {
onerror : function (r) {
highlighter.editor_pane.red.play();
status_update( dojo.string.substitute(pgt_strings.ERROR_SAVING_PERM_DATA, [group_store.getValue( current_group, 'name' )]) );
},
oncomplete : function (r) {
- var res = r.recv();
- if ( res && res.content() ) {
- perm_map_store.setValue( storeItem, 'ischanged', 0 );
- highlighter.editor_pane.green.play();
- status_update( dojo.string.substitute(pgt_strings.SUCCESS_SAVE_PERM, [group_store.getValue( current_group, 'name' )]) );
- } else {
- highlighter.editor_pane.red.play();
- status_update( dojo.string.substitute(pgt_strings.ERROR_SAVING_PERM_DATA, [group_store.getValue( current_group, 'name' )]) );
- }
+ perm_map_store.setValue( storeItem, 'ischanged', 0 );
+ highlighter.editor_pane.green.play();
+ status_update( dojo.string.substitute(pgt_strings.SUCCESS_SAVE_PERM, [group_store.getValue( current_group, 'name' )]) );
},
- }).send();
+ });
}
function save_them_all (event) {
Modified: branches/rel_1_6/Open-ILS/web/conify/global/permission/perm_list.html
===================================================================
--- branches/rel_1_6/Open-ILS/web/conify/global/permission/perm_list.html 2010-03-05 16:58:40 UTC (rev 15714)
+++ branches/rel_1_6/Open-ILS/web/conify/global/permission/perm_list.html 2010-03-05 17:07:32 UTC (rev 15715)
@@ -62,95 +62,87 @@
<script type="text/javascript" src="perm_list.js"></script>
- </head>
+ <script type="text/javascript"><![CDATA[
+ var dirtyStore = [];
+ var perm_rows = [];
- <body class="tundra" id='pagebody'>
+ var _perm_list = pCRUD.retrieveAll('ppl', { order_by : { ppl : 'code' } });
+ var _perm_data = ppl.toStoreData( _perm_list, 'code' );
+ var perm_store = new dojo.data.ItemFileWriteStore({ data : _perm_data });
- <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 } );
- window.dirtyStore = [];
+ perm_store.onSet = function (item, attr, o, n) {
+ if (attr == 'ischanged') return;
+ if (n == o) return;
+ this.setValue( item, 'ischanged', 1);
+ };
- 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) {
- 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 });
-
- perm_store.onSet = function (item, attr, o, n) {
- if (attr == 'ischanged') return;
- if (n == o) return;
- this.setValue( item, 'ischanged', 1);
- };
-
- 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 '';
- }
- }
- ]
- ]
+ 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",
+ formatter : function (value) {
+ return '<span class="perm_grid_trans_desc_'+value+'"></span>';
+ },
+ 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 row;
+ }
+ return '';
+ }
}
- ];
+ ]
+ ]
+ }
+ ];
- dojo.addOnUnload( function (event) {
+ dojo.addOnUnload( function (event) {
- 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
- });
+ perm_store.fetch({
+ query : { ischanged : 1 },
+ onItem : function (item, req) { try { if (this.isItem( item )) dirtyStore.push( item ); } catch (e) { /* meh */ } },
+ scope : perm_store
+ });
- if (dirtyStore.length > 0) {
- var confirmation = confirm(ppl_strings.CONFIRM_EXIT_PPL);
+ 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);
- }
- }
- }
-
- });
+ if (confirmation) {
+ for (var i in dirtyStore) {
+ current_perm = dirtyStore[i];
+ save_perm(true);
+ }
}
- }).send();
+ }
+
+ });
]]>
- </script>
+ </script>
+
+ </head>
+
+ <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,42 +158,29 @@
});
var err = false;
- pCRUD.request({
- method : 'open-ils.permacrud.create.ppl',
- timeout : 10,
- params : [ ses, new_fm_obj ],
+ pCRUD.create(new_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 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">
- </script>
- -->
</div>
</div>
@@ -233,36 +212,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();
+ });
}
}
@@ -273,5 +242,11 @@
</div>
</div>
+ <script type="text/javascript">
+ 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 } );
+ </script>
+
</body>
</html>
Modified: branches/rel_1_6/Open-ILS/web/conify/global/permission/perm_list.js
===================================================================
--- branches/rel_1_6/Open-ILS/web/conify/global/permission/perm_list.js 2010-03-05 16:58:40 UTC (rev 15714)
+++ branches/rel_1_6/Open-ILS/web/conify/global/permission/perm_list.js 2010-03-05 17:07:32 UTC (rev 15715)
@@ -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