From: phasefx Date: Tue, 25 Sep 2007 21:42:16 +0000 (+0000) Subject: Library filter for stat cats in item attribute editor. need to make it sticky, and... X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=f3de11037b8616235a3734a7b7eb8fcbd292ac85;p=Evergreen.git 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) git-svn-id: svn://svn.open-ils.org/ILS/trunk@7831 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- diff --git a/Open-ILS/xul/staff_client/server/cat/copy_editor.js b/Open-ILS/xul/staff_client/server/cat/copy_editor.js index 77e41bf81b..411c3a2b76 100644 --- a/Open-ILS/xul/staff_client/server/cat/copy_editor.js +++ b/Open-ILS/xul/staff_client/server/cat/copy_editor.js @@ -136,9 +136,10 @@ function my_init() { + sc.id() + '; } ); l ? l.value() : "";', input: 'c = function(v){ g.apply_stat_cat(' + sc.id() + ',v); if (typeof post_c == "function") post_c(v); }; x = util.widgets.make_menulist( [ [ "", -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( [ [ "", 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 @@ function my_init() { 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 @@ function my_init() { } } + g.panes_and_field_names.right_pane4.sort(); + /******************************************************************************************************/ /* Backup copies :) */ @@ -963,6 +966,7 @@ g.summarize = function( copies ) { 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 @@ g.render = function() { } /******************************************************************************************************/ + /* 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 @@ g.render = function() { 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 @@ g.render_input = function(node,blob) { var input_cmd = blob.input; var render_cmd = blob.render; + var attr = blob.attr; var block = false; var first = true; @@ -1219,3 +1251,17 @@ g.copy_notes = function() { ); } +/******************************************************************************************************/ +/* 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'); + } + } +} + diff --git a/Open-ILS/xul/staff_client/server/cat/copy_editor.xul b/Open-ILS/xul/staff_client/server/cat/copy_editor.xul index bb190e5a98..9dfc6ffddd 100644 --- a/Open-ILS/xul/staff_client/server/cat/copy_editor.xul +++ b/Open-ILS/xul/staff_client/server/cat/copy_editor.xul @@ -76,6 +76,9 @@