[open-ils-commits] r9162 - branches/dojo-admin/Open-ILS/web/conify/global/permission

svn at svn.open-ils.org svn at svn.open-ils.org
Sat Mar 29 21:35:12 EDT 2008


Author: miker
Date: 2008-03-29 20:59:24 -0400 (Sat, 29 Mar 2008)
New Revision: 9162

Modified:
   branches/dojo-admin/Open-ILS/web/conify/global/permission/perm_list.html
   branches/dojo-admin/Open-ILS/web/conify/global/permission/perm_list.js
Log:
we can add (mostly) and update permissions now

Modified: branches/dojo-admin/Open-ILS/web/conify/global/permission/perm_list.html
===================================================================
--- branches/dojo-admin/Open-ILS/web/conify/global/permission/perm_list.html	2008-03-29 05:37:48 UTC (rev 9161)
+++ branches/dojo-admin/Open-ILS/web/conify/global/permission/perm_list.html	2008-03-30 00:59:24 UTC (rev 9162)
@@ -21,8 +21,13 @@
 			#perm_grid {
 				border: 0px;
 				width: 100%;
-				height: 88%;
+				height: 100%;
 			}
+
+			#grid_container {
+				width: 100%;
+				height: 100%;
+			}
 		</style>
 
 		<!-- The OpenSRF API writ JS -->
@@ -48,7 +53,7 @@
 
 	<body class="tundra" id='pagebody'>
 
-		<div dojoType="dijit.layout.ContentPane" id="grid_container" jsId="grid_container">
+		<div dojoType="dijit.layout.LayoutContainer" id="grid_container" jsId="grid_container" orientation="vertical">
 			<script type="dojo/method">
 				window.highlighter= {};
 				window.highlighter.green = dojox.fx.highlight( { color : '#B4FFB4', node : 'grid_container', duration : 500 } );
@@ -112,102 +117,142 @@
 
 			</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 dojoType="dijit.layout.LayoutContainer" orientation="horizontal" style="margin-top: 5px;" layoutAlign="top">
+				<span>New Permission:</span>
+				<div dojoType="dijit.form.TextBox" id="new_perm_code" jsId="new_perm_code" label="New Code"></div>
+				<button dojoType="dijit.form.Button" id="save_new_perm_code" jsId="save_new_perm_code" label="Add"> 
+					<script type="dojo/connect" event="onClick">
+
+						var new_code = new_perm_code.getValue();
+						if (!new_code) return;
+
+    	                var new_fm_obj = new ppl().fromHash({
+        	                isnew           : 1,
+            	            code            : new_code
+	                    });
+    
+    	                var err = false;
+        	            pCRUD.request({
+            	            method : 'open-ils.permacrud.create.ppl',
+                	        timeout : 10,
+                    	    params : [ ses, new_fm_obj ],
+	                        onerror : function (r) {
+    	                        highlighter.red.play();
+        	                    status_update( 'Problem calling method to create new Permission' );
+            	                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( 'New ' + new_item_hash.code + ' permission created' );
+									highlighter.green.play();
+                            	} else {
+	                                highlighter.red.play();
+    	                            status_update( 'Problem creating new Permission' );
+        	                        err = true;
+            	                }
+                	        }
+                    	}).send();
+    
+	                </script>
+				</button>
 			</div>
 
-		</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" 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) {
+			<div dojoType="dijit.layout.ContentPane" orientation="horizontal" style="margin-bottom: 5px;" layoutAlign="bottom">
+		
+				<button jsId="save_ppl_button" dojoType="dijit.form.Button" label="Save Changes" onClick="save_them_all()">
+				</button>
+		
+				<button jsId="delete_ppl_button" dojoType="dijit.form.Button" label="Delete Selected">
+					<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' ) + ', ' + existing_kids.length + ' subordinates still exist.' );
-							return;
+							status_update( 'Cannot delete' + perm_store.getValue( current_perm, 'code' ) + ', you need at least one.' );
+							return false;
 						}
-					}
 	
-					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) {
+						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( 'Problem deleting ' + perm_store.getValue( current_perm, 'code' ) );
-							},
-							oncomplete : function (r) {
-								var res = r.recv();
-								if ( res && res.content() ) {
+								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' );
 	
-									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
-									});
+										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
+										}
 	
-									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 );
 									}
-
-									highlighter.green.play();
-									status_update( old_name + ' deleted' );
-								} else {
-									highlighter.red.play();
-									status_update( 'Problem deleting ' + old_name );
 								}
-							}
-						}).send();
+							}).send();
 	
-					}
+						}
 	
-				</script>
-			</button>
+					</script>
+				</button>
 	
+			</div>
 		</div>
 	
 	</body>

Modified: branches/dojo-admin/Open-ILS/web/conify/global/permission/perm_list.js
===================================================================
--- branches/dojo-admin/Open-ILS/web/conify/global/permission/perm_list.js	2008-03-29 05:37:48 UTC (rev 9161)
+++ branches/dojo-admin/Open-ILS/web/conify/global/permission/perm_list.js	2008-03-30 00:59:24 UTC (rev 9162)
@@ -8,6 +8,8 @@
 dojo.require('dijit.form.ValidationTextBox');
 dojo.require('dijit.form.Textarea');
 dojo.require('dijit.layout.ContentPane');
+dojo.require('dijit.layout.LayoutContainer');
+dojo.require('dijit.layout.BorderContainer');
 dojo.require('dojox.widget.Toaster');
 dojo.require('dojox.fx');
 dojo.require('dojox.grid.Grid');
@@ -34,10 +36,6 @@
 	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,
@@ -60,3 +58,33 @@
 	}).send();
 }
 
+function save_them_all (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
+	});
+
+	var confirmation = true;
+
+
+	if (event && dirtyStore.length > 0) {
+		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);
+		}
+
+		window.dirtyStore = [];
+	}
+}
+
+dojo.addOnUnload( save_them_all );
+



More information about the open-ils-commits mailing list