[open-ils-commits] r19729 - branches/rel_2_1/Open-ILS/xul/staff_client/server/patron (dbs)

svn at svn.open-ils.org svn at svn.open-ils.org
Sun Mar 13 18:16:26 EDT 2011


Author: dbs
Date: 2011-03-13 18:16:20 -0400 (Sun, 13 Mar 2011)
New Revision: 19729

Modified:
   branches/rel_2_1/Open-ILS/xul/staff_client/server/patron/search_form.js
   branches/rel_2_1/Open-ILS/xul/staff_client/server/patron/search_form_overlay.xul
Log:
Normalize patron profile search function in "Search for Patrons" UI

Use util.widgets.make_menulist for a more consistent approach to
generating the menulist and use a row/label/hbox layout to normalize the
appearance of the patron profile filter in the search menu.


Modified: branches/rel_2_1/Open-ILS/xul/staff_client/server/patron/search_form.js
===================================================================
--- branches/rel_2_1/Open-ILS/xul/staff_client/server/patron/search_form.js	2011-03-13 22:15:49 UTC (rev 19728)
+++ branches/rel_2_1/Open-ILS/xul/staff_client/server/patron/search_form.js	2011-03-13 22:16:20 UTC (rev 19729)
@@ -232,7 +232,7 @@
                             };
                         }
                     ],
-                    'profile' : [ ['render'],function(e) {
+                    'profile' : [ ['render'], function(e) {
                             return function() {};
                         } 
                     ],
@@ -243,7 +243,7 @@
                     'search_depth' : [ ['render'],function(e) {
                             return function() {};
                         }
-                    ],
+                    ]
                 }
             }
         );
@@ -286,7 +286,7 @@
         util.widgets.load_attributes(file);
         ml.value = ml.getAttribute('value');
         if (! ml.value) {
-            ml.value = 0
+            ml.value = 0;
             ml.setAttribute('value',ml.value);
         }
 
@@ -299,14 +299,34 @@
         );
         cb.checked = cb.getAttribute('value') == "true" ? true : false;
 
-        var menupopup = document.getElementById('profile').firstChild;
-        for (var i = 0; i < obj.OpenILS.data.list.pgt.length; i++) { 
-            var my_pgt = obj.OpenILS.data.list.pgt[i]; 
-            var menuitem = document.createElement('menuitem'); 
-            menuitem.setAttribute('label',my_pgt.name()); 
-            menuitem.setAttribute('value',my_pgt.id());
-            menupopup.appendChild(menuitem); 
-        };
+        /* Populate the Patron Profile filter */
+        util.widgets.remove_children(obj.controller.view.profile);
+        var profile_ml = util.widgets.make_menulist(
+            util.functional.map_list( obj.OpenILS.data.list.pgt,
+                function(el,idx) {
+                    return [ el.name(), el.id() ]
+                }
+            ).sort(
+                function(a,b) {
+                    if (a[0] < b[0]) return -1;
+                    if (a[0] > b[0]) return 1;
+                    return 0;
+                }
+            )
+        );
+        profile_ml.addEventListener('command', function() {
+                profile_ml.parentNode.setAttribute('value', profile_ml.value);
+            }, false
+        );
+        profile_ml.setAttribute('id','profile_ml');
+
+        /* Add an empty menu item as the default profile */
+        var empty = document.createElement('menuitem'); 
+        profile_ml.firstChild.insertBefore(empty, profile_ml.firstChild.firstChild);
+        empty.setAttribute('label', '');
+        empty.setAttribute('value', ''); 
+        obj.controller.view.profile.appendChild(profile_ml);
+        profile_ml.value = profile_ml.getAttribute('value');
     },
 
     'on_submit' : function(q) {
@@ -326,7 +346,7 @@
                     query[id] = node.getAttribute('value');
                     obj.error.sdump('D_DEBUG','id = ' + id + '  value = ' + node.getAttribute('value') + '\n');
                 } else if (id == 'profile') {
-                    query[id] = node.selectedItem.getAttribute('value');
+                    query[id] = node.firstChild.getAttribute('value');
                     obj.error.sdump('D_DEBUG','id = ' + id + '  value = ' + node.getAttribute('value') + '\n');
                 } else {
                     if (id == 'search_depth') {

Modified: branches/rel_2_1/Open-ILS/xul/staff_client/server/patron/search_form_overlay.xul
===================================================================
--- branches/rel_2_1/Open-ILS/xul/staff_client/server/patron/search_form_overlay.xul	2011-03-13 22:15:49 UTC (rev 19728)
+++ branches/rel_2_1/Open-ILS/xul/staff_client/server/patron/search_form_overlay.xul	2011-03-13 22:16:20 UTC (rev 19729)
@@ -125,16 +125,10 @@
                 accesskey="&staff.patron_search_form.post_code.accesskey;"/>
             <textbox id="post_code" group="1" context="clipboard"/>
         </row>
-        <vbox flex="1" style="overflow: auto">
-            <groupbox flex="1">
-                <caption label="&staff.patron_search_form.profile.label;" />
-                <menulist id="profile">
-                    <menupopup>
-                        <menuitem label="" value=""/>
-                    </menupopup>
-                </menulist>
-            </groupbox>
-        </vbox>
+        <row>
+            <label value="&staff.patron_search_form.profile.label;"/>
+            <hbox id="profile" />
+        </row>
         <row id="psr12">
             <spacer id="pss12"/>
             <button id="search" label="&staff.patron_search_form.search.label;" 



More information about the open-ils-commits mailing list