[open-ils-commits] r7831 - trunk/Open-ILS/xul/staff_client/server/cat

svn at svn.open-ils.org svn at svn.open-ils.org
Tue Sep 25 17:51:59 EDT 2007


Author: phasefx
Date: 2007-09-25 17:42:16 -0400 (Tue, 25 Sep 2007)
New Revision: 7831

Modified:
   trunk/Open-ILS/xul/staff_client/server/cat/copy_editor.js
   trunk/Open-ILS/xul/staff_client/server/cat/copy_editor.xul
Log:
Library filter for stat cats in item attribute editor.  need to make it sticky, and need to pull in stat cats based on owning_lib and circ_lib (and re-render the stat cats if any of those change in the eidtor)

Modified: trunk/Open-ILS/xul/staff_client/server/cat/copy_editor.js
===================================================================
--- trunk/Open-ILS/xul/staff_client/server/cat/copy_editor.js	2007-09-25 21:08:53 UTC (rev 7830)
+++ trunk/Open-ILS/xul/staff_client/server/cat/copy_editor.js	2007-09-25 21:42:16 UTC (rev 7831)
@@ -136,9 +136,10 @@
 						+ sc.id() + '; } ); l ? l.value() : "<Unset>";',
 					input: 'c = function(v){ g.apply_stat_cat(' + sc.id() + ',v); if (typeof post_c == "function") post_c(v); }; x = util.widgets.make_menulist( [ [ "<Remove Stat Cat>", -1 ] ].concat( util.functional.map_list( g.data.hash.asc[' + sc.id() 
 						+ '].entries(), function(obj){ return [ obj.value(), obj.id() ]; } ) ).sort() ); '
-					//input: 'c = function(v){ g.apply_stat_cat(' + sc.id() + ',v); if (typeof post_c == "function") post_c(v); }; x = util.widgets.make_menulist( [ [ "<Remove Stat Cat>", null ] ].concat( util.functional.map_list( g.data.hash.asc[' + sc.id() 
-					//	+ '].entries(), function(obj){ return [ obj.value(), obj.id() ]; } ).sort() ) ); '
 						+ 'x.addEventListener("apply",function(f){ return function(ev) { f(ev.target.value); } }(c),false);',
+                    attr: {
+                        sc_lib: sc.owner(),
+                    }
 				}
 			];
 
@@ -147,7 +148,7 @@
 			g.panes_and_field_names.right_pane4.push( temp_array );
 		}
 
-		/* The stat cats for the pertinent library */
+		/* The stat cats for the pertinent library -- this is based on workstation ou */
 		for (var i = 0; i < g.data.list.my_asc.length; i++) {
 			add_stat_cat( g.data.list.my_asc[i] );	
 		}
@@ -162,6 +163,8 @@
 			}
 		}
 
+        g.panes_and_field_names.right_pane4.sort();
+
 		/******************************************************************************************************/
 		/* Backup copies :) */
 
@@ -963,6 +966,7 @@
 
 		var field_name = g.field_names[i][0];
 		var render = g.field_names[i][1].render;
+        var attr = g.field_names[i][1].attr;
 		g.summary[ field_name ] = {};
 
 		/******************************************************************************************************/
@@ -1015,6 +1019,28 @@
 	}
 
 	/******************************************************************************************************/
+	/* Populate the library filter menu for stat cats */
+
+    var sc_libs = {};
+    for (var i = 0; i < g.panes_and_field_names.right_pane4.length; i++) {
+        sc_libs[ g.panes_and_field_names.right_pane4[i][1].attr.sc_lib ] = true;
+    }
+    var sc_libs2 = [];
+    for (var i in sc_libs) { sc_libs2.push( [ g.data.hash.aou[ i ].shortname(), i ] ); }
+    sc_libs2.sort();
+    var x = document.getElementById("stat_cat_lib_filter_menu").firstChild;
+    JSAN.use('util.widgets'); util.widgets.remove_children(x);
+    for (var i = 0; i < sc_libs2.length; i++) {
+        var menuitem = document.createElement('menuitem');
+        menuitem.setAttribute('type','checkbox');
+        menuitem.setAttribute('checked','true');
+        menuitem.setAttribute('label',sc_libs2[i][0]);
+        menuitem.setAttribute('value',sc_libs2[i][1]);
+        menuitem.setAttribute('oncommand','try{g.toggle_stat_cat_display(this);}catch(E){alert(E);}');
+        x.appendChild(menuitem);
+    }
+
+	/******************************************************************************************************/
 	/* Prepare the panes */
 
 	var groupbox; var caption; var vbox; var grid; var rows;
@@ -1026,8 +1052,13 @@
 		if (!document.getElementById(h)) continue;
 		for (var i = 0; i < g.panes_and_field_names[h].length; i++) {
 			try {
-				var f = g.panes_and_field_names[h][i]; var fn = f[0];
+				var f = g.panes_and_field_names[h][i]; var fn = f[0]; var attr = f[1].attr;
 				groupbox = document.createElement('groupbox'); document.getElementById(h).appendChild(groupbox);
+                if (attr) {
+                    for (var a in attr) {
+                        groupbox.setAttribute(a,attr[a]);
+                    }
+                }
 				if (typeof g.changed[fn] != 'undefined') groupbox.setAttribute('class','copy_editor_field_changed');
 				caption = document.createElement('caption'); groupbox.appendChild(caption);
 				caption.setAttribute('label',fn); caption.setAttribute('id','caption_'+fn);
@@ -1087,6 +1118,7 @@
 
 		var input_cmd = blob.input;
 		var render_cmd = blob.render;
+        var attr = blob.attr;
 
 		var block = false; var first = true;
 
@@ -1219,3 +1251,17 @@
 	);
 }
 
+/******************************************************************************************************/
+/* hides or unhides stat cats based on library stat cat filter menu */
+g.toggle_stat_cat_display = function(el) {
+    var visible = el.getAttribute('checked');
+    var nl = document.getElementsByAttribute('sc_lib',el.getAttribute('value'));
+    for (var n = 0; n < nl.length; n++) {
+        if (visible) {
+            nl[n].setAttribute('hidden','false');
+        } else {
+            nl[n].setAttribute('hidden','true');
+        }
+    }
+}
+

Modified: trunk/Open-ILS/xul/staff_client/server/cat/copy_editor.xul
===================================================================
--- trunk/Open-ILS/xul/staff_client/server/cat/copy_editor.xul	2007-09-25 21:08:53 UTC (rev 7830)
+++ trunk/Open-ILS/xul/staff_client/server/cat/copy_editor.xul	2007-09-25 21:42:16 UTC (rev 7831)
@@ -76,6 +76,9 @@
 			<splitter><grippy /></splitter>
 			<vbox flex="1">
 				<button style="font-weight: bold; font-size: normal" label="Statistics" accesskey="4" oncommand="document.getElementById('right_pane4').firstChild.firstChild.focus();"/>
+                <menu label="Library Filter" id="stat_cat_lib_filter_menu">
+                    <menupopup />
+                </menu>
 				<vbox id="right_pane4" flex="1"/>
 			</vbox>
 		</hbox>



More information about the open-ils-commits mailing list