r2014 + renderRackMultiSelect(): employ OPTGROUP for better rack listing
authorDenis Ovsienko <infrastation@yandex.ru>
Mon, 30 Jun 2008 22:44:20 +0000 (22:44 +0000)
committerDenis Ovsienko <infrastation@yandex.ru>
Mon, 30 Jun 2008 22:44:20 +0000 (22:44 +0000)
inc/interface.php

index 743c92184ea43145e52d2ab483b197b5983cb0a1..8cb67ef078f7f7f71008cea73e3f9883c7731bc6 100644 (file)
@@ -1003,13 +1003,24 @@ function renderRackObject ($object_id = 0)
 
 function renderRackMultiSelect ($sname, $racks, $selected)
 {
-       echo "<select name=${sname} multiple size=" . getConfigVar ('MAXSELSIZE') . " onchange='getElementById(\"racks\").submit()'>\n";
+       // Transform the given flat list into a list of groups, each representing a rack row.
+       $rdata = array();
        foreach ($racks as $rack)
+               if (!isset ($rdata[$rack['row_name']]))
+                       $rdata[$rack['row_name']] = array ($rack['id'] => $rack['name']);
+               else
+                       $rdata[$rack['row_name']][$rack['id']] = $rack['name'];
+       echo "<select name=${sname} multiple size=" . getConfigVar ('MAXSELSIZE') . " onchange='getElementById(\"racks\").submit()'>\n";
+       foreach ($rdata as $optgroup => $racklist)
        {
-               echo "<option value=${rack['id']}";
-               if (!(array_search ($rack['id'], $selected) === FALSE))
-                       echo ' selected';
-               echo">${rack['row_name']}: ${rack['name']}</option>\n";
+               echo "<optgroup label='${optgroup}'>";
+               foreach ($racklist as $rack_id => $rack_name)
+               {
+                       echo "<option value=${rack_id}";
+                       if (!(array_search ($rack_id, $selected) === FALSE))
+                               echo ' selected';
+                       echo">${rack_name}</option>\n";
+               }
        }
        echo "</select>\n";
 }