[open-ils-commits] SPAM: r9160 - in branches/dojo-admin/Open-ILS/web/conify: global global/actor global/permission js/conify/fieldmapper

svn at svn.open-ils.org svn at svn.open-ils.org
Sat Mar 29 02:08:44 EDT 2008


Author: miker
Date: 2008-03-29 01:33:02 -0400 (Sat, 29 Mar 2008)
New Revision: 9160

Added:
   branches/dojo-admin/Open-ILS/web/conify/global/permission/perm_list.html
   branches/dojo-admin/Open-ILS/web/conify/global/permission/perm_list.js
Modified:
   branches/dojo-admin/Open-ILS/web/conify/global/actor/org_unit.html
   branches/dojo-admin/Open-ILS/web/conify/global/actor/org_unit_type.html
   branches/dojo-admin/Open-ILS/web/conify/global/admin.html
   branches/dojo-admin/Open-ILS/web/conify/global/permission/grp_tree.html
   branches/dojo-admin/Open-ILS/web/conify/global/permission/grp_tree.js
   branches/dojo-admin/Open-ILS/web/conify/js/conify/fieldmapper/addToStoreData.js
Log:
moving dojo to /js/; adding the start of the permission editor; using a dropdown for application perms; starting on the group-perm map

Modified: branches/dojo-admin/Open-ILS/web/conify/global/actor/org_unit.html
===================================================================
--- branches/dojo-admin/Open-ILS/web/conify/global/actor/org_unit.html	2008-03-29 04:21:56 UTC (rev 9159)
+++ branches/dojo-admin/Open-ILS/web/conify/global/actor/org_unit.html	2008-03-29 05:33:02 UTC (rev 9160)
@@ -3,9 +3,9 @@
 		<title>Confiy :: Global :: Actor :: Org Units</title>
 
 		<style type="text/css">
-			@import url("/conify/js/dojo/resources/dojo.css");
-			@import url("/conify/js/dijit/themes/tundra/tundra.css");
-			@import url("/conify/js/dojox/widget/Toaster/Toaster.css");
+			@import url("/js/dojo/resources/dojo.css");
+			@import url("/js/dijit/themes/tundra/tundra.css");
+			@import url("/js/dojox/widget/Toaster/Toaster.css");
 		</style>
 
 		<style>
@@ -41,8 +41,8 @@
 		<script language='javascript' src='/opac/common/js/OrgTree.js' type='text/javascript'></script>
 
 		<!-- Dojo goodness -->
-		<script type="text/javascript" src="/conify/js/dojo/dojo.js" djConfig="parseOnLoad: true"></script>
-		<script type="text/javascript" src="/conify/js/dijit/dijit.js"></script>
+		<script type="text/javascript" src="/js/dojo/dojo.js" djConfig="parseOnLoad: true"></script>
+		<script type="text/javascript" src="/js/dijit/dijit.js"></script>
 
 		<script type="text/javascript" src="org_unit.js"></script>
 

Modified: branches/dojo-admin/Open-ILS/web/conify/global/actor/org_unit_type.html
===================================================================
--- branches/dojo-admin/Open-ILS/web/conify/global/actor/org_unit_type.html	2008-03-29 04:21:56 UTC (rev 9159)
+++ branches/dojo-admin/Open-ILS/web/conify/global/actor/org_unit_type.html	2008-03-29 05:33:02 UTC (rev 9160)
@@ -3,9 +3,9 @@
 		<title>Confiy :: Global :: Actor :: Org Unit Types</title>
 
 		<style type="text/css">
-			@import url("/conify/js/dojo/resources/dojo.css");
-			@import url("/conify/js/dijit/themes/tundra/tundra.css");
-			@import url("/conify/js/dojox/widget/Toaster/Toaster.css");
+			@import url("/js/dojo/resources/dojo.css");
+			@import url("/js/dijit/themes/tundra/tundra.css");
+			@import url("/js/dojox/widget/Toaster/Toaster.css");
 		</style>
 
 		<style>
@@ -41,8 +41,8 @@
 		<script language='javascript' src='/opac/common/js/OrgTree.js' type='text/javascript'></script>
 
 		<!-- Dojo goodness -->
-		<script type="text/javascript" src="/conify/js/dojo/dojo.js" djConfig="parseOnLoad: true"></script>
-		<script type="text/javascript" src="/conify/js/dijit/dijit.js"></script>
+		<script type="text/javascript" src="/js/dojo/dojo.js" djConfig="parseOnLoad: true"></script>
+		<script type="text/javascript" src="/js/dijit/dijit.js"></script>
 
 		<script type="text/javascript" src="org_unit_type.js"></script>
 

Modified: branches/dojo-admin/Open-ILS/web/conify/global/admin.html
===================================================================
--- branches/dojo-admin/Open-ILS/web/conify/global/admin.html	2008-03-29 04:21:56 UTC (rev 9159)
+++ branches/dojo-admin/Open-ILS/web/conify/global/admin.html	2008-03-29 05:33:02 UTC (rev 9160)
@@ -3,9 +3,9 @@
 		<title>Conify :: Global :: Admin</title>
 
         <style type="text/css">
-            @import url("/conify/js/dojo/resources/dojo.css");
-            @import url("/conify/js/dijit/themes/tundra/tundra.css");
-            @import url("/conify/js/dojox/widget/Toaster/Toaster.css");
+            @import url("/js/dojo/resources/dojo.css");
+            @import url("/js/dijit/themes/tundra/tundra.css");
+            @import url("/js/dojox/widget/Toaster/Toaster.css");
         </style>
 
         <style>
@@ -20,8 +20,8 @@
         </style>
 
         <!-- Dojo goodness -->
-        <script type="text/javascript" src="/conify/js/dojo/dojo.js" djConfig="parseOnLoad: true"></script>
-        <script type="text/javascript" src="/conify/js/dijit/dijit.js"></script>
+        <script type="text/javascript" src="/js/dojo/dojo.js" djConfig="parseOnLoad: true"></script>
+        <script type="text/javascript" src="/js/dijit/dijit.js"></script>
 
         <script type="text/javascript">
             dojo.require('dojo.parser');
@@ -47,6 +47,7 @@
 					<li><a href="" onclick="dojo.byId('action_iframe').src = 'actor/org_unit_type.html'; return false;">Organization Types</a></li>
 					<li><a href="" onclick="dojo.byId('action_iframe').src = 'actor/org_unit.html'; return false;">Organizational Units</a></li>
 					<li><a href="" onclick="dojo.byId('action_iframe').src = 'permission/grp_tree.html'; return false;">Permission Groups</a></li>
+					<li><a href="" onclick="dojo.byId('action_iframe').src = 'permission/perm_list.html'; return false;">Permissions</a></li>
 				</ul>
 			</div>
 			<div id="content_pane" jsId="content_pane" dojoType="dijit.layout.ContentPane" layoutAlign="client" style="margin: 2px; border-top: 2px solid grey; border-bottom: 2px solid grey; border-left: 2px solid grey;">

Modified: branches/dojo-admin/Open-ILS/web/conify/global/permission/grp_tree.html
===================================================================
--- branches/dojo-admin/Open-ILS/web/conify/global/permission/grp_tree.html	2008-03-29 04:21:56 UTC (rev 9159)
+++ branches/dojo-admin/Open-ILS/web/conify/global/permission/grp_tree.html	2008-03-29 05:33:02 UTC (rev 9160)
@@ -3,9 +3,9 @@
 		<title>Confiy :: Global :: Permission :: Group Tree</title>
 
 		<style type="text/css">
-			@import url("/conify/js/dojo/resources/dojo.css");
-			@import url("/conify/js/dijit/themes/tundra/tundra.css");
-			@import url("/conify/js/dojox/widget/Toaster/Toaster.css");
+			@import url("/js/dojo/resources/dojo.css");
+			@import url("/js/dijit/themes/tundra/tundra.css");
+			@import url("/js/dojox/widget/Toaster/Toaster.css");
 		</style>
 
 		<style>
@@ -41,8 +41,8 @@
 		<script language='javascript' src='/opac/common/js/OrgTree.js' type='text/javascript'></script>
 
 		<!-- Dojo goodness -->
-		<script type="text/javascript" src="/conify/js/dojo/dojo.js" djConfig="parseOnLoad: true"></script>
-		<script type="text/javascript" src="/conify/js/dijit/dijit.js"></script>
+		<script type="text/javascript" src="/js/dojo/dojo.js" djConfig="parseOnLoad: true"></script>
+		<script type="text/javascript" src="/js/dijit/dijit.js"></script>
 
 		<script type="text/javascript" src="grp_tree.js"></script>
 
@@ -62,19 +62,21 @@
                         params : [ ses, { id : { "!=" : null } }, { order_by : { pgt : 'name' } } ],
                         onerror : function (r) { status_update('Problem fetching groups') },
                         oncomplete : function (r) {
-                            ou_group_store = new dojo.data.ItemFileWriteStore({ data : pgt.toStoreData( r.recv().content() ) });
-                            ou_group_store.onSet = function (item, attr, n, o) {
+                            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, n, o) {
                                 if (attr == 'ischanged') return;
                                 if (n == o) return;
                                 this.setValue( item, 'ischanged', 1);
                             };
                             dojo.addOnUnload( function (event) {
 
-                                ou_group_store.fetch({
+                                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 : ou_group_store
+                                    scope : window.group_store
                                 });
 
                                 if (dirtyStore.length > 0) {
@@ -95,13 +97,84 @@
                         }
                     }).send();
 
+					function get_perm_part(part, model, row) {
+						var value;
+						perm_store.fetchItemByIdentity({
+							identity : model.getRow(row).perm,
+							onItem : function (item) { value = perm_store.getValue( item, part ) }
+						});
+						return value;
+					}
+
+					// XXX Use existing perm grabbing functions??  see old interface
+                    pCRUD.request({
+                        method : 'open-ils.permacrud.search.ppl.atomic',
+                        timeout : 10,
+                        params : [ ses, { id : { "!=" : null } }, { order_by : { ppl : 'code' } } ],
+                        onerror : function (r) { status_update('Problem fetching perms') },
+                        oncomplete : function (r) {
+    
+                            window._perm_list = r.recv().content();
+                            window._perm_data = ppl.toStoreData( window._perm_list, 'code' );
+                            window._perm_name_data = ppl.toStoreData( window._perm_list, 'code', { identifier : 'code' } );
+                            window.perm_store = new dojo.data.ItemFileWriteStore({ data : window._perm_data });
+                            window.perm_name_store = new dojo.data.ItemFileWriteStore({ data : window._perm_name_data });
+    
+                            window.current_perm_grid_layout = [
+                                {   cells : [
+                                        [
+                                            {	name : "Depth",
+												field : "perm",
+												width : "5em",
+												noresize : true
+											}, 
+                                            {	name : "Code",
+												//get : dojo.partial(get_perm_part, "code", perm_map_model),
+												width : "300px"
+											},
+                                            {	name : "Description",
+												//get : dojo.partial(get_perm_part, "code", perm_map_model),
+												width : "auto"
+											}
+                                        ]
+                                    ]
+                                }
+                            ];
+    
+                        }
+                    }).send();
+
+                    pCRUD.request({
+                        method : 'open-ils.permacrud.search.pgmp.atomic',
+                        timeout : 10,
+                        params : [ ses, { id : { "!=" : null } } ],
+                        onerror : function (r) { status_update('Problem 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 });
+                        }
+                    }).send();
+
+                    pCRUD.request({
+                        method : 'open-ils.permacrud.search.aout.atomic',
+                        timeout : 10,
+                        params : [ ses, { id : { "!=" : null } }, { order_by : { aout : 'depth' } } ],
+                        onerror : function (r) { status_update('Problem fetching types') },
+                        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.ItemFileWriteStore({ data : window._ou_type_data });
+                        }
+                    }).send();
+
 				</script>
 				<div
 				  id="group_tree"
 				  label="Permission Groups"
 				  query="{'_top':'true'}"
 				  dojoType="dijit.Tree"
-				  store="ou_group_store"
+				  store="group_store"
 				  minSize="200"
 				  jsId="group_tree"
 				>
@@ -119,7 +192,7 @@
 						save_out_button.disabled = false;
 						delete_out_button.disabled = false;
 
-						var main_settings_fields = [ 'name', 'perm_interval', 'description', 'application_perm'];
+						var main_settings_fields = [ 'name', 'perm_interval', 'description'];
 						for ( var i in main_settings_fields ) {
 							var field = main_settings_fields[i];
 							var value = this.store.getValue( current_group, field );
@@ -141,6 +214,8 @@
 							editor_pane_parent.setValue( this.store.getValue( current_group, 'parent' ) );
 						}
 
+						editor_pane_application_perm.setValue( this.store.getValue( current_group, 'application_perm' ) );
+
 						editor_pane_usergroup.setChecked( this.store.getValue( current_group, 'usergroup' ) == 't' ? true : false );
 
 					</script>
@@ -160,7 +235,8 @@
 					window.right_pane_toggler.hide();
 				</script>
 
-					<div id="editor_pane" dojoType="dijit.layout.ContentPane">
+				<div dojoType="dijit.layout.TabContainer">
+					<div id="editor_pane" dojoType="dijit.layout.ContentPane" title="Group Configuration">
 						<script type="dojo/method">
 							highlighter.group_tree = {};
 							highlighter.editor_pane = {};
@@ -177,7 +253,7 @@
 									<span id="editor_pane_name" dojoType="dijit.form.ValidationTextBox" jsId="editor_pane_name" regExp=".+" required="true">
 										<script type="dojo/connect" event="onChange">
 											if (current_group) {
-												ou_group_store.setValue( current_group, "name", this.getValue() );
+												group_store.setValue( current_group, "name", this.getValue() );
 											}
 										</script>
 									</span>
@@ -190,7 +266,7 @@
 									  id="editor_pane_description"
 									  dojoType="dijit.form.Textarea"
 									  jsId="editor_pane_description"
-									  onChange="if (current_group) ou_group_store.setValue( current_group, "description", this.getValue() );"
+									  onChange="if (current_group) group_store.setValue( current_group, "description", this.getValue() );"
 									></textarea>
 								</td>
 							</tr>
@@ -200,7 +276,7 @@
 									<span id="editor_pane_perm_interval" dojoType="dijit.form.ValidationTextBox" jsId="editor_pane_perm_interval" regExp="^\d+ (?:y.*|mo.*|d.*)$" required="true">
 										<script type="dojo/connect" event="onChange">
 											if (current_group) {
-												ou_group_store.setValue( current_group, "perm_interval", this.getValue() );
+												group_store.setValue( current_group, "perm_interval", this.getValue() );
 											}
 										</script>
 									</span>
@@ -209,13 +285,18 @@
 							<tr>
 								<th>Edit Permission</th>
 								<td>
-									<span id="editor_pane_application_perm" dojoType="dijit.form.ValidationTextBox" jsId="editor_pane_application_perm">
+									<div
+									  id="editor_pane_application_perm"
+									  dojoType="dijit.form.FilteringSelect"
+									  store="perm_name_store"
+									  jsId="editor_pane_application_perm"
+									>
 										<script type="dojo/connect" event="onChange">
 											if (current_group && this.getValue()) {
-												ou_group_store.setValue( current_group, "application_perm", this.getValue() );
+												group_store.setValue( current_group, "application_perm", this.getValue() );
 											}
 										</script>
-									</span>
+									</div>
 								</td>
 							</tr>
 							<tr>
@@ -225,7 +306,7 @@
 									  id="editor_pane_parent"
 									  dojoType="dijit.form.FilteringSelect"
 									  jsId="editor_pane_parent"
-									  store="ou_group_store"
+									  store="group_store"
 									  searchAttr="name"
 									  ignoreCase="true"
 									  required="true"
@@ -246,7 +327,7 @@
 									  jsId="editor_pane_usergroup"
 									  type="checkbox"
 									  dojoType="dijit.form.CheckBox"
-									  onChange='if (current_group) ou_group_store.setValue( current_group, "usergroup", this.checked ? "t" : "f" );'
+									  onChange='if (current_group) group_store.setValue( current_group, "usergroup", this.checked ? "t" : "f" );'
 									/>
 								</td>
 							</tr>
@@ -266,9 +347,9 @@
 								</script>
 								<script type="dojo/connect" event="onClick">
 	
-									if (ou_group_store.getValue( current_group, '_trueRoot' ) == 'true') {
+									if (group_store.getValue( current_group, '_trueRoot' ) == 'true') {
 										highlighter.editor_pane.red.play();
-										status_update( 'Cannot delete' + ou_group_store.getValue( current_group, 'name' ) + ', you need at least one.' );
+										status_update( 'Cannot delete' + group_store.getValue( current_group, 'name' ) + ', you need at least one.' );
 										return false;
 									}
 
@@ -282,13 +363,13 @@
 										);
 										if ( existing_kids.length > 0) {
 											highlighter.editor_pane.red.play();
-											status_update( 'Cannot delete' + ou_group_store.getValue( current_group, 'name' ) + ', ' + existing_kids.length + ' subordinates still exist.' );
+											status_update( 'Cannot delete' + group_store.getValue( current_group, 'name' ) + ', ' + existing_kids.length + ' subordinates still exist.' );
 											return;
 										}
 									}
 	
 									if ( confirm('Are you sure you want to delete ' + current_group.name + '?')) {
-										ou_group_store.setValue( current_group, 'isdeleted', 1 );
+										group_store.setValue( current_group, 'isdeleted', 1 );
 	
 										var modified_pgt = new pgt().fromStoreItem( current_group );
 										modified_pgt.isdeleted( 1 );
@@ -299,19 +380,19 @@
 											params : [ ses, modified_pgt ],
 											onerror : function (r) {
 												highlighter.editor_pane.red.play();
-												status_update( 'Problem deleting ' + ou_group_store.getValue( current_group, 'name' ) );
+												status_update( 'Problem deleting ' + group_store.getValue( current_group, 'name' ) );
 											},
 											oncomplete : function (r) {
 												var res = r.recv();
 												if ( res && res.content() ) {
 	
-													var old_name = ou_group_store.getValue( current_group, 'name' );
+													var old_name = group_store.getValue( current_group, 'name' );
 
-													ou_group_store.fetch({
-														query : { id : ou_group_store.getValue( current_group, 'id' ) },
+													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 : ou_group_store
+														scope : group_store
 													});
 	
 													current_group = null;
@@ -320,7 +401,7 @@
 													save_out_button.disabled = true;
 													delete_out_button.disabled = true;
 			
-													var main_settings_fields = [ 'name', 'perm_interval', 'description', 'application_perm' ];
+													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
@@ -355,7 +436,7 @@
 									isnew			: 1,
 									name			: 'New Group',
 									usergroup		: 'f',
-									parent			: ou_group_store.getValue( current_group, 'id' )
+									parent			: group_store.getValue( current_group, 'id' )
 								});
 	
 								var err = false;
@@ -371,7 +452,7 @@
 									oncomplete : function (r) {
 										var res = r.recv();
 										if ( res && res.content() ) {
-											ou_group_store.newItem(
+											group_store.newItem(
 												res.content().toHash(),
 												{ parent : current_group, attribute : 'children' }
 											);
@@ -386,13 +467,21 @@
 								if (!err) {
 									highlighter.editor_pane.green.play();
 									highlighter.group_tree.green.play();
-									status_update( 'New child Group created for ' + ou_group_store.getValue( current_group, 'name' ) );
+									status_update( 'New child Group created for ' + group_store.getValue( current_group, 'name' ) );
 								}
 	
 							</script>
 						</button>
 	
 					</div>
+
+					<div id="perm_pane" dojoType="dijit.layout.ContentPane" title="Group Permissions">
+						<!--
+						<div dojoType="dojox.grid.data.DojoData" id="perm_data_model"jsId="perm_data_model" rowsPerPage="20" store="perm_store" query="{ code : '*' }"></div>
+						<div id="perm_grid" dojoType="dojox.Grid" model="perm_data_model" structure="perm_grid_layout" jsId="perm_grid"></div>
+						-->
+					</div>
+
 				</div>
 			</div>
 		</div>

Modified: branches/dojo-admin/Open-ILS/web/conify/global/permission/grp_tree.js
===================================================================
--- branches/dojo-admin/Open-ILS/web/conify/global/permission/grp_tree.js	2008-03-29 04:21:56 UTC (rev 9159)
+++ branches/dojo-admin/Open-ILS/web/conify/global/permission/grp_tree.js	2008-03-29 05:33:02 UTC (rev 9160)
@@ -19,6 +19,7 @@
 dojo.require('dijit.layout.SplitContainer');
 dojo.require('dojox.widget.Toaster');
 dojo.require('dojox.fx');
+//dojo.require('dojox.grid.Grid');
 
 // some handy globals
 var cgi = new CGI();
@@ -50,17 +51,17 @@
 		params : [ ses, modified_pgt ],
 		onerror : function (r) {
 			highlighter.editor_pane.red.play();
-			status_update( 'Problem saving data for ' + ou_group_store.getValue( current_group, 'name' ) );
+			status_update( 'Problem saving data for ' + group_store.getValue( current_group, 'name' ) );
 		},
 		oncomplete : function (r) {
 			var res = r.recv();
 			if ( res && res.content() ) {
-				ou_group_store.setValue( current_group, 'ischanged', 0 );
+				group_store.setValue( current_group, 'ischanged', 0 );
 				highlighter.editor_pane.green.play();
-				status_update( 'Saved changes to ' + ou_group_store.getValue( current_group, 'name' ) );
+				status_update( 'Saved changes to ' + group_store.getValue( current_group, 'name' ) );
 			} else {
 				highlighter.editor_pane.red.play();
-				status_update( 'Problem saving data for ' + ou_group_store.getValue( current_group, 'name' ) );
+				status_update( 'Problem saving data for ' + group_store.getValue( current_group, 'name' ) );
 			}
 		},
 	}).send();

Added: branches/dojo-admin/Open-ILS/web/conify/global/permission/perm_list.html
===================================================================
--- branches/dojo-admin/Open-ILS/web/conify/global/permission/perm_list.html	                        (rev 0)
+++ branches/dojo-admin/Open-ILS/web/conify/global/permission/perm_list.html	2008-03-29 05:33:02 UTC (rev 9160)
@@ -0,0 +1,214 @@
+<html xmlns="http://www.w3.org/1999/xhtml">
+	<head>
+		<title>Confiy :: Global :: Permission :: Permission List</title>
+
+		<style type="text/css">
+			@import url("/js/dojox/grid/_grid/tundraGrid.css");
+			@import url("/js/dojo/resources/dojo.css");
+			@import url("/js/dijit/themes/tundra/tundra.css");
+			@import url("/js/dojox/widget/Toaster/Toaster.css");
+		</style>
+
+		<style>
+			html, body {
+				height: 100%;
+				width: 100%;
+				margin: 0px 0px 0px 0px;
+				padding: 0px 0px 0px 0px;
+				overflow: hidden;
+			}
+
+			#perm_grid {
+				border: 1px solid #333;
+				width: 100%;
+				height: 90%;
+			}
+		</style>
+
+		<!-- The OpenSRF API writ JS -->
+		<script language='javascript' src='/opac/common/js/utils.js' type='text/javascript'></script>
+		<script language='javascript' src='/opac/common/js/Cookies.js' type='text/javascript'></script>
+		<script language='javascript' src='/opac/common/js/CGI.js' type='text/javascript'></script>
+		<script language='javascript' src='/opac/common/js/JSON_v1.js' type='text/javascript'></script>
+		<script language='javascript' src='/opac/common/js/opensrf.js' type='text/javascript'></script>
+		<script language='javascript' src='/opac/common/js/opensrf_xhr.js' type='text/javascript'></script>
+
+		<!-- Fieldmapper objects -->
+		<script language='javascript' src='/opac/common/js/fmall.js' type='text/javascript'></script>
+		<script language='javascript' src='/opac/common/js/fmgen.js' type='text/javascript'></script>
+		<script language='javascript' src='/opac/common/js/OrgTree.js' type='text/javascript'></script>
+
+		<!-- Dojo goodness -->
+		<script type="text/javascript" src="/js/dojo/dojo.js" djConfig="parseOnLoad: true"></script>
+		<script type="text/javascript" src="/js/dijit/dijit.js"></script>
+
+		<script type="text/javascript" src="perm_list.js"></script>
+
+	</head>
+
+	<body class="tundra" id='pagebody'>
+
+		<div dojoType="dijit.layout.ContentPane" id="grid_container" jsId="grid_container">
+			<script type="dojo/method">
+				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 = [];
+
+                pCRUD.request({
+                    method : 'open-ils.permacrud.search.ppl.atomic',
+                    timeout : 10,
+                    params : [ ses, { id : { "!=" : null } }, { order_by : { ppl : 'code' } } ],
+                    onerror : function (r) { status_update('Problem 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, n, o) {
+                            if (attr == 'ischanged') return;
+                            if (n == o) return;
+                            this.setValue( item, 'ischanged', 1);
+                        };
+
+						window.perm_grid_layout = [
+							{	cells : [
+									[
+										{ name : "ID", field : "id", width : "5em", noresize : true }, 
+										{ name : "Code", field : "code", width : "300px", editor : dojox.grid.editors.Dijit }, 
+										{ name : "Description", field : "description", width : "100%", editor : dojox.grid.editors.Editor }
+									]
+								]
+							}
+						];
+
+                        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
+                            });
+
+                            if (dirtyStore.length > 0) {
+                                var confirmation = confirm(
+                                    'There are unsaved modified Permissions!  '+
+                                    'OK to save these changes, Cancel to abandon them.'
+                                );
+
+                                if (confirmation) {
+                                    for (var i in window.dirtyStore) {
+                                        window.current_perm = window.dirtyStore[i];
+                                        save_perm(true);
+                                    }
+                                }
+                            }
+
+                        });
+                    }
+                }).send();
+
+			</script>
+
+			<div dojoType="dojox.grid.data.DojoData" id="perm_data_model"jsId="perm_data_model" rowsPerPage="20" 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>
+
+		<div dojoType="dijit.layout.ContentPane" orientation="horizontal" style="margin-bottom: 20px;">
+	
+			<button jsId="save_ppl_button" dojoType="dijit.form.Button" label="Save" onClick="save_perm()">
+				<script type="dojo/connect" event="startup">
+					this.disabled = true;
+				</script>
+			</button>
+	
+			<button jsId="delete_ppl_button" dojoType="dijit.form.Button" label="Delete">
+				<script type="dojo/connect" event="startup">
+					this.disabled = true;
+				</script>
+				<script type="dojo/connect" event="onClick">
+	
+					if (perm_store.getValue( current_perm, '_trueRoot' ) == 'true') {
+						highlighter.red.play();
+						status_update( 'Cannot delete' + perm_store.getValue( current_perm, 'code' ) + ', you need at least one.' );
+						return false;
+					}
+
+					if ( current_perm.children ) {
+						var kids = current_perm.children;
+						if (!dojo.isArray(kids)) kids = [kids];
+	
+						var existing_kids = dojo.filter(
+							kids,
+							function(kid){ return kid.isdeleted[0] != 1 }
+						);
+						if ( existing_kids.length > 0) {
+							highlighter.red.play();
+							status_update( 'Cannot delete' + perm_store.getValue( current_perm, 'code' ) + ', ' + existing_kids.length + ' subordinates still exist.' );
+							return;
+						}
+					}
+	
+					if ( confirm('Are you sure you want to delete ' + current_perm.name + '?')) {
+						perm_store.setValue( current_perm, 'isdeleted', 1 );
+	
+						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 ],
+							onerror : function (r) {
+								highlighter.red.play();
+								status_update( 'Problem 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;
+	
+									new_kid_button.disabled = true;
+									save_ppl_button.disabled = true;
+									delete_ppl_button.disabled = true;
+			
+									var main_settings_fields = [ 'code', '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
+									}
+
+									highlighter.green.play();
+									status_update( old_name + ' deleted' );
+								} else {
+									highlighter.red.play();
+									status_update( 'Problem deleting ' + old_name );
+								}
+							}
+						}).send();
+	
+					}
+	
+				</script>
+			</button>
+	
+		</div>
+	
+	</body>
+</html>

Added: branches/dojo-admin/Open-ILS/web/conify/global/permission/perm_list.js
===================================================================
--- branches/dojo-admin/Open-ILS/web/conify/global/permission/perm_list.js	                        (rev 0)
+++ branches/dojo-admin/Open-ILS/web/conify/global/permission/perm_list.js	2008-03-29 05:33:02 UTC (rev 9160)
@@ -0,0 +1,62 @@
+dojo.require('conify.fieldmapper.addToHash', true);
+dojo.require('conify.fieldmapper.addFromHash', true);
+dojo.require('conify.fieldmapper.addToStoreData', true);
+dojo.require('conify.fieldmapper.addFromStoreItem', true);
+dojo.require('dojo.parser');
+dojo.require('dojo.data.ItemFileWriteStore');
+dojo.require('dijit.form.TextBox');
+dojo.require('dijit.form.ValidationTextBox');
+dojo.require('dijit.form.Textarea');
+dojo.require('dijit.layout.ContentPane');
+dojo.require('dojox.widget.Toaster');
+dojo.require('dojox.fx');
+dojo.require('dojox.grid.Grid');
+dojo.require('dojox.grid._data.model');
+dojo.require("dojox.grid.editors");
+
+// some handy globals
+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 current_perm;
+var virgin_out_id = -1;
+
+var highlighter = {};
+
+function status_update (markup) {
+	if (parent !== window && parent.status_update) parent.status_update( markup );
+}
+
+function save_perm () {
+
+	var modified_ppl = new ppl().fromStoreItem( current_perm );
+	modified_ppl.ischanged( 1 );
+
+	new_kid_button.disabled = false;
+	save_out_button.disabled = false;
+	delete_out_button.disabled = false;
+
+	pCRUD.request({
+		method : 'open-ils.permacrud.update.ppl',
+		timeout : 10,
+		params : [ ses, modified_ppl ],
+		onerror : function (r) {
+			highlighter.red.play();
+			status_update( 'Problem saving data for ' + 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( 'Saved changes to ' + perm_store.getValue( current_perm, 'code' ) );
+			} else {
+				highlighter.red.play();
+				status_update( 'Problem saving data for ' + perm_store.getValue( current_perm, 'code' ) );
+			}
+		},
+	}).send();
+}
+

Modified: branches/dojo-admin/Open-ILS/web/conify/js/conify/fieldmapper/addToStoreData.js
===================================================================
--- branches/dojo-admin/Open-ILS/web/conify/js/conify/fieldmapper/addToStoreData.js	2008-03-29 04:21:56 UTC (rev 9159)
+++ branches/dojo-admin/Open-ILS/web/conify/js/conify/fieldmapper/addToStoreData.js	2008-03-29 05:33:02 UTC (rev 9160)
@@ -1,14 +1,18 @@
 
 function _toStoreData (list, label, params) {
 
+	if (!params) params = {};
+
 	// a sane default
 	if (!params.identifier) params.identifier = 'id';
+	if (!label) label = params.label;
+	if (!label) label = params.identifier;
 
-	var data = { label : 'shortname', identifier : 'id', items : [] };
+	var data = { label : label, identifier : params.identifier, items : [] };
 
 	for (var i in list) data.items.push( list[i].toHash() );
 
-	if (params.children && params['parent']) {
+	if (params.children && params.parent) {
 		var _hash_list = data.items;
 
 		var _find_root = {};
@@ -23,7 +27,7 @@
 
 			for (var j in _hash_list) {
 				var kid = _hash_list[j];
-				if (kid[params['parent']] == obj[params.identifier]) {
+				if (kid[params.parent] == obj[params.identifier]) {
 					obj[params.children].push( { _reference : kid[params.identifier] } );
 					kid._iskid = true;
 					if (_find_root[kid[params.identifier]]) delete _find_root[kid[params.identifier]];
@@ -35,7 +39,7 @@
 
 		for (var j in _find_root) {
 			_find_root[j]['_top'] = 'true';
-			if (!_find_root[j][params['parent']])
+			if (!_find_root[j][params.parent])
 				_find_root[j]['_trueRoot'] = 'true';
 		}
 
@@ -63,4 +67,10 @@
 	return _toStoreData(list, label, { 'parent' : 'parent', 'children' : 'children' });
 }
 
+/*
+ppl.toStoreData = function (list, label) {
+	if (!label) label = 'code';
+	return _toStoreData(list, label, {});
+}
+*/
 



More information about the open-ils-commits mailing list